feat: add outbound interface binding

This commit is contained in:
lbl
2026-08-22 07:58:18 +08:00
parent 55d47c5a1c
commit 74c47bce69
29 changed files with 562 additions and 74 deletions
+3
View File
@@ -254,6 +254,7 @@ pub struct StartConfig {
pub device_id: Option<String>,
pub device_name: Option<String>,
pub tun_name: Option<String>,
pub outbound_interface: Option<String>,
pub ip: Option<Ipv4Addr>,
pub password: Option<String>,
#[serde(default)]
@@ -1389,6 +1390,7 @@ fn convert_config(cfg: StartConfig) -> anyhow::Result<CoreConfig> {
device_id,
device_name,
tun_name: cfg.tun_name,
outbound_interface: cfg.outbound_interface,
password: cfg.password,
cert_mode,
input: cfg.input,
@@ -1690,6 +1692,7 @@ mod tests {
device_id: Some("device-a".to_string()),
device_name: None,
tun_name: None,
outbound_interface: None,
ip: None,
password: None,
no_punch: false,
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -19,8 +19,8 @@
if (dark) document.documentElement.classList.add("dark");
})();
</script>
<script type="module" crossorigin src="/assets/index-DIvs683K.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-F22jYCcu.css">
<script type="module" crossorigin src="/assets/index-JN_O_VQt.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DviShRor.css">
</head>
<body>
<div id="app"></div>
+11
View File
@@ -19,6 +19,7 @@ export const emptyFormData = () => ({
device_name: "",
device_id: "",
tun_name: "",
outbound_interface: "",
password: "",
cert_mode: "skip",
fingerprint: "",
@@ -95,6 +96,9 @@ export const parseTomlToForm = (toml) => {
} else if (trimmed.includes("tun_name")) {
const match = trimmed.match(/tun_name\s*=\s*"([^"]*)"/);
if (match) data.tun_name = match[1];
} else if (trimmed.includes("outbound_interface")) {
const match = trimmed.match(/outbound_interface\s*=\s*"([^"]*)"/);
if (match) data.outbound_interface = match[1];
} else if (trimmed.includes("password =")) {
const match = trimmed.match(/password\s*=\s*"([^"]*)"/);
if (match) data.password = match[1];
@@ -231,6 +235,10 @@ export const formToToml = (formData) => {
toml += "\n# 虚拟网卡名称\n";
toml += `tun_name = "${formData.tun_name}"\n`;
}
if (formData.outbound_interface) {
toml += "\n# 绑定对外通信 Socket 的出口网卡名称(用于服务端通信、P2P 打洞及转发流量)\n";
toml += `outbound_interface = "${formData.outbound_interface}"\n`;
}
toml += "\n# --- 安全配置 ---\n";
if (formData.password) {
@@ -331,6 +339,9 @@ server = ["quic://1.2.3.4:29872"]
# 虚拟网卡名称
# tun_name = "vnt-tun"
# 绑定对外通信 Socket 的出口网卡名称(例如 Ethernet、Wi-Fi、eth0
# outbound_interface = "Ethernet"
# --- 安全配置 ---
# 加密密码 (可选)
+11 -1
View File
@@ -515,7 +515,7 @@ const sectionTitleClass = "text-md mb-4 flex items-center font-bold text-slate-9
</svg>
设备配置
</h4>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-4">
<div>
<label class="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">设备名称</label>
<input v-model="formData.device_name" type="text" placeholder="默认为主机名" class="input" />
@@ -528,6 +528,16 @@ const sectionTitleClass = "text-md mb-4 flex items-center font-bold text-slate-9
<label class="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">虚拟网卡名</label>
<input v-model="formData.tun_name" type="text" placeholder="默认为vnt-tun" class="input" />
</div>
<div>
<label class="mb-2 block text-sm font-medium text-slate-600 dark:text-slate-300">绑定出口网卡</label>
<input
v-model="formData.outbound_interface"
type="text"
placeholder="例如 Ethernet、Wi-Fi、eth0"
class="input"
/>
<p class="mt-1.5 text-xs leading-5 text-slate-400">服务端通信P2P 打洞及转发流量将使用此网卡</p>
</div>
</div>
</div>