Refactor id and security

This commit is contained in:
DHR60 2026-01-21 11:58:29 +08:00
parent 2d450357d1
commit ee7d3c60b6
20 changed files with 302 additions and 222 deletions

View file

@ -292,24 +292,28 @@ public static class ConfigHandler
{ {
profileItem.ConfigType = EConfigType.VMess; profileItem.ConfigType = EConfigType.VMess;
var protocolExtra = profileItem.GetProtocolExtra();
profileItem.Address = profileItem.Address.TrimEx(); profileItem.Address = profileItem.Address.TrimEx();
profileItem.Id = profileItem.Id.TrimEx(); profileItem.Password = profileItem.Password.TrimEx();
profileItem.Security = profileItem.Security.TrimEx(); protocolExtra.VmessSecurity = protocolExtra.VmessSecurity?.TrimEx();
profileItem.Network = profileItem.Network.TrimEx(); profileItem.Network = profileItem.Network.TrimEx();
profileItem.HeaderType = profileItem.HeaderType.TrimEx(); profileItem.HeaderType = profileItem.HeaderType.TrimEx();
profileItem.RequestHost = profileItem.RequestHost.TrimEx(); profileItem.RequestHost = profileItem.RequestHost.TrimEx();
profileItem.Path = profileItem.Path.TrimEx(); profileItem.Path = profileItem.Path.TrimEx();
profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx(); profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx();
if (!Global.VmessSecurities.Contains(profileItem.Security)) if (!Global.VmessSecurities.Contains(protocolExtra.VmessSecurity))
{ {
return -1; return -1;
} }
if (profileItem.Id.IsNullOrEmpty()) if (profileItem.Password.IsNullOrEmpty())
{ {
return -1; return -1;
} }
profileItem.SetProtocolExtra(protocolExtra);
await AddServerCommon(config, profileItem, toFile); await AddServerCommon(config, profileItem, toFile);
return 0; return 0;
@ -607,19 +611,23 @@ public static class ConfigHandler
{ {
profileItem.ConfigType = EConfigType.Shadowsocks; profileItem.ConfigType = EConfigType.Shadowsocks;
profileItem.Address = profileItem.Address.TrimEx(); var protocolExtra = profileItem.GetProtocolExtra();
profileItem.Id = profileItem.Id.TrimEx();
profileItem.Security = profileItem.Security.TrimEx();
if (!AppManager.Instance.GetShadowsocksSecurities(profileItem).Contains(profileItem.Security)) profileItem.Address = profileItem.Address.TrimEx();
profileItem.Password = profileItem.Password.TrimEx();
protocolExtra.SsMethod = protocolExtra.SsMethod.TrimEx();
if (!AppManager.Instance.GetShadowsocksSecurities(profileItem).Contains(protocolExtra.SsMethod))
{ {
return -1; return -1;
} }
if (profileItem.Id.IsNullOrEmpty()) if (profileItem.Password.IsNullOrEmpty())
{ {
return -1; return -1;
} }
profileItem.SetProtocolExtra(protocolExtra);
await AddServerCommon(config, profileItem, toFile); await AddServerCommon(config, profileItem, toFile);
return 0; return 0;
@ -676,12 +684,12 @@ public static class ConfigHandler
profileItem.ConfigType = EConfigType.Trojan; profileItem.ConfigType = EConfigType.Trojan;
profileItem.Address = profileItem.Address.TrimEx(); profileItem.Address = profileItem.Address.TrimEx();
profileItem.Id = profileItem.Id.TrimEx(); profileItem.Password = profileItem.Password.TrimEx();
if (profileItem.StreamSecurity.IsNullOrEmpty()) if (profileItem.StreamSecurity.IsNullOrEmpty())
{ {
profileItem.StreamSecurity = Global.StreamSecurity; profileItem.StreamSecurity = Global.StreamSecurity;
} }
if (profileItem.Id.IsNullOrEmpty()) if (profileItem.Password.IsNullOrEmpty())
{ {
return -1; return -1;
} }
@ -706,7 +714,7 @@ public static class ConfigHandler
//profileItem.CoreType = ECoreType.sing_box; //profileItem.CoreType = ECoreType.sing_box;
profileItem.Address = profileItem.Address.TrimEx(); profileItem.Address = profileItem.Address.TrimEx();
profileItem.Id = profileItem.Id.TrimEx(); profileItem.Password = profileItem.Password.TrimEx();
profileItem.Path = profileItem.Path.TrimEx(); profileItem.Path = profileItem.Path.TrimEx();
profileItem.Network = string.Empty; profileItem.Network = string.Empty;
@ -714,7 +722,7 @@ public static class ConfigHandler
{ {
profileItem.StreamSecurity = Global.StreamSecurity; profileItem.StreamSecurity = Global.StreamSecurity;
} }
if (profileItem.Id.IsNullOrEmpty()) if (profileItem.Password.IsNullOrEmpty())
{ {
return -1; return -1;
} }
@ -738,9 +746,11 @@ public static class ConfigHandler
profileItem.ConfigType = EConfigType.TUIC; profileItem.ConfigType = EConfigType.TUIC;
profileItem.CoreType = ECoreType.sing_box; profileItem.CoreType = ECoreType.sing_box;
var protocolExtra = profileItem.GetProtocolExtra();
profileItem.Address = profileItem.Address.TrimEx(); profileItem.Address = profileItem.Address.TrimEx();
profileItem.Id = profileItem.Id.TrimEx(); profileItem.Password = profileItem.Password.TrimEx();
profileItem.Security = profileItem.Security.TrimEx(); protocolExtra.Username = protocolExtra.Username?.TrimEx();
profileItem.Network = string.Empty; profileItem.Network = string.Empty;
if (!Global.TuicCongestionControls.Contains(profileItem.HeaderType)) if (!Global.TuicCongestionControls.Contains(profileItem.HeaderType))
@ -756,7 +766,7 @@ public static class ConfigHandler
{ {
profileItem.Alpn = "h3"; profileItem.Alpn = "h3";
} }
if (profileItem.Id.IsNullOrEmpty()) if (profileItem.Password.IsNullOrEmpty())
{ {
return -1; return -1;
} }
@ -778,22 +788,26 @@ public static class ConfigHandler
{ {
profileItem.ConfigType = EConfigType.WireGuard; profileItem.ConfigType = EConfigType.WireGuard;
var protocolExtra = profileItem.GetProtocolExtra();
profileItem.Address = profileItem.Address.TrimEx(); profileItem.Address = profileItem.Address.TrimEx();
profileItem.Id = profileItem.Id.TrimEx(); profileItem.Password = profileItem.Password.TrimEx();
profileItem.PublicKey = profileItem.PublicKey.TrimEx(); protocolExtra.WgPublicKey = protocolExtra.WgPublicKey?.TrimEx();
profileItem.Path = profileItem.Path.TrimEx(); protocolExtra.WgPresharedKey = protocolExtra.WgPresharedKey?.TrimEx();
profileItem.RequestHost = profileItem.RequestHost.TrimEx(); protocolExtra.WgInterfaceAddress = protocolExtra.WgInterfaceAddress?.TrimEx();
profileItem.Network = string.Empty; protocolExtra.WgReserved = protocolExtra.WgReserved?.TrimEx();
if (profileItem.ShortId.IsNullOrEmpty()) if (protocolExtra.WgMtu <= 0)
{ {
profileItem.ShortId = Global.TunMtus.First().ToString(); protocolExtra.WgMtu = Global.TunMtus.First();
} }
if (profileItem.Id.IsNullOrEmpty()) if (profileItem.Password.IsNullOrEmpty())
{ {
return -1; return -1;
} }
profileItem.SetProtocolExtra(protocolExtra);
await AddServerCommon(config, profileItem, toFile); await AddServerCommon(config, profileItem, toFile);
return 0; return 0;
@ -813,14 +827,13 @@ public static class ConfigHandler
profileItem.CoreType = ECoreType.sing_box; profileItem.CoreType = ECoreType.sing_box;
profileItem.Address = profileItem.Address.TrimEx(); profileItem.Address = profileItem.Address.TrimEx();
profileItem.Id = profileItem.Id.TrimEx(); profileItem.Password = profileItem.Password.TrimEx();
profileItem.Security = profileItem.Security.TrimEx();
profileItem.Network = string.Empty; profileItem.Network = string.Empty;
if (profileItem.StreamSecurity.IsNullOrEmpty()) if (profileItem.StreamSecurity.IsNullOrEmpty())
{ {
profileItem.StreamSecurity = Global.StreamSecurity; profileItem.StreamSecurity = Global.StreamSecurity;
} }
if (profileItem.Id.IsNullOrEmpty()) if (profileItem.Password.IsNullOrEmpty())
{ {
return -1; return -1;
} }
@ -858,7 +871,7 @@ public static class ConfigHandler
Remarks = t.Remarks, Remarks = t.Remarks,
Address = t.Address, Address = t.Address,
Port = t.Port, Port = t.Port,
Security = t.Security, //Security = t.Security,
Network = t.Network, Network = t.Network,
StreamSecurity = t.StreamSecurity, StreamSecurity = t.StreamSecurity,
Delay = t33?.Delay ?? 0, Delay = t33?.Delay ?? 0,
@ -956,28 +969,28 @@ public static class ConfigHandler
{ {
profileItem.ConfigType = EConfigType.VLESS; profileItem.ConfigType = EConfigType.VLESS;
var protocolExtra = profileItem.GetProtocolExtra();
profileItem.Address = profileItem.Address.TrimEx(); profileItem.Address = profileItem.Address.TrimEx();
profileItem.Id = profileItem.Id.TrimEx(); profileItem.Password = profileItem.Password.TrimEx();
profileItem.Security = profileItem.Security.TrimEx();
profileItem.Network = profileItem.Network.TrimEx(); profileItem.Network = profileItem.Network.TrimEx();
profileItem.HeaderType = profileItem.HeaderType.TrimEx(); profileItem.HeaderType = profileItem.HeaderType.TrimEx();
profileItem.RequestHost = profileItem.RequestHost.TrimEx(); profileItem.RequestHost = profileItem.RequestHost.TrimEx();
profileItem.Path = profileItem.Path.TrimEx(); profileItem.Path = profileItem.Path.TrimEx();
profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx(); profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx();
protocolExtra.VlessEncryption = protocolExtra.VlessEncryption?.TrimEx();
var protocolExtra = profileItem.GetProtocolExtra();
if (!Global.Flows.Contains(protocolExtra.Flow ?? string.Empty)) if (!Global.Flows.Contains(protocolExtra.Flow ?? string.Empty))
{ {
protocolExtra.Flow = Global.Flows.First(); protocolExtra.Flow = Global.Flows.First();
} }
if (profileItem.Id.IsNullOrEmpty()) if (profileItem.Password.IsNullOrEmpty())
{ {
return -1; return -1;
} }
if (profileItem.Security.IsNullOrEmpty()) if (protocolExtra.VlessEncryption.IsNullOrEmpty())
{ {
profileItem.Security = Global.None; protocolExtra.VlessEncryption = Global.None;
} }
profileItem.SetProtocolExtra(protocolExtra); profileItem.SetProtocolExtra(protocolExtra);
@ -1099,19 +1112,22 @@ public static class ConfigHandler
return false; return false;
} }
var protocolExtra = o.GetProtocolExtra(); var oProtocolExtra = o.GetProtocolExtra();
var nProtocolExtra = n.GetProtocolExtra();
return o.ConfigType == n.ConfigType return o.ConfigType == n.ConfigType
&& AreEqual(o.Address, n.Address) && AreEqual(o.Address, n.Address)
&& o.Port == n.Port && o.Port == n.Port
&& AreEqual(o.Id, n.Id) && AreEqual(o.Password, n.Password)
&& AreEqual(o.Security, n.Security) && AreEqual(oProtocolExtra.VlessEncryption, nProtocolExtra.VlessEncryption)
&& AreEqual(oProtocolExtra.SsMethod, nProtocolExtra.SsMethod)
&& AreEqual(oProtocolExtra.VmessSecurity, nProtocolExtra.VmessSecurity)
&& AreEqual(o.Network, n.Network) && AreEqual(o.Network, n.Network)
&& AreEqual(o.HeaderType, n.HeaderType) && AreEqual(o.HeaderType, n.HeaderType)
&& AreEqual(o.RequestHost, n.RequestHost) && AreEqual(o.RequestHost, n.RequestHost)
&& AreEqual(o.Path, n.Path) && AreEqual(o.Path, n.Path)
&& (o.ConfigType == EConfigType.Trojan || o.StreamSecurity == n.StreamSecurity) && (o.ConfigType == EConfigType.Trojan || o.StreamSecurity == n.StreamSecurity)
&& AreEqual(protocolExtra.Flow, protocolExtra.Flow) && AreEqual(oProtocolExtra.Flow, nProtocolExtra.Flow)
&& AreEqual(o.Sni, n.Sni) && AreEqual(o.Sni, n.Sni)
&& AreEqual(o.Alpn, n.Alpn) && AreEqual(o.Alpn, n.Alpn)
&& AreEqual(o.Fingerprint, n.Fingerprint) && AreEqual(o.Fingerprint, n.Fingerprint)

View file

@ -20,7 +20,7 @@ public class AnytlsFmt : BaseFmt
Port = parsedUrl.Port, Port = parsedUrl.Port,
}; };
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo); var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
item.Id = rawUserInfo; item.Password = rawUserInfo;
var query = Utils.ParseQueryString(parsedUrl.Query); var query = Utils.ParseQueryString(parsedUrl.Query);
ResolveUriQuery(query, ref item); ResolveUriQuery(query, ref item);
@ -39,7 +39,7 @@ public class AnytlsFmt : BaseFmt
{ {
remark = "#" + Utils.UrlEncode(item.Remarks); remark = "#" + Utils.UrlEncode(item.Remarks);
} }
var pw = item.Id; var pw = item.Password;
var dicQuery = new Dictionary<string, string>(); var dicQuery = new Dictionary<string, string>();
ToUriQuery(item, Global.None, ref dicQuery); ToUriQuery(item, Global.None, ref dicQuery);

View file

@ -19,7 +19,7 @@ public class Hysteria2Fmt : BaseFmt
item.Address = url.IdnHost; item.Address = url.IdnHost;
item.Port = url.Port; item.Port = url.Port;
item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.Id = Utils.UrlDecode(url.UserInfo); item.Password = Utils.UrlDecode(url.UserInfo);
var query = Utils.ParseQueryString(url.Query); var query = Utils.ParseQueryString(url.Query);
ResolveUriQuery(query, ref item); ResolveUriQuery(query, ref item);
@ -75,7 +75,7 @@ public class Hysteria2Fmt : BaseFmt
dicQuery.Add("pinSHA256", Utils.UrlEncode(sha)); dicQuery.Add("pinSHA256", Utils.UrlEncode(sha));
} }
return ToUri(EConfigType.Hysteria2, item.Address, item.Port, item.Id, dicQuery, remark); return ToUri(EConfigType.Hysteria2, item.Address, item.Port, item.Password, dicQuery, remark);
} }
public static ProfileItem? ResolveFull2(string strData, string? subRemarks) public static ProfileItem? ResolveFull2(string strData, string? subRemarks)

View file

@ -12,7 +12,9 @@ public class ShadowsocksFmt : BaseFmt
{ {
return null; return null;
} }
if (item.Address.Length == 0 || item.Port == 0 || item.Security.Length == 0 || item.Id.Length == 0)
var protocolExtra = item.GetProtocolExtra();
if (item.Address.Length == 0 || item.Port == 0 || protocolExtra.SsMethod.IsNullOrEmpty() || item.Password.Length == 0)
{ {
return null; return null;
} }
@ -40,7 +42,8 @@ public class ShadowsocksFmt : BaseFmt
// item.port); // item.port);
//url = Utile.Base64Encode(url); //url = Utile.Base64Encode(url);
//new Sip002 //new Sip002
var pw = Utils.Base64Encode($"{item.Security}:{item.Id}", true); var protocolExtra = item.GetProtocolExtra();
var pw = Utils.Base64Encode($"{protocolExtra.SsMethod}:{item.Password}", true);
// plugin // plugin
var plugin = string.Empty; var plugin = string.Empty;
@ -136,10 +139,12 @@ public class ShadowsocksFmt : BaseFmt
{ {
return null; return null;
} }
item.Security = details.Groups["method"].Value; var protocolExtra = item.GetProtocolExtra();
item.Id = details.Groups["password"].Value; protocolExtra.SsMethod = details.Groups["method"].Value;
item.Password = details.Groups["password"].Value;
item.Address = details.Groups["hostname"].Value; item.Address = details.Groups["hostname"].Value;
item.Port = details.Groups["port"].Value.ToInt(); item.Port = details.Groups["port"].Value.ToInt();
item.SetProtocolExtra(protocolExtra);
return item; return item;
} }
@ -157,6 +162,7 @@ public class ShadowsocksFmt : BaseFmt
Address = parsedUrl.IdnHost, Address = parsedUrl.IdnHost,
Port = parsedUrl.Port, Port = parsedUrl.Port,
}; };
var protocolExtra = item.GetProtocolExtra();
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo); var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
//2022-blake3 //2022-blake3
if (rawUserInfo.Contains(':')) if (rawUserInfo.Contains(':'))
@ -166,8 +172,8 @@ public class ShadowsocksFmt : BaseFmt
{ {
return null; return null;
} }
item.Security = userInfoParts.First(); protocolExtra.SsMethod = userInfoParts.First();
item.Id = Utils.UrlDecode(userInfoParts.Last()); item.Password = Utils.UrlDecode(userInfoParts.Last());
} }
else else
{ {
@ -178,8 +184,8 @@ public class ShadowsocksFmt : BaseFmt
{ {
return null; return null;
} }
item.Security = userInfoParts.First(); protocolExtra.SsMethod = userInfoParts.First();
item.Id = userInfoParts.Last(); item.Password = userInfoParts.Last();
} }
var queryParameters = Utils.ParseQueryString(parsedUrl.Query); var queryParameters = Utils.ParseQueryString(parsedUrl.Query);
@ -300,11 +306,11 @@ public class ShadowsocksFmt : BaseFmt
var ssItem = new ProfileItem() var ssItem = new ProfileItem()
{ {
Remarks = it.remarks, Remarks = it.remarks,
Security = it.method, Password = it.password,
Id = it.password,
Address = it.server, Address = it.server,
Port = it.server_port.ToInt() Port = it.server_port.ToInt()
}; };
ssItem.SetProtocolExtra(new ProtocolExtraItem() { SsMethod = it.method });
lst.Add(ssItem); lst.Add(ssItem);
} }
return lst; return lst;

View file

@ -33,7 +33,8 @@ public class SocksFmt : BaseFmt
remark = "#" + Utils.UrlEncode(item.Remarks); remark = "#" + Utils.UrlEncode(item.Remarks);
} }
//new //new
var pw = Utils.Base64Encode($"{item.Security}:{item.Id}", true); var protocolExtra = item.GetProtocolExtra();
var pw = Utils.Base64Encode($"{protocolExtra.Username}:{item.Password}", true);
return ToUri(EConfigType.SOCKS, item.Address, item.Port, pw, null, remark); return ToUri(EConfigType.SOCKS, item.Address, item.Port, pw, null, remark);
} }
@ -43,6 +44,7 @@ public class SocksFmt : BaseFmt
{ {
ConfigType = EConfigType.SOCKS ConfigType = EConfigType.SOCKS
}; };
var protocolExtra = item.GetProtocolExtra();
result = result[Global.ProtocolShares[EConfigType.SOCKS].Length..]; result = result[Global.ProtocolShares[EConfigType.SOCKS].Length..];
//remark //remark
var indexRemark = result.IndexOf('#'); var indexRemark = result.IndexOf('#');
@ -78,9 +80,10 @@ public class SocksFmt : BaseFmt
} }
item.Address = arr1[1][..indexPort]; item.Address = arr1[1][..indexPort];
item.Port = arr1[1][(indexPort + 1)..].ToInt(); item.Port = arr1[1][(indexPort + 1)..].ToInt();
item.Security = arr21.First(); protocolExtra.Username = arr21.First();
item.Id = arr21[1]; item.Password = arr21[1];
item.SetProtocolExtra(protocolExtra);
return item; return item;
} }
@ -98,6 +101,7 @@ public class SocksFmt : BaseFmt
Address = parsedUrl.IdnHost, Address = parsedUrl.IdnHost,
Port = parsedUrl.Port, Port = parsedUrl.Port,
}; };
var protocolExtra = item.GetProtocolExtra();
// parse base64 UserInfo // parse base64 UserInfo
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo); var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
@ -105,8 +109,8 @@ public class SocksFmt : BaseFmt
var userInfoParts = userInfo.Split([':'], 2); var userInfoParts = userInfo.Split([':'], 2);
if (userInfoParts.Length == 2) if (userInfoParts.Length == 2)
{ {
item.Security = userInfoParts.First(); protocolExtra.Username = userInfoParts.First();
item.Id = userInfoParts[1]; item.Password = userInfoParts[1];
} }
return item; return item;

View file

@ -20,7 +20,7 @@ public class TrojanFmt : BaseFmt
item.Address = url.IdnHost; item.Address = url.IdnHost;
item.Port = url.Port; item.Port = url.Port;
item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.Id = Utils.UrlDecode(url.UserInfo); item.Password = Utils.UrlDecode(url.UserInfo);
var query = Utils.ParseQueryString(url.Query); var query = Utils.ParseQueryString(url.Query);
ResolveUriQuery(query, ref item); ResolveUriQuery(query, ref item);
@ -42,6 +42,6 @@ public class TrojanFmt : BaseFmt
var dicQuery = new Dictionary<string, string>(); var dicQuery = new Dictionary<string, string>();
ToUriQuery(item, null, ref dicQuery); ToUriQuery(item, null, ref dicQuery);
return ToUri(EConfigType.Trojan, item.Address, item.Port, item.Id, dicQuery, remark); return ToUri(EConfigType.Trojan, item.Address, item.Port, item.Password, dicQuery, remark);
} }
} }

View file

@ -10,6 +10,7 @@ public class TuicFmt : BaseFmt
{ {
ConfigType = EConfigType.TUIC ConfigType = EConfigType.TUIC
}; };
var protocolExtra = item.GetProtocolExtra();
var url = Utils.TryUri(str); var url = Utils.TryUri(str);
if (url == null) if (url == null)
@ -24,14 +25,15 @@ public class TuicFmt : BaseFmt
var userInfoParts = rawUserInfo.Split(new[] { ':' }, 2); var userInfoParts = rawUserInfo.Split(new[] { ':' }, 2);
if (userInfoParts.Length == 2) if (userInfoParts.Length == 2)
{ {
item.Id = userInfoParts.First(); item.Password = userInfoParts.First();
item.Security = userInfoParts.Last(); protocolExtra.Username = userInfoParts.Last();
} }
var query = Utils.ParseQueryString(url.Query); var query = Utils.ParseQueryString(url.Query);
ResolveUriQuery(query, ref item); ResolveUriQuery(query, ref item);
item.HeaderType = GetQueryValue(query, "congestion_control"); item.HeaderType = GetQueryValue(query, "congestion_control");
item.SetProtocolExtra(protocolExtra);
return item; return item;
} }
@ -53,6 +55,6 @@ public class TuicFmt : BaseFmt
dicQuery.Add("congestion_control", item.HeaderType); dicQuery.Add("congestion_control", item.HeaderType);
return ToUri(EConfigType.TUIC, item.Address, item.Port, $"{item.Id}:{item.Security}", dicQuery, remark); return ToUri(EConfigType.TUIC, item.Address, item.Port, $"{item.Password}:{item.GetProtocolExtra().Username ?? ""}", dicQuery, remark);
} }
} }

View file

@ -9,8 +9,8 @@ public class VLESSFmt : BaseFmt
ProfileItem item = new() ProfileItem item = new()
{ {
ConfigType = EConfigType.VLESS, ConfigType = EConfigType.VLESS,
Security = Global.None
}; };
var protocolExtra = item.GetProtocolExtra();
var url = Utils.TryUri(str); var url = Utils.TryUri(str);
if (url == null) if (url == null)
@ -21,13 +21,14 @@ public class VLESSFmt : BaseFmt
item.Address = url.IdnHost; item.Address = url.IdnHost;
item.Port = url.Port; item.Port = url.Port;
item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.Id = Utils.UrlDecode(url.UserInfo); item.Password = Utils.UrlDecode(url.UserInfo);
var query = Utils.ParseQueryString(url.Query); var query = Utils.ParseQueryString(url.Query);
item.Security = GetQueryValue(query, "encryption", Global.None); protocolExtra.VlessEncryption = GetQueryValue(query, "encryption", Global.None);
item.StreamSecurity = GetQueryValue(query, "security"); item.StreamSecurity = GetQueryValue(query, "security");
ResolveUriQuery(query, ref item); ResolveUriQuery(query, ref item);
item.SetProtocolExtra(protocolExtra);
return item; return item;
} }
@ -38,22 +39,18 @@ public class VLESSFmt : BaseFmt
return null; return null;
} }
var protocolExtra = item.GetProtocolExtra();
var remark = string.Empty; var remark = string.Empty;
if (item.Remarks.IsNotEmpty()) if (item.Remarks.IsNotEmpty())
{ {
remark = "#" + Utils.UrlEncode(item.Remarks); remark = "#" + Utils.UrlEncode(item.Remarks);
} }
var dicQuery = new Dictionary<string, string>(); var dicQuery = new Dictionary<string, string>();
if (item.Security.IsNotEmpty()) dicQuery.Add("encryption",
{ !protocolExtra.VlessEncryption.IsNullOrEmpty() ? protocolExtra.VlessEncryption : Global.None);
dicQuery.Add("encryption", item.Security);
}
else
{
dicQuery.Add("encryption", Global.None);
}
ToUriQuery(item, Global.None, ref dicQuery); ToUriQuery(item, Global.None, ref dicQuery);
return ToUri(EConfigType.VLESS, item.Address, item.Port, item.Id, dicQuery, remark); return ToUri(EConfigType.VLESS, item.Address, item.Port, item.Password, dicQuery, remark);
} }
} }

View file

@ -31,9 +31,9 @@ public class VmessFmt : BaseFmt
ps = item.Remarks.TrimEx(), ps = item.Remarks.TrimEx(),
add = item.Address, add = item.Address,
port = item.Port, port = item.Port,
id = item.Id, id = item.Password,
aid = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0, aid = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0,
scy = item.Security, scy = item.GetProtocolExtra().VmessSecurity ?? "",
net = item.Network, net = item.Network,
type = item.HeaderType, type = item.HeaderType,
host = item.RequestHost, host = item.RequestHost,
@ -77,14 +77,12 @@ public class VmessFmt : BaseFmt
item.Remarks = Utils.ToString(vmessQRCode.ps); item.Remarks = Utils.ToString(vmessQRCode.ps);
item.Address = Utils.ToString(vmessQRCode.add); item.Address = Utils.ToString(vmessQRCode.add);
item.Port = vmessQRCode.port; item.Port = vmessQRCode.port;
item.Id = Utils.ToString(vmessQRCode.id); item.Password = Utils.ToString(vmessQRCode.id);
item.SetProtocolExtra(new ProtocolExtraItem item.SetProtocolExtra(new ProtocolExtraItem
{ {
AlterId = vmessQRCode.aid.ToString(), AlterId = vmessQRCode.aid.ToString(),
VmessSecurity = vmessQRCode.scy.IsNullOrEmpty() ? Global.DefaultSecurity : vmessQRCode.scy,
}); });
item.Security = Utils.ToString(vmessQRCode.scy);
item.Security = vmessQRCode.scy.IsNotEmpty() ? vmessQRCode.scy : Global.DefaultSecurity;
if (vmessQRCode.net.IsNotEmpty()) if (vmessQRCode.net.IsNotEmpty())
{ {
item.Network = vmessQRCode.net; item.Network = vmessQRCode.net;
@ -110,7 +108,6 @@ public class VmessFmt : BaseFmt
var item = new ProfileItem var item = new ProfileItem
{ {
ConfigType = EConfigType.VMess, ConfigType = EConfigType.VMess,
Security = "auto"
}; };
var url = Utils.TryUri(str); var url = Utils.TryUri(str);
@ -122,7 +119,12 @@ public class VmessFmt : BaseFmt
item.Address = url.IdnHost; item.Address = url.IdnHost;
item.Port = url.Port; item.Port = url.Port;
item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.Id = Utils.UrlDecode(url.UserInfo); item.Password = Utils.UrlDecode(url.UserInfo);
item.SetProtocolExtra(new ProtocolExtraItem
{
VmessSecurity = "auto",
});
var query = Utils.ParseQueryString(url.Query); var query = Utils.ParseQueryString(url.Query);
ResolveUriQuery(query, ref item); ResolveUriQuery(query, ref item);

View file

@ -17,17 +17,20 @@ public class WireguardFmt : BaseFmt
return null; return null;
} }
var protocolExtra = item.GetProtocolExtra();
item.Address = url.IdnHost; item.Address = url.IdnHost;
item.Port = url.Port; item.Port = url.Port;
item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.Id = Utils.UrlDecode(url.UserInfo); item.Password = Utils.UrlDecode(url.UserInfo);
var query = Utils.ParseQueryString(url.Query); var query = Utils.ParseQueryString(url.Query);
item.PublicKey = GetQueryDecoded(query, "publickey"); protocolExtra.WgPublicKey = GetQueryDecoded(query, "publickey");
item.Path = GetQueryDecoded(query, "reserved"); protocolExtra.WgReserved = GetQueryDecoded(query, "reserved");
item.RequestHost = GetQueryDecoded(query, "address"); protocolExtra.WgInterfaceAddress = GetQueryDecoded(query, "address");
item.ShortId = GetQueryDecoded(query, "mtu"); protocolExtra.WgMtu = int.TryParse(GetQueryDecoded(query, "mtu"), out var mtu) ? mtu : 1280;
protocolExtra.WgPresharedKey = GetQueryDecoded(query, "presharedKey");
return item; return item;
} }
@ -39,6 +42,8 @@ public class WireguardFmt : BaseFmt
return null; return null;
} }
var protocolExtra = item.GetProtocolExtra();
var remark = string.Empty; var remark = string.Empty;
if (item.Remarks.IsNotEmpty()) if (item.Remarks.IsNotEmpty())
{ {
@ -46,22 +51,19 @@ public class WireguardFmt : BaseFmt
} }
var dicQuery = new Dictionary<string, string>(); var dicQuery = new Dictionary<string, string>();
if (item.PublicKey.IsNotEmpty()) if (!protocolExtra.WgPublicKey.IsNullOrEmpty())
{ {
dicQuery.Add("publickey", Utils.UrlEncode(item.PublicKey)); dicQuery.Add("publickey", Utils.UrlEncode(protocolExtra.WgPublicKey));
} }
if (item.Path.IsNotEmpty()) if (!protocolExtra.WgReserved.IsNullOrEmpty())
{ {
dicQuery.Add("reserved", Utils.UrlEncode(item.Path)); dicQuery.Add("reserved", Utils.UrlEncode(protocolExtra.WgReserved));
} }
if (item.RequestHost.IsNotEmpty()) if (!protocolExtra.WgInterfaceAddress.IsNullOrEmpty())
{ {
dicQuery.Add("address", Utils.UrlEncode(item.RequestHost)); dicQuery.Add("address", Utils.UrlEncode(protocolExtra.WgInterfaceAddress));
} }
if (item.ShortId.IsNotEmpty()) dicQuery.Add("mtu", Utils.UrlEncode(protocolExtra.WgMtu > 0 ? protocolExtra.WgMtu.ToString() : "1280"));
{ return ToUri(EConfigType.WireGuard, item.Address, item.Port, item.Password, dicQuery, remark);
dicQuery.Add("mtu", Utils.UrlEncode(item.ShortId));
}
return ToUri(EConfigType.WireGuard, item.Address, item.Port, item.Id, dicQuery, remark);
} }
} }

View file

@ -1,3 +1,5 @@
using ServiceLib.Common;
namespace ServiceLib.Manager; namespace ServiceLib.Manager;
/// <summary> /// <summary>
@ -133,17 +135,17 @@ public class ActionPrecheckManager
switch (item.ConfigType) switch (item.ConfigType)
{ {
case EConfigType.VMess: case EConfigType.VMess:
if (item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id)) if (item.Password.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Password))
{ {
errors.Add(string.Format(ResUI.InvalidProperty, "Id")); errors.Add(string.Format(ResUI.InvalidProperty, "Password"));
} }
break; break;
case EConfigType.VLESS: case EConfigType.VLESS:
if (item.Id.IsNullOrEmpty() || (!Utils.IsGuidByParse(item.Id) && item.Id.Length > 30)) if (item.Password.IsNullOrEmpty() || (!Utils.IsGuidByParse(item.Password) && item.Password.Length > 30))
{ {
errors.Add(string.Format(ResUI.InvalidProperty, "Id")); errors.Add(string.Format(ResUI.InvalidProperty, "Password"));
} }
if (!Global.Flows.Contains(protocolExtra.Flow ?? string.Empty)) if (!Global.Flows.Contains(protocolExtra.Flow ?? string.Empty))
@ -154,14 +156,14 @@ public class ActionPrecheckManager
break; break;
case EConfigType.Shadowsocks: case EConfigType.Shadowsocks:
if (item.Id.IsNullOrEmpty()) if (item.Password.IsNullOrEmpty())
{ {
errors.Add(string.Format(ResUI.InvalidProperty, "Id")); errors.Add(string.Format(ResUI.InvalidProperty, "Password"));
} }
if (string.IsNullOrEmpty(item.Security) || !Global.SsSecuritiesInSingbox.Contains(item.Security)) if (string.IsNullOrEmpty(protocolExtra.SsMethod) || !Global.SsSecuritiesInSingbox.Contains(protocolExtra.SsMethod))
{ {
errors.Add(string.Format(ResUI.InvalidProperty, "Security")); errors.Add(string.Format(ResUI.InvalidProperty, "SsMethod"));
} }
break; break;

View file

@ -294,6 +294,22 @@ public sealed class AppManager
extra.Filter = groupItem.Filter; extra.Filter = groupItem.Filter;
extra.MultipleLoad = groupItem.MultipleLoad; extra.MultipleLoad = groupItem.MultipleLoad;
} }
switch (item.ConfigType)
{
case EConfigType.Shadowsocks:
extra.SsMethod = item.Security.IsNotEmpty() ? item.Security : null;
break;
case EConfigType.VMess:
extra.VmessSecurity = item.Security.IsNotEmpty() ? item.Security : null;
break;
case EConfigType.WireGuard:
extra.WgPublicKey = item.PublicKey.IsNotEmpty() ? item.PublicKey : null;
extra.WgInterfaceAddress = item.RequestHost.IsNotEmpty() ? item.RequestHost : null;
extra.WgReserved = item.Path.IsNotEmpty() ? item.Path : null;
extra.WgMtu = int.TryParse(item.ShortId, out var mtu) ? mtu : 1280;
break;
}
} }
item.SetProtocolExtra(extra); item.SetProtocolExtra(extra);

View file

@ -1,3 +1,5 @@
using ServiceLib.Common;
namespace ServiceLib.Models; namespace ServiceLib.Models;
[Serializable] [Serializable]
@ -11,9 +13,6 @@ public class ProfileItem : ReactiveObject
Address = string.Empty; Address = string.Empty;
Port = 0; Port = 0;
Password = string.Empty; Password = string.Empty;
Id = string.Empty;
AlterId = 0;
Security = string.Empty;
Network = string.Empty; Network = string.Empty;
Remarks = string.Empty; Remarks = string.Empty;
HeaderType = string.Empty; HeaderType = string.Empty;
@ -22,7 +21,6 @@ public class ProfileItem : ReactiveObject
StreamSecurity = string.Empty; StreamSecurity = string.Empty;
AllowInsecure = string.Empty; AllowInsecure = string.Empty;
Subid = string.Empty; Subid = string.Empty;
Flow = string.Empty;
} }
#region function #region function
@ -82,7 +80,7 @@ public class ProfileItem : ReactiveObject
switch (ConfigType) switch (ConfigType)
{ {
case EConfigType.VMess: case EConfigType.VMess:
if (Id.IsNullOrEmpty() || !Utils.IsGuidByParse(Id)) if (Password.IsNullOrEmpty() || !Utils.IsGuidByParse(Password))
{ {
return false; return false;
} }
@ -90,7 +88,7 @@ public class ProfileItem : ReactiveObject
break; break;
case EConfigType.VLESS: case EConfigType.VLESS:
if (Id.IsNullOrEmpty() || (!Utils.IsGuidByParse(Id) && Id.Length > 30)) if (Password.IsNullOrEmpty() || (!Utils.IsGuidByParse(Password) && Password.Length > 30))
{ {
return false; return false;
} }
@ -103,12 +101,15 @@ public class ProfileItem : ReactiveObject
break; break;
case EConfigType.Shadowsocks: case EConfigType.Shadowsocks:
if (Id.IsNullOrEmpty()) if (Password.IsNullOrEmpty())
{ {
return false; return false;
} }
if (string.IsNullOrEmpty(Security) || !Global.SsSecuritiesInSingbox.Contains(Security)) var protocolExtra = GetProtocolExtra();
if (string.IsNullOrEmpty(protocolExtra.SsMethod)
|| !Global.SsSecuritiesInSingbox.Contains(protocolExtra.SsMethod))
{ {
return false; return false;
} }

View file

@ -1,3 +1,5 @@
using System.Linq;
namespace ServiceLib.Services.CoreConfig; namespace ServiceLib.Services.CoreConfig;
public partial class CoreConfigSingboxService public partial class CoreConfigSingboxService
@ -15,11 +17,11 @@ public partial class CoreConfigSingboxService
{ {
case EConfigType.VMess: case EConfigType.VMess:
{ {
outbound.uuid = node.Id; outbound.uuid = node.Password;
outbound.alter_id = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0; outbound.alter_id = int.TryParse(protocolExtra.AlterId, out var result) ? result : 0;
if (Global.VmessSecurities.Contains(node.Security)) if (Global.VmessSecurities.Contains(protocolExtra.VmessSecurity))
{ {
outbound.security = node.Security; outbound.security = protocolExtra.VmessSecurity;
} }
else else
{ {
@ -32,8 +34,9 @@ public partial class CoreConfigSingboxService
} }
case EConfigType.Shadowsocks: case EConfigType.Shadowsocks:
{ {
outbound.method = AppManager.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : Global.None; outbound.method = AppManager.Instance.GetShadowsocksSecurities(node).Contains(protocolExtra.SsMethod)
outbound.password = node.Id; ? protocolExtra.SsMethod : Global.None;
outbound.password = node.Password;
if (node.Network == nameof(ETransport.tcp) && node.HeaderType == Global.TcpHeaderHttp) if (node.Network == nameof(ETransport.tcp) && node.HeaderType == Global.TcpHeaderHttp)
{ {
@ -89,27 +92,27 @@ public partial class CoreConfigSingboxService
case EConfigType.SOCKS: case EConfigType.SOCKS:
{ {
outbound.version = "5"; outbound.version = "5";
if (node.Security.IsNotEmpty() if (protocolExtra.Username.IsNotEmpty()
&& node.Id.IsNotEmpty()) && node.Password.IsNotEmpty())
{ {
outbound.username = node.Security; outbound.username = protocolExtra.Username;
outbound.password = node.Id; outbound.password = node.Password;
} }
break; break;
} }
case EConfigType.HTTP: case EConfigType.HTTP:
{ {
if (node.Security.IsNotEmpty() if (protocolExtra.Username.IsNotEmpty()
&& node.Id.IsNotEmpty()) && node.Password.IsNotEmpty())
{ {
outbound.username = node.Security; outbound.username = protocolExtra.Username;
outbound.password = node.Id; outbound.password = node.Password;
} }
break; break;
} }
case EConfigType.VLESS: case EConfigType.VLESS:
{ {
outbound.uuid = node.Id; outbound.uuid = node.Password;
outbound.packet_encoding = "xudp"; outbound.packet_encoding = "xudp";
@ -127,7 +130,7 @@ public partial class CoreConfigSingboxService
} }
case EConfigType.Trojan: case EConfigType.Trojan:
{ {
outbound.password = node.Id; outbound.password = node.Password;
await GenOutboundMux(node, outbound); await GenOutboundMux(node, outbound);
await GenOutboundTransport(node, outbound); await GenOutboundTransport(node, outbound);
@ -135,7 +138,7 @@ public partial class CoreConfigSingboxService
} }
case EConfigType.Hysteria2: case EConfigType.Hysteria2:
{ {
outbound.password = node.Id; outbound.password = node.Password;
if (node.Path.IsNotEmpty()) if (node.Path.IsNotEmpty())
{ {
@ -174,14 +177,14 @@ public partial class CoreConfigSingboxService
} }
case EConfigType.TUIC: case EConfigType.TUIC:
{ {
outbound.uuid = node.Id; outbound.uuid = node.Password;
outbound.password = node.Security; outbound.password = protocolExtra.Username;
outbound.congestion_control = node.HeaderType; outbound.congestion_control = node.HeaderType;
break; break;
} }
case EConfigType.Anytls: case EConfigType.Anytls:
{ {
outbound.password = node.Id; outbound.password = node.Password;
break; break;
} }
} }
@ -199,7 +202,9 @@ public partial class CoreConfigSingboxService
{ {
try try
{ {
endpoint.address = Utils.String2List(node.RequestHost); var protocolExtra = node.GetProtocolExtra();
endpoint.address = Utils.String2List(protocolExtra.WgInterfaceAddress);
endpoint.type = Global.ProtocolTypes[node.ConfigType]; endpoint.type = Global.ProtocolTypes[node.ConfigType];
switch (node.ConfigType) switch (node.ConfigType)
@ -208,16 +213,17 @@ public partial class CoreConfigSingboxService
{ {
var peer = new Peer4Sbox var peer = new Peer4Sbox
{ {
public_key = node.PublicKey, public_key = protocolExtra.WgPublicKey,
reserved = Utils.String2List(node.Path)?.Select(int.Parse).ToList(), pre_shared_key = protocolExtra.WgPresharedKey,
reserved = Utils.String2List(protocolExtra.WgReserved)?.Select(int.Parse).ToList(),
address = node.Address, address = node.Address,
port = node.Port, port = node.Port,
// TODO default ["0.0.0.0/0", "::/0"] // TODO default ["0.0.0.0/0", "::/0"]
allowed_ips = new() { "0.0.0.0/0", "::/0" }, allowed_ips = new() { "0.0.0.0/0", "::/0" },
}; };
endpoint.private_key = node.Id; endpoint.private_key = node.Password;
endpoint.mtu = node.ShortId.IsNullOrEmpty() ? Global.TunMtus.First() : node.ShortId.ToInt(); endpoint.mtu = protocolExtra.WgMtu > 0 ? protocolExtra.WgMtu : Global.TunMtus.First();
endpoint.peers = new() { peer }; endpoint.peers = [peer];
break; break;
} }
} }

View file

@ -1,3 +1,5 @@
using System.Linq;
namespace ServiceLib.Services.CoreConfig; namespace ServiceLib.Services.CoreConfig;
public partial class CoreConfigV2rayService public partial class CoreConfigV2rayService
@ -36,12 +38,12 @@ public partial class CoreConfigV2rayService
usersItem = vnextItem.users.First(); usersItem = vnextItem.users.First();
} }
usersItem.id = node.Id; usersItem.id = node.Password;
usersItem.alterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0; usersItem.alterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
usersItem.email = Global.UserEMail; usersItem.email = Global.UserEMail;
if (Global.VmessSecurities.Contains(node.Security)) if (Global.VmessSecurities.Contains(protocolExtra.VmessSecurity))
{ {
usersItem.security = node.Security; usersItem.security = protocolExtra.VmessSecurity;
} }
else else
{ {
@ -67,8 +69,9 @@ public partial class CoreConfigV2rayService
} }
serversItem.address = node.Address; serversItem.address = node.Address;
serversItem.port = node.Port; serversItem.port = node.Port;
serversItem.password = node.Id; serversItem.password = node.Password;
serversItem.method = AppManager.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : "none"; serversItem.method = AppManager.Instance.GetShadowsocksSecurities(node).Contains(protocolExtra.SsMethod)
? protocolExtra.SsMethod : "none";
serversItem.ota = false; serversItem.ota = false;
serversItem.level = 1; serversItem.level = 1;
@ -96,13 +99,13 @@ public partial class CoreConfigV2rayService
serversItem.method = null; serversItem.method = null;
serversItem.password = null; serversItem.password = null;
if (node.Security.IsNotEmpty() if (protocolExtra.Username.IsNotEmpty()
&& node.Id.IsNotEmpty()) && node.Password.IsNotEmpty())
{ {
SocksUsersItem4Ray socksUsersItem = new() SocksUsersItem4Ray socksUsersItem = new()
{ {
user = node.Security, user = protocolExtra.Username ?? "",
pass = node.Id, pass = node.Password,
level = 1 level = 1
}; };
@ -139,9 +142,9 @@ public partial class CoreConfigV2rayService
{ {
usersItem = vnextItem.users.First(); usersItem = vnextItem.users.First();
} }
usersItem.id = node.Id; usersItem.id = node.Password;
usersItem.email = Global.UserEMail; usersItem.email = Global.UserEMail;
usersItem.encryption = node.Security; usersItem.encryption = protocolExtra.VlessEncryption;
if (protocolExtra.Flow.IsNullOrEmpty()) if (protocolExtra.Flow.IsNullOrEmpty())
{ {
@ -169,7 +172,7 @@ public partial class CoreConfigV2rayService
} }
serversItem.address = node.Address; serversItem.address = node.Address;
serversItem.port = node.Port; serversItem.port = node.Port;
serversItem.password = node.Id; serversItem.password = node.Password;
serversItem.ota = false; serversItem.ota = false;
serversItem.level = 1; serversItem.level = 1;
@ -200,16 +203,16 @@ public partial class CoreConfigV2rayService
} }
var peer = new WireguardPeer4Ray var peer = new WireguardPeer4Ray
{ {
publicKey = node.PublicKey, publicKey = protocolExtra.WgPublicKey ?? "",
endpoint = address + ":" + node.Port.ToString() endpoint = address + ":" + node.Port.ToString()
}; };
var setting = new Outboundsettings4Ray var setting = new Outboundsettings4Ray
{ {
address = Utils.String2List(node.RequestHost), address = Utils.String2List(protocolExtra.WgInterfaceAddress),
secretKey = node.Id, secretKey = node.Password,
reserved = Utils.String2List(node.Path)?.Select(int.Parse).ToList(), reserved = Utils.String2List(protocolExtra.WgReserved)?.Select(int.Parse).ToList(),
mtu = node.ShortId.IsNullOrEmpty() ? Global.TunMtus.First() : node.ShortId.ToInt(), mtu = protocolExtra.WgMtu > 0 ? protocolExtra.WgMtu : Global.TunMtus.First(),
peers = new List<WireguardPeer4Ray> { peer } peers = [peer]
}; };
outbound.settings = setting; outbound.settings = setting;
outbound.settings.vnext = null; outbound.settings.vnext = null;
@ -534,7 +537,7 @@ public partial class CoreConfigV2rayService
HysteriaSettings4Ray hysteriaSettings = new() HysteriaSettings4Ray hysteriaSettings = new()
{ {
version = 2, version = 2,
auth = node.Id, auth = node.Password,
up = upMbps > 0 ? $"{upMbps}mbps" : null, up = upMbps > 0 ? $"{upMbps}mbps" : null,
down = downMbps > 0 ? $"{downMbps}mbps" : null, down = downMbps > 0 ? $"{downMbps}mbps" : null,
udphop = udpHop, udphop = udpHop,

View file

@ -35,6 +35,29 @@ public class AddServerViewModel : MyReactiveObject
[Reactive] [Reactive]
public string Flow { get; set; } public string Flow { get; set; }
[Reactive]
public string VmessSecurity { get; set; }
[Reactive]
public string VlessEncryption { get; set; }
[Reactive]
public string SsMethod { get; set; }
[Reactive]
public string Username { get; set; }
[Reactive]
public string WgPublicKey { get; set; }
//[Reactive]
//public string WgPresharedKey { get; set; }
[Reactive]
public string WgInterfaceAddress { get; set; }
[Reactive]
public string WgReserved { get; set; }
[Reactive]
public int WgMtu { get; set; }
public ReactiveCommand<Unit, Unit> FetchCertCmd { get; } public ReactiveCommand<Unit, Unit> FetchCertCmd { get; }
public ReactiveCommand<Unit, Unit> FetchCertChainCmd { get; } public ReactiveCommand<Unit, Unit> FetchCertChainCmd { get; }
public ReactiveCommand<Unit, Unit> SaveCmd { get; } public ReactiveCommand<Unit, Unit> SaveCmd { get; }
@ -89,6 +112,14 @@ public class AddServerViewModel : MyReactiveObject
UpMbps = protocolExtra?.UpMbps ?? 0; UpMbps = protocolExtra?.UpMbps ?? 0;
DownMbps = protocolExtra?.DownMbps ?? 0; DownMbps = protocolExtra?.DownMbps ?? 0;
HopInterval = protocolExtra?.HopInterval ?? Global.Hysteria2DefaultHopInt; HopInterval = protocolExtra?.HopInterval ?? Global.Hysteria2DefaultHopInt;
VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
SsMethod = protocolExtra?.SsMethod ?? string.Empty;
Username = protocolExtra?.Username ?? string.Empty;
WgPublicKey = protocolExtra?.WgPublicKey ?? string.Empty;
WgInterfaceAddress = protocolExtra?.WgInterfaceAddress ?? string.Empty;
WgReserved = protocolExtra?.WgReserved ?? string.Empty;
WgMtu = protocolExtra?.WgMtu ?? 1280;
} }
private async Task SaveServerAsync() private async Task SaveServerAsync()
@ -113,12 +144,12 @@ public class AddServerViewModel : MyReactiveObject
} }
if (SelectedSource.ConfigType == EConfigType.Shadowsocks) if (SelectedSource.ConfigType == EConfigType.Shadowsocks)
{ {
if (SelectedSource.Id.IsNullOrEmpty()) if (SelectedSource.Password.IsNullOrEmpty())
{ {
NoticeManager.Instance.Enqueue(ResUI.FillPassword); NoticeManager.Instance.Enqueue(ResUI.FillPassword);
return; return;
} }
if (SelectedSource.Security.IsNullOrEmpty()) if (SsMethod.IsNullOrEmpty())
{ {
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectEncryption); NoticeManager.Instance.Enqueue(ResUI.PleaseSelectEncryption);
return; return;
@ -126,7 +157,7 @@ public class AddServerViewModel : MyReactiveObject
} }
if (SelectedSource.ConfigType is not EConfigType.SOCKS and not EConfigType.HTTP) if (SelectedSource.ConfigType is not EConfigType.SOCKS and not EConfigType.HTTP)
{ {
if (SelectedSource.Id.IsNullOrEmpty()) if (SelectedSource.Password.IsNullOrEmpty())
{ {
NoticeManager.Instance.Enqueue(ResUI.FillUUID); NoticeManager.Instance.Enqueue(ResUI.FillUUID);
return; return;
@ -136,12 +167,20 @@ public class AddServerViewModel : MyReactiveObject
SelectedSource.Cert = Cert.IsNullOrEmpty() ? string.Empty : Cert; SelectedSource.Cert = Cert.IsNullOrEmpty() ? string.Empty : Cert;
SelectedSource.CertSha = CertSha.IsNullOrEmpty() ? string.Empty : CertSha; SelectedSource.CertSha = CertSha.IsNullOrEmpty() ? string.Empty : CertSha;
var protocolExtra = SelectedSource.GetProtocolExtra(); var protocolExtra = SelectedSource.GetProtocolExtra();
protocolExtra.Ports = Ports; protocolExtra.Ports = Ports.IsNullOrEmpty() ? null : Ports;
protocolExtra.AlterId = AlterId > 0 ? AlterId.ToString() : string.Empty; protocolExtra.AlterId = AlterId > 0 ? AlterId.ToString() : string.Empty;
protocolExtra.Flow = Flow; protocolExtra.Flow = Flow.IsNullOrEmpty() ? null : Flow;
protocolExtra.UpMbps = UpMbps; protocolExtra.UpMbps = UpMbps > 0 ? UpMbps : null;
protocolExtra.DownMbps = DownMbps; protocolExtra.DownMbps = DownMbps > 0 ? DownMbps : null;
protocolExtra.HopInterval = HopInterval >= 5 ? HopInterval : Global.Hysteria2DefaultHopInt; protocolExtra.HopInterval = HopInterval >= 5 ? HopInterval : null;
protocolExtra.VmessSecurity = VmessSecurity.IsNullOrEmpty() ? null : VmessSecurity;
protocolExtra.VlessEncryption = VlessEncryption.IsNullOrEmpty() ? null : VlessEncryption;
protocolExtra.SsMethod = SsMethod.IsNullOrEmpty() ? null : SsMethod;
protocolExtra.Username = Username.IsNullOrEmpty() ? null : Username;
protocolExtra.WgPublicKey = WgPublicKey.IsNullOrEmpty() ? null : WgPublicKey;
protocolExtra.WgInterfaceAddress = WgInterfaceAddress.IsNullOrEmpty() ? null : WgInterfaceAddress;
protocolExtra.WgReserved = WgReserved.IsNullOrEmpty() ? null : WgReserved;
protocolExtra.WgMtu = WgMtu >= 576 ? WgMtu : null;
SelectedSource.SetProtocolExtra(protocolExtra); SelectedSource.SetProtocolExtra(protocolExtra);
if (await ConfigHandler.AddServer(_config, SelectedSource) == 0) if (await ConfigHandler.AddServer(_config, SelectedSource) == 0)

View file

@ -209,7 +209,7 @@ public class ProfilesSelectViewModel : MyReactiveObject
Remarks = t.Remarks, Remarks = t.Remarks,
Address = t.Address, Address = t.Address,
Port = t.Port, Port = t.Port,
Security = t.Security, //Security = t.Security,
Network = t.Network, Network = t.Network,
StreamSecurity = t.StreamSecurity, StreamSecurity = t.StreamSecurity,
Subid = t.Subid, Subid = t.Subid,

View file

@ -446,7 +446,7 @@ public class ProfilesViewModel : MyReactiveObject
Remarks = t.Remarks, Remarks = t.Remarks,
Address = t.Address, Address = t.Address,
Port = t.Port, Port = t.Port,
Security = t.Security, //Security = t.Security,
Network = t.Network, Network = t.Network,
StreamSecurity = t.StreamSecurity, StreamSecurity = t.StreamSecurity,
Subid = t.Subid, Subid = t.Subid,

View file

@ -39,10 +39,6 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
case EConfigType.VMess: case EConfigType.VMess:
gridVMess.IsVisible = true; gridVMess.IsVisible = true;
cmbSecurity.ItemsSource = Global.VmessSecurities; cmbSecurity.ItemsSource = Global.VmessSecurities;
if (profileItem.Security.IsNullOrEmpty())
{
profileItem.Security = Global.DefaultSecurity;
}
break; break;
case EConfigType.Shadowsocks: case EConfigType.Shadowsocks:
@ -59,10 +55,6 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
gridVLESS.IsVisible = true; gridVLESS.IsVisible = true;
lstStreamSecurity.Add(Global.StreamSecurityReality); lstStreamSecurity.Add(Global.StreamSecurityReality);
cmbFlow5.ItemsSource = Global.Flows; cmbFlow5.ItemsSource = Global.Flows;
if (profileItem.Security.IsNullOrEmpty())
{
profileItem.Security = Global.None;
}
break; break;
case EConfigType.Trojan: case EConfigType.Trojan:
@ -119,39 +111,39 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
switch (profileItem.ConfigType) switch (profileItem.ConfigType)
{ {
case EConfigType.VMess: case EConfigType.VMess:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AlterId, v => v.txtAlterId.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.AlterId, v => v.txtAlterId.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.cmbSecurity.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.VmessSecurity, v => v.cmbSecurity.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled.IsChecked).DisposeWith(disposables);
break; break;
case EConfigType.Shadowsocks: case EConfigType.Shadowsocks:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId3.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId3.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.cmbSecurity3.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SsMethod, v => v.cmbSecurity3.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled3.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled3.IsChecked).DisposeWith(disposables);
break; break;
case EConfigType.SOCKS: case EConfigType.SOCKS:
case EConfigType.HTTP: case EConfigType.HTTP:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId4.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId4.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity4.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Username, v => v.txtSecurity4.Text).DisposeWith(disposables);
break; break;
case EConfigType.VLESS: case EConfigType.VLESS:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId5.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId5.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Flow, v => v.cmbFlow5.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Flow, v => v.cmbFlow5.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity5.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.VlessEncryption, v => v.txtSecurity5.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled5.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled5.IsChecked).DisposeWith(disposables);
break; break;
case EConfigType.Trojan: case EConfigType.Trojan:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId6.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId6.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Flow, v => v.cmbFlow6.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Flow, v => v.cmbFlow6.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled6.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled6.IsChecked).DisposeWith(disposables);
break; break;
case EConfigType.Hysteria2: case EConfigType.Hysteria2:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId7.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId7.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath7.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath7.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Ports, v => v.txtPorts7.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Ports, v => v.txtPorts7.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.HopInterval, v => v.txtHopInt7.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.HopInterval, v => v.txtHopInt7.Text).DisposeWith(disposables);
@ -160,21 +152,21 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
break; break;
case EConfigType.TUIC: case EConfigType.TUIC:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId8.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId8.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity8.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Username, v => v.txtSecurity8.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType8.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType8.SelectedValue).DisposeWith(disposables);
break; break;
case EConfigType.WireGuard: case EConfigType.WireGuard:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId9.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.PublicKey, v => v.txtPublicKey9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.WgPublicKey, v => v.txtPublicKey9.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.WgReserved, v => v.txtPath9.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.WgInterfaceAddress, v => v.txtRequestHost9.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.ShortId, v => v.txtShortId9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.WgMtu, v => v.txtShortId9.Text).DisposeWith(disposables);
break; break;
case EConfigType.Anytls: case EConfigType.Anytls:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId10.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId10.Text).DisposeWith(disposables);
break; break;
} }
this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables);

View file

@ -34,10 +34,6 @@ public partial class AddServerWindow
case EConfigType.VMess: case EConfigType.VMess:
gridVMess.Visibility = Visibility.Visible; gridVMess.Visibility = Visibility.Visible;
cmbSecurity.ItemsSource = Global.VmessSecurities; cmbSecurity.ItemsSource = Global.VmessSecurities;
if (profileItem.Security.IsNullOrEmpty())
{
profileItem.Security = Global.DefaultSecurity;
}
break; break;
case EConfigType.Shadowsocks: case EConfigType.Shadowsocks:
@ -54,10 +50,6 @@ public partial class AddServerWindow
gridVLESS.Visibility = Visibility.Visible; gridVLESS.Visibility = Visibility.Visible;
lstStreamSecurity.Add(Global.StreamSecurityReality); lstStreamSecurity.Add(Global.StreamSecurityReality);
cmbFlow5.ItemsSource = Global.Flows; cmbFlow5.ItemsSource = Global.Flows;
if (profileItem.Security.IsNullOrEmpty())
{
profileItem.Security = Global.None;
}
break; break;
case EConfigType.Trojan: case EConfigType.Trojan:
@ -114,39 +106,39 @@ public partial class AddServerWindow
switch (profileItem.ConfigType) switch (profileItem.ConfigType)
{ {
case EConfigType.VMess: case EConfigType.VMess:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AlterId, v => v.txtAlterId.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.AlterId, v => v.txtAlterId.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.cmbSecurity.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.VmessSecurity, v => v.cmbSecurity.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled.IsChecked).DisposeWith(disposables);
break; break;
case EConfigType.Shadowsocks: case EConfigType.Shadowsocks:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId3.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId3.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.cmbSecurity3.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SsMethod, v => v.cmbSecurity3.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled3.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled3.IsChecked).DisposeWith(disposables);
break; break;
case EConfigType.SOCKS: case EConfigType.SOCKS:
case EConfigType.HTTP: case EConfigType.HTTP:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId4.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId4.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity4.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Username, v => v.txtSecurity4.Text).DisposeWith(disposables);
break; break;
case EConfigType.VLESS: case EConfigType.VLESS:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId5.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId5.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Flow, v => v.cmbFlow5.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Flow, v => v.cmbFlow5.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity5.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.VlessEncryption, v => v.txtSecurity5.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled5.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled5.IsChecked).DisposeWith(disposables);
break; break;
case EConfigType.Trojan: case EConfigType.Trojan:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId6.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId6.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Flow, v => v.cmbFlow6.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Flow, v => v.cmbFlow6.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled6.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.MuxEnabled, v => v.togmuxEnabled6.IsChecked).DisposeWith(disposables);
break; break;
case EConfigType.Hysteria2: case EConfigType.Hysteria2:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId7.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId7.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath7.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath7.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Ports, v => v.txtPorts7.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Ports, v => v.txtPorts7.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.HopInterval, v => v.txtHopInt7.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.HopInterval, v => v.txtHopInt7.Text).DisposeWith(disposables);
@ -155,21 +147,21 @@ public partial class AddServerWindow
break; break;
case EConfigType.TUIC: case EConfigType.TUIC:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId8.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId8.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity8.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Username, v => v.txtSecurity8.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType8.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType8.Text).DisposeWith(disposables);
break; break;
case EConfigType.WireGuard: case EConfigType.WireGuard:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId9.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.PublicKey, v => v.txtPublicKey9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.WgPublicKey, v => v.txtPublicKey9.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.WgReserved, v => v.txtPath9.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.WgInterfaceAddress, v => v.txtRequestHost9.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.ShortId, v => v.txtShortId9.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.WgMtu, v => v.txtShortId9.Text).DisposeWith(disposables);
break; break;
case EConfigType.Anytls: case EConfigType.Anytls:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId10.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId10.Text).DisposeWith(disposables);
break; break;
} }
this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.Text).DisposeWith(disposables);