mirror of
https://github.com/snltty/linker.git
synced 2026-04-02 19:50:55 +08:00
大量更新
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
v1.9.95
|
||||
2026-03-19 16:50:51
|
||||
2026-03-20 17:06:52
|
||||
1. 一些累计更新,一些BUG修复
|
||||
2. #92 松开打洞loading限制,允许选择中继节点
|
||||
3. #89 windows下利用任务计划进行进程守护,定时检查服务
|
||||
|
||||
@@ -431,6 +431,10 @@ namespace linker.app
|
||||
|
||||
public void SetMtu(int value)
|
||||
{
|
||||
}
|
||||
public void SetMssFix(int value = 0)
|
||||
{
|
||||
|
||||
}
|
||||
public void SetNat(out string error)
|
||||
{
|
||||
|
||||
@@ -293,14 +293,13 @@ namespace linker.libs
|
||||
//开始最近二次幂数 64
|
||||
uint startValue = FindNearestPowerOfTwo(originStart);
|
||||
//掩码26
|
||||
byte prefixLength = (byte)(32 - (int)Math.Log2(FindNearestPowerOfTwo(originEnd - startValue + 1 + 2)));
|
||||
uint prefixLengthValue = prefixLength < 1 ? 0 : 0xffffffff << (32 - prefixLength);
|
||||
byte prefixLength = (byte)(32 - (int)Math.Log2(FindNearestPowerOfTwo(originEnd - startValue + 1)));
|
||||
uint prefixLengthValue = ToPrefixValue(prefixLength);
|
||||
|
||||
//网络号 192.168.0.64
|
||||
uint networkValue = (startIpValue & prefixLengthValue) | startValue;
|
||||
|
||||
//广播号 192.168.0.95
|
||||
//uint broadcastValue = startIpValue | ~prefixLengthValue;
|
||||
uint broadcastValue = startIpValue | ~prefixLengthValue;
|
||||
|
||||
return (ToIP(networkValue), prefixLength);
|
||||
}
|
||||
|
||||
@@ -176,9 +176,14 @@ namespace linker.messenger.serializer.memorypack
|
||||
[MemoryPackInclude]
|
||||
string NetworkName => info.NetworkName;
|
||||
|
||||
[MemoryPackInclude]
|
||||
int Mtu => info.Mtu;
|
||||
[MemoryPackInclude]
|
||||
int MssFix => info.MssFix;
|
||||
|
||||
[MemoryPackConstructor]
|
||||
SerializableTuntapInfo(string machineId, TuntapStatus status, IPAddress ip, byte prefixLength, string name,
|
||||
List<TuntapLanInfo> lans, IPAddress wan, string setupError, string natError, string systemInfo, List<TuntapForwardInfo> forwards, TuntapSwitch Switch, string networkName)
|
||||
List<TuntapLanInfo> lans, IPAddress wan, string setupError, string natError, string systemInfo, List<TuntapForwardInfo> forwards, TuntapSwitch Switch, string networkName, int mtu, int mssfix)
|
||||
{
|
||||
var info = new TuntapInfo
|
||||
{
|
||||
@@ -194,7 +199,9 @@ namespace linker.messenger.serializer.memorypack
|
||||
Name = name,
|
||||
Status = status,
|
||||
Switch = Switch,
|
||||
NetworkName = networkName
|
||||
NetworkName = networkName,
|
||||
Mtu = mtu,
|
||||
MssFix = mssfix
|
||||
};
|
||||
this.info = info;
|
||||
}
|
||||
@@ -243,6 +250,12 @@ namespace linker.messenger.serializer.memorypack
|
||||
|
||||
if (count > 12)
|
||||
value.NetworkName = reader.ReadValue<string>();
|
||||
|
||||
if (count > 13)
|
||||
value.Mtu = reader.ReadValue<int>();
|
||||
|
||||
if (count > 14)
|
||||
value.MssFix = reader.ReadValue<int>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,8 +561,13 @@ namespace linker.messenger.serializer.memorypack
|
||||
[MemoryPackInclude, MemoryPackAllowSerialize]
|
||||
List<LeaseSubInfo> Subs => info.Subs;
|
||||
|
||||
[MemoryPackInclude, MemoryPackAllowSerialize]
|
||||
int Mtu => info.Mtu;
|
||||
[MemoryPackInclude, MemoryPackAllowSerialize]
|
||||
int MssFix => info.MssFix;
|
||||
|
||||
[MemoryPackConstructor]
|
||||
SerializableLeaseInfo(IPAddress ip, byte prefixLength, string name, string subname, List<LeaseSubInfo> subs)
|
||||
SerializableLeaseInfo(IPAddress ip, byte prefixLength, string name, string subname, List<LeaseSubInfo> subs, int mtu, int mssfix)
|
||||
{
|
||||
var info = new LeaseInfo
|
||||
{
|
||||
@@ -557,7 +575,9 @@ namespace linker.messenger.serializer.memorypack
|
||||
PrefixLength = prefixLength,
|
||||
Name = name,
|
||||
SubName = subname,
|
||||
Subs = subs
|
||||
Subs = subs,
|
||||
Mtu = mtu,
|
||||
MssFix = mssfix
|
||||
};
|
||||
this.info = info;
|
||||
}
|
||||
@@ -600,6 +620,12 @@ namespace linker.messenger.serializer.memorypack
|
||||
if (count > 4)
|
||||
value.Subs = reader.ReadValue<List<LeaseSubInfo>>();
|
||||
|
||||
if (count > 5)
|
||||
value.Mtu = reader.ReadValue<int>();
|
||||
|
||||
if (count > 6)
|
||||
value.MssFix = reader.ReadValue<int>();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -207,6 +207,7 @@ namespace linker.messenger.tunnel.client
|
||||
(MappingBehavior.EndpointIndependent, FilteringBehavior.AddressAndPortDependent) => 80,
|
||||
(MappingBehavior.AddressDependent, FilteringBehavior.EndpointIndependent) => 50,
|
||||
(MappingBehavior.AddressDependent, FilteringBehavior.AddressDependent) => 40,
|
||||
(MappingBehavior.AddressDependent, FilteringBehavior.AddressAndPortDependent) => 35,
|
||||
(MappingBehavior.AddressAndPortDependent, FilteringBehavior.EndpointIndependent) => 35,
|
||||
(MappingBehavior.AddressAndPortDependent, FilteringBehavior.AddressDependent) => 25,
|
||||
(MappingBehavior.AddressAndPortDependent, FilteringBehavior.AddressAndPortDependent) => 3,
|
||||
|
||||
@@ -15,12 +15,16 @@ namespace linker.messenger.tuntap
|
||||
/// </summary>
|
||||
public byte PrefixLength { get; set; } = 24;
|
||||
|
||||
public int Mtu { get; set; } = 1420;
|
||||
|
||||
public int MssFix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 局域网配置列表
|
||||
/// </summary>
|
||||
public List<TuntapLanInfo> Lans { get; set; } = new List<TuntapLanInfo>();
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = "linker";
|
||||
public string NetworkName { get; set; } = string.Empty;
|
||||
|
||||
public Guid Guid { get; set; } = Guid.Parse("771EF382-8718-5BC5-EBF0-A28B86142278");
|
||||
@@ -54,7 +58,10 @@ namespace linker.messenger.tuntap
|
||||
{
|
||||
public IPAddress IP { get; set; } = IPAddress.Any;
|
||||
public byte PrefixLength { get; set; } = 24;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string NetworkName { get; set; } = string.Empty;
|
||||
public int Mtu { get; set; } = 1420;
|
||||
public int MssFix { get; set; }
|
||||
}
|
||||
|
||||
public sealed partial class TuntapVeaLanIPAddress
|
||||
@@ -101,6 +108,9 @@ namespace linker.messenger.tuntap
|
||||
/// 前缀长度
|
||||
/// </summary>
|
||||
public byte PrefixLength { get; set; } = 24;
|
||||
public int Mtu { get; set; } = 1420;
|
||||
public int MssFix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 网卡名
|
||||
/// </summary>
|
||||
@@ -127,7 +137,7 @@ namespace linker.messenger.tuntap
|
||||
/// <summary>
|
||||
/// 端口转发列表
|
||||
/// </summary>
|
||||
|
||||
|
||||
public List<TuntapForwardInfo> Forwards { get; set; } = new List<TuntapForwardInfo>();
|
||||
/// <summary>
|
||||
/// 开关,多个bool集合
|
||||
@@ -473,7 +483,7 @@ namespace linker.messenger.tuntap
|
||||
/// <summary>
|
||||
/// 源代理
|
||||
/// </summary>
|
||||
SrcProxy = 1024,
|
||||
SrcProxy = 1024
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -161,8 +161,9 @@ namespace linker.messenger.tuntap.client
|
||||
Name = tuntapConfigTransfer.Name,
|
||||
Address = tuntapConfigTransfer.Info.IP,
|
||||
PrefixLength = tuntapConfigTransfer.Info.PrefixLength,
|
||||
Mtu = 1420,
|
||||
Mtu = tuntapConfigTransfer.Info.Mtu,
|
||||
Guid = tuntapConfigTransfer.Info.Guid,
|
||||
MssFix = tuntapConfigTransfer.Info.MssFix
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -11,8 +11,7 @@ namespace linker.messenger.tuntap.client
|
||||
{
|
||||
public TuntapConfigInfo Info => tuntapStore.Info;
|
||||
|
||||
private string name = string.Empty;
|
||||
public string Name => string.IsNullOrWhiteSpace(Info.Name) ? (string.IsNullOrWhiteSpace(name) ? "linker" : name) : Info.Name;
|
||||
public string Name => string.IsNullOrWhiteSpace(Info.Name) ? "linker" : Info.Name;
|
||||
|
||||
|
||||
private ulong configVersion = 0;
|
||||
@@ -63,8 +62,6 @@ namespace linker.messenger.tuntap.client
|
||||
{
|
||||
TimerHelper.Async(async () =>
|
||||
{
|
||||
string old = info.DiffValue;
|
||||
|
||||
Info.IP = info.IP ?? IPAddress.Any;
|
||||
Info.Lans = info.Lans;
|
||||
Info.PrefixLength = info.PrefixLength;
|
||||
@@ -72,16 +69,15 @@ namespace linker.messenger.tuntap.client
|
||||
Info.Switch = info.Switch;
|
||||
Info.Forwards = info.Forwards;
|
||||
Info.NetworkName = info.NetworkName;
|
||||
Info.Mtu = info.Mtu;
|
||||
Info.MssFix = info.MssFix;
|
||||
|
||||
tuntapStore.Confirm();
|
||||
|
||||
await LeaseIP().ConfigureAwait(false);
|
||||
SetGroupIP();
|
||||
|
||||
if (old != info.DiffValue)
|
||||
{
|
||||
Version.Increment();
|
||||
}
|
||||
Version.Increment();
|
||||
|
||||
OnUpdate();
|
||||
});
|
||||
@@ -127,10 +123,12 @@ namespace linker.messenger.tuntap.client
|
||||
/// <returns></returns>
|
||||
private async Task LeaseIP()
|
||||
{
|
||||
LeaseInfo leaseInfo = await leaseClientTreansfer.LeaseIp(Info.IP, Info.PrefixLength, Info.NetworkName).ConfigureAwait(false);
|
||||
LeaseInfo leaseInfo = await leaseClientTreansfer.LeaseIp(Info.IP, Info.PrefixLength, Info.NetworkName, Info.Name, Info.Mtu, Info.MssFix).ConfigureAwait(false);
|
||||
Info.IP = leaseInfo.IP;
|
||||
Info.PrefixLength = leaseInfo.PrefixLength;
|
||||
name = leaseInfo.Name;
|
||||
Info.Mtu = leaseInfo.Mtu;
|
||||
Info.MssFix = leaseInfo.MssFix;
|
||||
Info.Name = leaseInfo.Name;
|
||||
tuntapStore.Confirm();
|
||||
}
|
||||
|
||||
@@ -146,6 +144,9 @@ namespace linker.messenger.tuntap.client
|
||||
Info.IP = tuntapGroup2IPInfo.IP;
|
||||
Info.PrefixLength = tuntapGroup2IPInfo.PrefixLength;
|
||||
Info.NetworkName = tuntapGroup2IPInfo.NetworkName;
|
||||
Info.Mtu = tuntapGroup2IPInfo.Mtu;
|
||||
Info.MssFix = tuntapGroup2IPInfo.MssFix;
|
||||
Info.Name = tuntapGroup2IPInfo.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,7 +155,15 @@ namespace linker.messenger.tuntap.client
|
||||
/// </summary>
|
||||
private void SetGroupIP()
|
||||
{
|
||||
TuntapGroup2IPInfo tuntapGroup2IPInfo = new TuntapGroup2IPInfo { IP = Info.IP, PrefixLength = Info.PrefixLength, NetworkName = Info.NetworkName };
|
||||
TuntapGroup2IPInfo tuntapGroup2IPInfo = new TuntapGroup2IPInfo
|
||||
{
|
||||
IP = Info.IP,
|
||||
PrefixLength = Info.PrefixLength,
|
||||
NetworkName = Info.NetworkName,
|
||||
Mtu = Info.Mtu,
|
||||
MssFix = Info.MssFix,
|
||||
Name = Info.Name,
|
||||
};
|
||||
Info.Group2IP[signInClientStore.Group.Id] = tuntapGroup2IPInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,10 @@ namespace linker.messenger.tuntap.client
|
||||
NatError = tuntapTransfer.NatError,
|
||||
SystemInfo = systemInformation.Get(),
|
||||
Forwards = tuntapConfigTransfer.Info.Forwards,
|
||||
Switch = tuntapConfigTransfer.Info.Switch
|
||||
Switch = tuntapConfigTransfer.Info.Switch,
|
||||
NetworkName = tuntapConfigTransfer.Info.NetworkName,
|
||||
Mtu = tuntapConfigTransfer.Info.Mtu,
|
||||
MssFix = tuntapConfigTransfer.Info.MssFix,
|
||||
});
|
||||
}
|
||||
public void AddData(Memory<byte> data)
|
||||
@@ -134,7 +137,7 @@ namespace linker.messenger.tuntap.client
|
||||
{
|
||||
if (DataVersion.Eq(version, out ulong _version) == false)
|
||||
{
|
||||
if(await CheckOffline() || await CheckOnline())
|
||||
if (await CheckOffline() || await CheckOnline())
|
||||
{
|
||||
ProcData();
|
||||
}
|
||||
|
||||
@@ -48,12 +48,12 @@ namespace linker.messenger.tuntap.lease
|
||||
info = serializer.Deserialize<LeaseInfo>(resp.Data.Span);
|
||||
}
|
||||
|
||||
if(info.IP.Equals(IPAddress.Any) == false)
|
||||
if (info.IP.Equals(IPAddress.Any) == false)
|
||||
{
|
||||
leaseClientStore.Set(signInClientStore.Group.Id, info);
|
||||
leaseClientStore.Confirm();
|
||||
}
|
||||
|
||||
|
||||
return info;
|
||||
}
|
||||
public async Task LeaseChange()
|
||||
@@ -65,13 +65,13 @@ namespace linker.messenger.tuntap.lease
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<LeaseInfo> LeaseIp(IPAddress ip, byte prefixLength,string networkName)
|
||||
public async Task<LeaseInfo> LeaseIp(IPAddress ip, byte prefixLength, string networkName, string name, int mtu, int mssfix)
|
||||
{
|
||||
MessageResponeInfo resp = await messengerSender.SendReply(new MessageRequestWrap
|
||||
{
|
||||
Connection = signInClientState.Connection,
|
||||
MessengerId = (ushort)TuntapMessengerIds.LeaseIP,
|
||||
Payload = serializer.Serialize(new LeaseInfo { IP = ip, PrefixLength = prefixLength, SubName= networkName })
|
||||
Payload = serializer.Serialize(new LeaseInfo { IP = ip, PrefixLength = prefixLength, SubName = networkName, Mtu = mtu, MssFix = mssfix, Name = name })
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
if (resp.Code == MessageResponeCodes.OK)
|
||||
@@ -82,7 +82,7 @@ namespace linker.messenger.tuntap.lease
|
||||
return newip;
|
||||
}
|
||||
}
|
||||
return new LeaseInfo { IP = ip, PrefixLength = prefixLength };
|
||||
return new LeaseInfo { IP = ip, PrefixLength = prefixLength, Mtu = mtu, MssFix = mssfix, Name = name };
|
||||
}
|
||||
|
||||
private void LeaseExpTask()
|
||||
|
||||
@@ -273,11 +273,11 @@ namespace linker.messenger.tuntap.lease
|
||||
/// <summary>
|
||||
/// 前缀,掩码长度
|
||||
/// </summary>
|
||||
public byte PrefixLength { get; set; } = 32;
|
||||
public byte PrefixLength { get; set; } = 24;
|
||||
/// <summary>
|
||||
/// 网卡名
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = "linker";
|
||||
|
||||
/// <summary>
|
||||
/// 仅传输,不需要任何设置
|
||||
@@ -285,11 +285,15 @@ namespace linker.messenger.tuntap.lease
|
||||
public string SubName { get; set; } = string.Empty;
|
||||
|
||||
public List<LeaseSubInfo> Subs { get; set; } = [];
|
||||
|
||||
public int Mtu { get; set; } = 1420;
|
||||
|
||||
public int MssFix { get; set; }
|
||||
}
|
||||
public sealed partial class LeaseSubInfo
|
||||
{
|
||||
public LeaseSubInfo() { }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 网络号
|
||||
/// </summary>
|
||||
|
||||
@@ -134,6 +134,7 @@ namespace linker.tun
|
||||
return false;
|
||||
}
|
||||
linkerTunDevice.SetMtu(info.Mtu);
|
||||
linkerTunDevice.SetMssFix(info.MssFix);
|
||||
Read();
|
||||
lanSrcProxy.Setup(address, prefixLength, this, ref natError);
|
||||
return true;
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace linker.tun.device
|
||||
/// </summary>
|
||||
public void Refresh();
|
||||
|
||||
public void SetMssFix(int value = 0);
|
||||
/// <summary>
|
||||
/// 设置MTU
|
||||
/// </summary>
|
||||
@@ -122,6 +123,10 @@ namespace linker.tun.device
|
||||
/// MTU
|
||||
/// </summary>
|
||||
public int Mtu { get; set; } = 1420;
|
||||
/// <summary>
|
||||
/// MSS 钳制
|
||||
/// </summary>
|
||||
public int MssFix { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -141,6 +141,26 @@ namespace linker.tun.device
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMssFix(int value = 0)
|
||||
{
|
||||
if (value >= 0 && value < 1500)
|
||||
{
|
||||
string _value = value == 0 ? "--clamp-mss-to-pmtu" : $"--set-mss {value}";
|
||||
|
||||
CommandHelper.Linux(string.Empty, new string[] {
|
||||
$"iptables -t mangle -A POSTROUTING -o {Name} -p tcp --tcp-flags SYN,RST SYN -j TCPMSS {_value}",
|
||||
$"iptables -t mangle -A FORWARD -o {Name} -p tcp --tcp-flags SYN,RST SYN -j TCPMSS {_value}",
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
CommandHelper.Linux(string.Empty, new string[] {
|
||||
@$"iptables-save | grep -v -E -- ""-o {Name}\s*.*\s* -j TCPMSS"" | iptables-restore",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void SetMtu(int value)
|
||||
{
|
||||
CommandHelper.Linux(string.Empty, new string[] { $"ip link set dev {Name} mtu {value}" });
|
||||
@@ -190,31 +210,9 @@ namespace linker.tun.device
|
||||
if (address == null || address.Equals(IPAddress.Any)) return;
|
||||
try
|
||||
{
|
||||
string support = CommandHelper.Linux(string.Empty, new string[] { "iptables -m state -h" }, out string supportError);
|
||||
bool isSupport = string.IsNullOrWhiteSpace(supportError) && support.Contains("No such file or directory") == false;
|
||||
|
||||
CommandHelper.Linux(string.Empty, new string[] {
|
||||
$"iptables -D FORWARD -i {interfaceLinux} -o {Name} -j ACCEPT",
|
||||
$"iptables -D FORWARD -i {Name} -j ACCEPT",
|
||||
$"iptables -t nat -D POSTROUTING -o {Name} -j MASQUERADE",
|
||||
|
||||
isSupport ? $"iptables -D FORWARD -i {Name} -o {interfaceLinux} -m state --state ESTABLISHED,RELATED -j ACCEPT"
|
||||
: $"iptables -D FORWARD -i {Name} -o {interfaceLinux} -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT",
|
||||
|
||||
isSupport ? $"iptables -D FORWARD -o {Name} -m state --state ESTABLISHED,RELATED -j ACCEPT"
|
||||
: $"iptables -D FORWARD -o {Name} -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT"
|
||||
@$"iptables-save | grep -v -E -- ""-[oi] {Name}\s*.*\s* -j (ACCEPT|MASQUERADE|DROP|REJECT)"" | iptables-restore",
|
||||
});
|
||||
|
||||
|
||||
IPAddress network = NetworkHelper.ToNetworkIP(address, NetworkHelper.ToPrefixValue(prefixLength));
|
||||
string iptableLineNumbers = CommandHelper.Linux(string.Empty, new string[] { $"iptables -t nat -L --line-numbers | grep {network}/{prefixLength} | cut -d' ' -f1" });
|
||||
if (string.IsNullOrWhiteSpace(iptableLineNumbers) == false)
|
||||
{
|
||||
string[] commands = iptableLineNumbers.Split(Environment.NewLine)
|
||||
.Where(c => string.IsNullOrWhiteSpace(c) == false)
|
||||
.Select(c => $"iptables -t nat -D POSTROUTING {c}").ToArray();
|
||||
CommandHelper.Linux(string.Empty, commands);
|
||||
}
|
||||
RestartFirewall();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace linker.tun.device
|
||||
{
|
||||
// Configure interface - use gateway as destination
|
||||
$"sudo ifconfig {interfaceMac} {address} {gatewayAddr} netmask 255.255.255.255 up",
|
||||
$"sudo ifconfig {interfaceMac} mtu 1500",
|
||||
$"sudo ifconfig {interfaceMac} mtu 1420",
|
||||
|
||||
// Enable IP forwarding
|
||||
"sudo sysctl -w net.inet.ip.forwarding=1",
|
||||
@@ -225,6 +225,10 @@ namespace linker.tun.device
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMssFix(int value = 0)
|
||||
{
|
||||
|
||||
}
|
||||
public void SetMtu(int value)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(interfaceMac))
|
||||
|
||||
@@ -184,6 +184,10 @@ namespace linker.tun.device
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMssFix(int value = 0)
|
||||
{
|
||||
|
||||
}
|
||||
public void SetMtu(int value)
|
||||
{
|
||||
CommandHelper.Windows(string.Empty, new string[] {
|
||||
|
||||
@@ -9,16 +9,26 @@
|
||||
<el-input v-trim v-model="state.ruleForm.Name" class="w-14" />
|
||||
<span class="mgl-1">留空则使用【本组网络】的设置</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="MTU" prop="MTU">
|
||||
<el-input-number v-trim v-model="state.ruleForm.Mtu" :min="0" :max="1500" class="w-14" />
|
||||
<span class="mgl-1">一般来说不用动,不要超过1440</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="MSS钳制" prop="MssFix">
|
||||
<el-select v-model="state.ruleForm.MssFix" class="w-14">
|
||||
<el-option :value="item.value" :label="item.label" v-for="(item,index) in state.msss"></el-option>
|
||||
</el-select>
|
||||
<span class="mgl-1">TCP MSS Clamping,仅linux</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="网络名" prop="NetworkName">
|
||||
<el-select v-model="state.ruleForm.NetworkName" class="w-14">
|
||||
<el-option :value="item.value" :label="item.label" v-for="(item,index) in state.networks"></el-option>
|
||||
</el-select>
|
||||
<span class="mgl-1">选择子网或留空或选择主网</span>
|
||||
<span class="mgl-1">需要变长掩码子网隔离就选子网、否则留空或选择主网</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="网卡IP" prop="IP" class="mgb-0">
|
||||
<el-form-item label="网卡IP" prop="IP">
|
||||
<el-input v-trim v-model="state.ruleForm.IP" class="w-14" />
|
||||
<span>/</span>
|
||||
<el-input v-trim @change="handlePrefixLengthChange" v-model="state.ruleForm.PrefixLength" class="w-4" />
|
||||
<span> / </span>
|
||||
<el-input v-trim @change="handlePrefixLengthChange" v-model="state.ruleForm.PrefixLength" class="w-4" />
|
||||
</el-form-item>
|
||||
<el-form-item label="" class="mgb-0">
|
||||
<el-checkbox class="mgr-1" v-model="state.ruleForm.ShowDelay" label="显示延迟" size="large" />
|
||||
@@ -66,6 +76,8 @@ export default {
|
||||
Forwards: tuntap.value.current.Forwards,
|
||||
Name: tuntap.value.current.Name,
|
||||
NetworkName: tuntap.value.current.NetworkName,
|
||||
Mtu: tuntap.value.current.Mtu,
|
||||
MssFix: tuntap.value.current.MssFix,
|
||||
Guid: '',
|
||||
},
|
||||
rules: {
|
||||
@@ -78,7 +90,22 @@ export default {
|
||||
},
|
||||
}
|
||||
},
|
||||
networks:[]
|
||||
networks:[],
|
||||
msss:[
|
||||
{value:-1,label:'不启用'},
|
||||
{value:0,label:'自动计算'},
|
||||
{value:1400,label:'启用1400'},
|
||||
{value:1380,label:'启用1380'},
|
||||
{value:1360,label:'启用1360'},
|
||||
{value:1340,label:'启用1340'},
|
||||
{value:1320,label:'启用1320'},
|
||||
{value:1300,label:'启用1300'},
|
||||
{value:1280,label:'启用1280'},
|
||||
{value:1260,label:'启用1260'},
|
||||
{value:1240,label:'启用1240'},
|
||||
{value:1220,label:'启用1220'},
|
||||
{value:1200,label:'启用1200'}
|
||||
]
|
||||
});
|
||||
const handlePrefixLengthChange = () => {
|
||||
var value = +state.ruleForm.PrefixLength;
|
||||
@@ -111,6 +138,9 @@ export default {
|
||||
json.FakeAck = state.ruleForm.FakeAck;
|
||||
json.SrcProxy = state.ruleForm.SrcProxy;
|
||||
json.Name = state.ruleForm.Name;
|
||||
json.NetworkName = state.ruleForm.NetworkName;
|
||||
json.Mtu = state.ruleForm.Mtu;
|
||||
json.MssFix = state.ruleForm.MssFix;
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,29 @@
|
||||
<template>
|
||||
<el-dialog v-model="state.show" :close-on-click-modal="false" append-to=".app-wrap" title="配置本组的网络" top="1vh" width="500">
|
||||
<div>
|
||||
<el-form ref="ruleFormRef" :model="state.ruleForm" :rules="state.rules" label-width="60">
|
||||
<el-form ref="ruleFormRef" :model="state.ruleForm" :rules="state.rules" label-width="70">
|
||||
<el-form-item label="网卡名" prop="Name">
|
||||
<el-row class="w-100">
|
||||
<el-col :span="10">
|
||||
<el-input v-trim v-model="state.ruleForm.Name"/>
|
||||
<el-input v-trim v-model="state.ruleForm.Name" class="w-100"/>
|
||||
</el-col>
|
||||
<el-col :span="14"></el-col>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
<el-form-item label="MTU" prop="MTU">
|
||||
<el-row class="w-100">
|
||||
<el-col :span="10">
|
||||
<el-input-number v-trim v-model="state.ruleForm.Mtu" :min="0" :max="1500" class="w-100" />
|
||||
</el-col>
|
||||
<el-col :span="14"></el-col>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
<el-form-item label="MSS钳制" prop="MssFix">
|
||||
<el-row class="w-100">
|
||||
<el-col :span="10">
|
||||
<el-select v-model="state.ruleForm.MssFix" class="w-100">
|
||||
<el-option :value="item.value" :label="item.label" v-for="(item,index) in state.msss"></el-option>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="14"></el-col>
|
||||
</el-row>
|
||||
@@ -40,21 +58,21 @@
|
||||
<el-form-item label="子网" prop="Subs">
|
||||
<div class="subs">
|
||||
<template v-for="(item,index) in state.ruleForm.Subs">
|
||||
<el-row class="w-100">
|
||||
<el-row class="w-100 sub-item">
|
||||
<el-col :span="4" class="pdr-10">
|
||||
<el-input v-trim v-model="item.Name"/>
|
||||
</el-col>
|
||||
<el-col :span="7">
|
||||
<el-input v-trim v-model="item.IP"/>
|
||||
<el-input v-trim v-model="item.IP" disabled/>
|
||||
</el-col>
|
||||
<el-col :span="1" class="t-c">/</el-col>
|
||||
<el-col :span="3">
|
||||
<el-input v-trim v-model="item.PrefixLength"/>
|
||||
<el-input v-trim v-model="item.PrefixLength" disabled/>
|
||||
</el-col>
|
||||
<el-col :span="9" class="t-r">
|
||||
<el-button type="danger"><el-icon><Delete></Delete></el-icon></el-button>
|
||||
<el-button type="info"><el-icon><Edit></Edit></el-icon></el-button>
|
||||
<el-button type="primary"><el-icon><Plus></Plus></el-icon></el-button>
|
||||
<el-button type="danger" @click="handleDelSub(index)"><el-icon><Delete></Delete></el-icon></el-button>
|
||||
<el-button type="info" @click="handleEditSub(index)"><el-icon><Edit></Edit></el-icon></el-button>
|
||||
<el-button type="primary" @click="handleAddSub(index)"><el-icon><Plus></Plus></el-icon></el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
@@ -75,7 +93,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import {getNetwork,addNetwork,calcNetwork } from '@/apis/tuntap';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { onMounted, reactive, ref, watch } from 'vue';
|
||||
import { Delete, Plus,Refresh,Edit } from '@element-plus/icons-vue'
|
||||
export default {
|
||||
@@ -91,7 +109,9 @@ export default {
|
||||
Name:'',
|
||||
IP:'0.0.0.0',
|
||||
PrefixLength:24,
|
||||
Subs:[]
|
||||
Subs:[],
|
||||
Mtu:1420,
|
||||
MssFix:0,
|
||||
},
|
||||
rules: {
|
||||
Name: {
|
||||
@@ -103,7 +123,22 @@ export default {
|
||||
},
|
||||
}
|
||||
},
|
||||
values:{}
|
||||
values:{},
|
||||
msss:[
|
||||
{value:-1,label:'不启用'},
|
||||
{value:0,label:'自动计算'},
|
||||
{value:1400,label:'启用1400'},
|
||||
{value:1380,label:'启用1380'},
|
||||
{value:1360,label:'启用1360'},
|
||||
{value:1340,label:'启用1340'},
|
||||
{value:1320,label:'启用1320'},
|
||||
{value:1300,label:'启用1300'},
|
||||
{value:1280,label:'启用1280'},
|
||||
{value:1260,label:'启用1260'},
|
||||
{value:1240,label:'启用1240'},
|
||||
{value:1220,label:'启用1220'},
|
||||
{value:1200,label:'启用1200'}
|
||||
]
|
||||
});
|
||||
watch(() => state.show, (val) => {
|
||||
if (!val) {
|
||||
@@ -127,6 +162,8 @@ export default {
|
||||
res.Subs = [{Name:'子网1',IP:'0.0.0.0',PrefixLength:24}];
|
||||
}
|
||||
state.ruleForm.Subs = res.Subs;
|
||||
state.ruleForm.Mtu = res.Mtu;
|
||||
state.ruleForm.MssFix = res.MssFix;
|
||||
_calcNetwork();
|
||||
});
|
||||
}
|
||||
@@ -157,12 +194,31 @@ export default {
|
||||
});
|
||||
}
|
||||
|
||||
const handleAddSub = (index)=>{
|
||||
state.ruleForm.Subs.splice(index+1,0,{Name:'子网'+(state.ruleForm.Subs.length+1),IP:'0.0.0.0',PrefixLength:24});
|
||||
}
|
||||
const handleDelSub = (index)=>{
|
||||
if(state.ruleForm.Subs.length <= 1){
|
||||
state.ruleForm.Subs = [{Name:'子网1',IP:'0.0.0.0',PrefixLength:24}];
|
||||
return;
|
||||
}
|
||||
ElMessageBox.confirm('确定要删除吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
state.ruleForm.Subs.splice(index,1);
|
||||
}).catch(() => {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
onMounted(()=>{
|
||||
_getNetwork();
|
||||
})
|
||||
|
||||
return {
|
||||
state,ruleFormRef, handleSave,handlePrefixLengthChange,handleClear
|
||||
state,ruleFormRef, handleSave,handlePrefixLengthChange,handleClear,handleDelSub,handleAddSub
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,4 +228,7 @@ export default {
|
||||
.el-button+.el-button{
|
||||
margin-left: .4rem;
|
||||
}
|
||||
.sub-item{
|
||||
margin-bottom:.6rem;
|
||||
}
|
||||
</style>
|
||||
@@ -10,7 +10,7 @@ export const provideTuntap = () => {
|
||||
list: null,
|
||||
hashcode: 0,
|
||||
|
||||
showLease: false,
|
||||
showLease: true,
|
||||
|
||||
device: {id:'',name:''},
|
||||
showRoutes:false,
|
||||
|
||||
Reference in New Issue
Block a user