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
@@ -18,6 +18,7 @@ public class VntConfig {
private final String deviceId;
private final String deviceName;
private final String tunName;
private final String outboundInterface;
private final String ip;
private final String certMode;
private final boolean noPunch;
@@ -39,6 +40,7 @@ public class VntConfig {
this.deviceId = builder.deviceId;
this.deviceName = builder.deviceName;
this.tunName = builder.tunName;
this.outboundInterface = builder.outboundInterface;
this.ip = builder.ip;
this.certMode = builder.certMode;
this.noPunch = builder.noPunch;
@@ -73,6 +75,7 @@ public class VntConfig {
if (deviceId != null) json.put("device_id", deviceId);
if (deviceName != null) json.put("device_name", deviceName);
if (tunName != null) json.put("tun_name", tunName);
if (outboundInterface != null) json.put("outbound_interface", outboundInterface);
if (ip != null) json.put("ip", ip);
if (certMode != null) json.put("cert_mode", certMode);
if (mtu != null) json.put("mtu", mtu);
@@ -124,6 +127,7 @@ public class VntConfig {
private String deviceId;
private String deviceName;
private String tunName;
private String outboundInterface;
private String ip;
private String certMode;
private boolean noPunch = false;
@@ -188,6 +192,14 @@ public class VntConfig {
return this;
}
/**
* 绑定对外通信Socket的出口网卡名称(可选)
*/
public Builder setOutboundInterface(String outboundInterface) {
this.outboundInterface = outboundInterface;
return this;
}
/**
* 设置固定IP(可选)
*/
+3
View File
@@ -895,6 +895,8 @@ fn parse_config_from_json(json_str: &str) -> anyhow::Result<Config> {
#[serde(default)]
tun_name: Option<String>,
#[serde(default)]
outbound_interface: Option<String>,
#[serde(default)]
ip: Option<Ipv4Addr>,
#[serde(default)]
password: Option<String>,
@@ -994,6 +996,7 @@ fn parse_config_from_json(json_str: &str) -> anyhow::Result<Config> {
device_id,
device_name,
tun_name: cfg.tun_name,
outbound_interface: cfg.outbound_interface,
password: cfg.password,
cert_mode,
input: cfg.input,