mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 13:13:04 +00:00
Refactor, use record instead of class
This commit is contained in:
parent
3b826e3e36
commit
37734d2de9
14 changed files with 151 additions and 188 deletions
|
|
@ -286,18 +286,19 @@ 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.Password = profileItem.Password.TrimEx();
|
profileItem.Password = profileItem.Password.TrimEx();
|
||||||
protocolExtra.VmessSecurity = protocolExtra.VmessSecurity?.TrimEx();
|
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
|
||||||
|
{
|
||||||
|
VmessSecurity = profileItem.GetProtocolExtra().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(protocolExtra.VmessSecurity))
|
if (!Global.VmessSecurities.Contains(profileItem.GetProtocolExtra().VmessSecurity))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -306,8 +307,6 @@ public static class ConfigHandler
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
profileItem.SetProtocolExtra(protocolExtra);
|
|
||||||
|
|
||||||
await AddServerCommon(config, profileItem, toFile);
|
await AddServerCommon(config, profileItem, toFile);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -605,13 +604,14 @@ public static class ConfigHandler
|
||||||
{
|
{
|
||||||
profileItem.ConfigType = EConfigType.Shadowsocks;
|
profileItem.ConfigType = EConfigType.Shadowsocks;
|
||||||
|
|
||||||
var protocolExtra = profileItem.GetProtocolExtra();
|
|
||||||
|
|
||||||
profileItem.Address = profileItem.Address.TrimEx();
|
profileItem.Address = profileItem.Address.TrimEx();
|
||||||
profileItem.Password = profileItem.Password.TrimEx();
|
profileItem.Password = profileItem.Password.TrimEx();
|
||||||
protocolExtra.SsMethod = protocolExtra.SsMethod.TrimEx();
|
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
|
||||||
|
{
|
||||||
|
SsMethod = profileItem.GetProtocolExtra().SsMethod?.TrimEx()
|
||||||
|
});
|
||||||
|
|
||||||
if (!AppManager.Instance.GetShadowsocksSecurities(profileItem).Contains(protocolExtra.SsMethod))
|
if (!AppManager.Instance.GetShadowsocksSecurities(profileItem).Contains(profileItem.GetProtocolExtra().SsMethod))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -620,8 +620,6 @@ public static class ConfigHandler
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
profileItem.SetProtocolExtra(protocolExtra);
|
|
||||||
|
|
||||||
await AddServerCommon(config, profileItem, toFile);
|
await AddServerCommon(config, profileItem, toFile);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -707,8 +705,6 @@ public static class ConfigHandler
|
||||||
profileItem.ConfigType = EConfigType.Hysteria2;
|
profileItem.ConfigType = EConfigType.Hysteria2;
|
||||||
//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.Password = profileItem.Password.TrimEx();
|
profileItem.Password = profileItem.Password.TrimEx();
|
||||||
profileItem.Path = profileItem.Path.TrimEx();
|
profileItem.Path = profileItem.Path.TrimEx();
|
||||||
|
|
@ -722,20 +718,12 @@ public static class ConfigHandler
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (protocolExtra.UpMbps is null or < 0)
|
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
|
||||||
{
|
{
|
||||||
protocolExtra.UpMbps = config.HysteriaItem.UpMbps;
|
UpMbps = profileItem.GetProtocolExtra().UpMbps is null or < 0 ? config.HysteriaItem.UpMbps : profileItem.GetProtocolExtra().UpMbps,
|
||||||
}
|
DownMbps = profileItem.GetProtocolExtra().DownMbps is null or < 0 ? config.HysteriaItem.DownMbps : profileItem.GetProtocolExtra().DownMbps,
|
||||||
if (protocolExtra.DownMbps is null or < 0)
|
HopInterval = profileItem.GetProtocolExtra().HopInterval is null or <= 5 ? Global.Hysteria2DefaultHopInt : profileItem.GetProtocolExtra().HopInterval,
|
||||||
{
|
});
|
||||||
protocolExtra.DownMbps = config.HysteriaItem.DownMbps;
|
|
||||||
}
|
|
||||||
if (protocolExtra.HopInterval is null or <= 5)
|
|
||||||
{
|
|
||||||
protocolExtra.HopInterval = Global.Hysteria2DefaultHopInt;
|
|
||||||
}
|
|
||||||
|
|
||||||
profileItem.SetProtocolExtra(protocolExtra);
|
|
||||||
|
|
||||||
await AddServerCommon(config, profileItem, toFile);
|
await AddServerCommon(config, profileItem, toFile);
|
||||||
|
|
||||||
|
|
@ -756,11 +744,12 @@ 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.Password = profileItem.Password.TrimEx();
|
profileItem.Password = profileItem.Password.TrimEx();
|
||||||
protocolExtra.Username = protocolExtra.Username?.TrimEx();
|
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
|
||||||
|
{
|
||||||
|
Username = profileItem.GetProtocolExtra().Username?.TrimEx()
|
||||||
|
});
|
||||||
profileItem.Network = string.Empty;
|
profileItem.Network = string.Empty;
|
||||||
|
|
||||||
if (!Global.TuicCongestionControls.Contains(profileItem.HeaderType))
|
if (!Global.TuicCongestionControls.Contains(profileItem.HeaderType))
|
||||||
|
|
@ -798,26 +787,22 @@ 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.Password = profileItem.Password.TrimEx();
|
profileItem.Password = profileItem.Password.TrimEx();
|
||||||
protocolExtra.WgPublicKey = protocolExtra.WgPublicKey?.TrimEx();
|
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
|
||||||
protocolExtra.WgPresharedKey = protocolExtra.WgPresharedKey?.TrimEx();
|
|
||||||
protocolExtra.WgInterfaceAddress = protocolExtra.WgInterfaceAddress?.TrimEx();
|
|
||||||
protocolExtra.WgReserved = protocolExtra.WgReserved?.TrimEx();
|
|
||||||
if (protocolExtra.WgMtu <= 0)
|
|
||||||
{
|
{
|
||||||
protocolExtra.WgMtu = Global.TunMtus.First();
|
WgPublicKey = profileItem.GetProtocolExtra().WgPublicKey?.TrimEx(),
|
||||||
}
|
WgPresharedKey = profileItem.GetProtocolExtra().WgPresharedKey?.TrimEx(),
|
||||||
|
WgInterfaceAddress = profileItem.GetProtocolExtra().WgInterfaceAddress?.TrimEx(),
|
||||||
|
WgReserved = profileItem.GetProtocolExtra().WgReserved?.TrimEx(),
|
||||||
|
WgMtu = profileItem.GetProtocolExtra().WgMtu is null or <= 0 ? Global.TunMtus.First() : profileItem.GetProtocolExtra().WgMtu,
|
||||||
|
});
|
||||||
|
|
||||||
if (profileItem.Password.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;
|
||||||
|
|
@ -979,8 +964,6 @@ 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.Password = profileItem.Password.TrimEx();
|
profileItem.Password = profileItem.Password.TrimEx();
|
||||||
profileItem.Network = profileItem.Network.TrimEx();
|
profileItem.Network = profileItem.Network.TrimEx();
|
||||||
|
|
@ -988,22 +971,19 @@ public static class ConfigHandler
|
||||||
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();
|
|
||||||
|
|
||||||
if (!Global.Flows.Contains(protocolExtra.Flow ?? string.Empty))
|
var vlessEncryption = profileItem.GetProtocolExtra().VlessEncryption?.TrimEx();
|
||||||
|
var flow = profileItem.GetProtocolExtra().Flow?.TrimEx() ?? string.Empty;
|
||||||
|
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
|
||||||
{
|
{
|
||||||
protocolExtra.Flow = Global.Flows.First();
|
VlessEncryption = vlessEncryption.IsNullOrEmpty() ? Global.None : vlessEncryption,
|
||||||
}
|
Flow = Global.Flows.Contains(flow) ? flow : Global.Flows.First(),
|
||||||
|
});
|
||||||
|
|
||||||
if (profileItem.Password.IsNullOrEmpty())
|
if (profileItem.Password.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (protocolExtra.VlessEncryption.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
protocolExtra.VlessEncryption = Global.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
profileItem.SetProtocolExtra(protocolExtra);
|
|
||||||
|
|
||||||
await AddServerCommon(config, profileItem, toFile);
|
await AddServerCommon(config, profileItem, toFile);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,9 @@ public class Hysteria2Fmt : BaseFmt
|
||||||
dicQuery.Add("obfs", "salamander");
|
dicQuery.Add("obfs", "salamander");
|
||||||
dicQuery.Add("obfs-password", Utils.UrlEncode(item.Path));
|
dicQuery.Add("obfs-password", Utils.UrlEncode(item.Path));
|
||||||
}
|
}
|
||||||
var protocolExtra = item.GetProtocolExtra();
|
if (item.GetProtocolExtra()?.Ports?.IsNotEmpty() ?? false)
|
||||||
if (protocolExtra?.Ports?.IsNotEmpty() ?? false)
|
|
||||||
{
|
{
|
||||||
dicQuery.Add("mport", Utils.UrlEncode(protocolExtra.Ports.Replace(':', '-')));
|
dicQuery.Add("mport", Utils.UrlEncode(item.GetProtocolExtra().Ports.Replace(':', '-')));
|
||||||
}
|
}
|
||||||
if (!item.CertSha.IsNullOrEmpty())
|
if (!item.CertSha.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@ public class ShadowsocksFmt : BaseFmt
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var protocolExtra = item.GetProtocolExtra();
|
if (item.Address.Length == 0 || item.Port == 0 || item.GetProtocolExtra().SsMethod.IsNullOrEmpty() || item.Password.Length == 0)
|
||||||
if (item.Address.Length == 0 || item.Port == 0 || protocolExtra.SsMethod.IsNullOrEmpty() || item.Password.Length == 0)
|
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -42,8 +41,7 @@ public class ShadowsocksFmt : BaseFmt
|
||||||
// item.port);
|
// item.port);
|
||||||
//url = Utile.Base64Encode(url);
|
//url = Utile.Base64Encode(url);
|
||||||
//new Sip002
|
//new Sip002
|
||||||
var protocolExtra = item.GetProtocolExtra();
|
var pw = Utils.Base64Encode($"{item.GetProtocolExtra().SsMethod}:{item.Password}", true);
|
||||||
var pw = Utils.Base64Encode($"{protocolExtra.SsMethod}:{item.Password}", true);
|
|
||||||
|
|
||||||
// plugin
|
// plugin
|
||||||
var plugin = string.Empty;
|
var plugin = string.Empty;
|
||||||
|
|
@ -139,12 +137,10 @@ public class ShadowsocksFmt : BaseFmt
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var protocolExtra = item.GetProtocolExtra();
|
item.SetProtocolExtra(item.GetProtocolExtra() with { SsMethod = details.Groups["method"].Value });
|
||||||
protocolExtra.SsMethod = details.Groups["method"].Value;
|
|
||||||
item.Password = details.Groups["password"].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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,7 +158,6 @@ 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(':'))
|
||||||
|
|
@ -172,7 +167,7 @@ public class ShadowsocksFmt : BaseFmt
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
protocolExtra.SsMethod = userInfoParts.First();
|
item.SetProtocolExtra(item.GetProtocolExtra() with { SsMethod = userInfoParts.First() });
|
||||||
item.Password = Utils.UrlDecode(userInfoParts.Last());
|
item.Password = Utils.UrlDecode(userInfoParts.Last());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -184,7 +179,7 @@ public class ShadowsocksFmt : BaseFmt
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
protocolExtra.SsMethod = userInfoParts.First();
|
item.SetProtocolExtra(item.GetProtocolExtra() with { SsMethod = userInfoParts.First() });
|
||||||
item.Password = userInfoParts.Last();
|
item.Password = userInfoParts.Last();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -281,8 +276,6 @@ public class ShadowsocksFmt : BaseFmt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item.SetProtocolExtra(protocolExtra);
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,7 @@ public class SocksFmt : BaseFmt
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
var protocolExtra = item.GetProtocolExtra();
|
var pw = Utils.Base64Encode($"{item.GetProtocolExtra().Username}:{item.Password}", true);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,7 +43,6 @@ 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('#');
|
||||||
|
|
@ -80,10 +78,8 @@ 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();
|
||||||
protocolExtra.Username = arr21.First();
|
item.SetProtocolExtra(item.GetProtocolExtra() with { Username = arr21.First() });
|
||||||
item.Password = arr21[1];
|
item.Password = arr21[1];
|
||||||
|
|
||||||
item.SetProtocolExtra(protocolExtra);
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,19 +97,16 @@ 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);
|
||||||
var userInfo = Utils.Base64Decode(rawUserInfo);
|
var userInfo = Utils.Base64Decode(rawUserInfo);
|
||||||
var userInfoParts = userInfo.Split([':'], 2);
|
var userInfoParts = userInfo.Split([':'], 2);
|
||||||
if (userInfoParts.Length == 2)
|
if (userInfoParts.Length == 2)
|
||||||
{
|
{
|
||||||
protocolExtra.Username = userInfoParts.First();
|
item.SetProtocolExtra(item.GetProtocolExtra() with { Username = userInfoParts.First() });
|
||||||
item.Password = userInfoParts[1];
|
item.Password = userInfoParts[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
item.SetProtocolExtra(protocolExtra);
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ public class TrojanFmt : BaseFmt
|
||||||
{
|
{
|
||||||
ConfigType = EConfigType.Trojan
|
ConfigType = EConfigType.Trojan
|
||||||
};
|
};
|
||||||
var protocolExtra = item.GetProtocolExtra();
|
|
||||||
|
|
||||||
var url = Utils.TryUri(str);
|
var url = Utils.TryUri(str);
|
||||||
if (url == null)
|
if (url == null)
|
||||||
|
|
@ -24,10 +23,9 @@ public class TrojanFmt : BaseFmt
|
||||||
item.Password = Utils.UrlDecode(url.UserInfo);
|
item.Password = Utils.UrlDecode(url.UserInfo);
|
||||||
|
|
||||||
var query = Utils.ParseQueryString(url.Query);
|
var query = Utils.ParseQueryString(url.Query);
|
||||||
protocolExtra.Flow = GetQueryValue(query, "flow");
|
item.SetProtocolExtra(item.GetProtocolExtra() with { Flow = GetQueryValue(query, "flow") });
|
||||||
ResolveUriQuery(query, ref item);
|
ResolveUriQuery(query, ref item);
|
||||||
|
|
||||||
item.SetProtocolExtra(protocolExtra);
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,16 +35,15 @@ public class TrojanFmt : 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 (!protocolExtra.Flow.IsNullOrEmpty())
|
if (!item.GetProtocolExtra().Flow.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("flow", protocolExtra.Flow);
|
dicQuery.Add("flow", item.GetProtocolExtra().Flow);
|
||||||
}
|
}
|
||||||
ToUriQuery(item, null, ref dicQuery);
|
ToUriQuery(item, null, ref dicQuery);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ 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)
|
||||||
|
|
@ -26,14 +25,13 @@ public class TuicFmt : BaseFmt
|
||||||
if (userInfoParts.Length == 2)
|
if (userInfoParts.Length == 2)
|
||||||
{
|
{
|
||||||
item.Password = userInfoParts.First();
|
item.Password = userInfoParts.First();
|
||||||
protocolExtra.Username = userInfoParts.Last();
|
item.SetProtocolExtra(item.GetProtocolExtra() with { 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ public class VLESSFmt : BaseFmt
|
||||||
{
|
{
|
||||||
ConfigType = EConfigType.VLESS,
|
ConfigType = EConfigType.VLESS,
|
||||||
};
|
};
|
||||||
var protocolExtra = item.GetProtocolExtra();
|
|
||||||
|
|
||||||
var url = Utils.TryUri(str);
|
var url = Utils.TryUri(str);
|
||||||
if (url == null)
|
if (url == null)
|
||||||
|
|
@ -24,12 +23,14 @@ public class VLESSFmt : BaseFmt
|
||||||
item.Password = Utils.UrlDecode(url.UserInfo);
|
item.Password = Utils.UrlDecode(url.UserInfo);
|
||||||
|
|
||||||
var query = Utils.ParseQueryString(url.Query);
|
var query = Utils.ParseQueryString(url.Query);
|
||||||
protocolExtra.VlessEncryption = GetQueryValue(query, "encryption", Global.None);
|
item.SetProtocolExtra(item.GetProtocolExtra() with
|
||||||
protocolExtra.Flow = GetQueryValue(query, "flow");
|
{
|
||||||
|
VlessEncryption = GetQueryValue(query, "encryption", Global.None),
|
||||||
|
Flow = GetQueryValue(query, "flow")
|
||||||
|
});
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,8 +41,6 @@ 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())
|
||||||
{
|
{
|
||||||
|
|
@ -49,10 +48,10 @@ public class VLESSFmt : BaseFmt
|
||||||
}
|
}
|
||||||
var dicQuery = new Dictionary<string, string>();
|
var dicQuery = new Dictionary<string, string>();
|
||||||
dicQuery.Add("encryption",
|
dicQuery.Add("encryption",
|
||||||
!protocolExtra.VlessEncryption.IsNullOrEmpty() ? protocolExtra.VlessEncryption : Global.None);
|
!item.GetProtocolExtra().VlessEncryption.IsNullOrEmpty() ? item.GetProtocolExtra().VlessEncryption : Global.None);
|
||||||
if (!protocolExtra.Flow.IsNullOrEmpty())
|
if (!item.GetProtocolExtra().Flow.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("flow", protocolExtra.Flow);
|
dicQuery.Add("flow", item.GetProtocolExtra().Flow);
|
||||||
}
|
}
|
||||||
ToUriQuery(item, Global.None, ref dicQuery);
|
ToUriQuery(item, Global.None, ref dicQuery);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ public class VmessFmt : BaseFmt
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var protocolExtra = item?.GetProtocolExtra();
|
|
||||||
var vmessQRCode = new VmessQRCode
|
var vmessQRCode = new VmessQRCode
|
||||||
{
|
{
|
||||||
v = 2,
|
v = 2,
|
||||||
|
|
@ -32,7 +31,7 @@ public class VmessFmt : BaseFmt
|
||||||
add = item.Address,
|
add = item.Address,
|
||||||
port = item.Port,
|
port = item.Port,
|
||||||
id = item.Password,
|
id = item.Password,
|
||||||
aid = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0,
|
aid = int.TryParse(item.GetProtocolExtra()?.AlterId, out var result) ? result : 0,
|
||||||
scy = item.GetProtocolExtra().VmessSecurity ?? "",
|
scy = item.GetProtocolExtra().VmessSecurity ?? "",
|
||||||
net = item.Network,
|
net = item.Network,
|
||||||
type = item.HeaderType,
|
type = item.HeaderType,
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@ 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);
|
||||||
|
|
@ -26,11 +24,13 @@ public class WireguardFmt : BaseFmt
|
||||||
|
|
||||||
var query = Utils.ParseQueryString(url.Query);
|
var query = Utils.ParseQueryString(url.Query);
|
||||||
|
|
||||||
protocolExtra.WgPublicKey = GetQueryDecoded(query, "publickey");
|
item.SetProtocolExtra(item.GetProtocolExtra() with
|
||||||
protocolExtra.WgReserved = GetQueryDecoded(query, "reserved");
|
{
|
||||||
protocolExtra.WgInterfaceAddress = GetQueryDecoded(query, "address");
|
WgPublicKey = GetQueryDecoded(query, "publickey"),
|
||||||
protocolExtra.WgMtu = int.TryParse(GetQueryDecoded(query, "mtu"), out var mtu) ? mtu : 1280;
|
WgReserved = GetQueryDecoded(query, "reserved"),
|
||||||
protocolExtra.WgPresharedKey = GetQueryDecoded(query, "presharedKey");
|
WgInterfaceAddress = GetQueryDecoded(query, "address"),
|
||||||
|
WgMtu = int.TryParse(GetQueryDecoded(query, "mtu"), out var mtuVal) ? mtuVal : 1280,
|
||||||
|
});
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
@ -42,8 +42,6 @@ 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())
|
||||||
{
|
{
|
||||||
|
|
@ -51,19 +49,19 @@ public class WireguardFmt : BaseFmt
|
||||||
}
|
}
|
||||||
|
|
||||||
var dicQuery = new Dictionary<string, string>();
|
var dicQuery = new Dictionary<string, string>();
|
||||||
if (!protocolExtra.WgPublicKey.IsNullOrEmpty())
|
if (!item.GetProtocolExtra().WgPublicKey.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("publickey", Utils.UrlEncode(protocolExtra.WgPublicKey));
|
dicQuery.Add("publickey", Utils.UrlEncode(item.GetProtocolExtra().WgPublicKey));
|
||||||
}
|
}
|
||||||
if (!protocolExtra.WgReserved.IsNullOrEmpty())
|
if (!item.GetProtocolExtra().WgReserved.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("reserved", Utils.UrlEncode(protocolExtra.WgReserved));
|
dicQuery.Add("reserved", Utils.UrlEncode(item.GetProtocolExtra().WgReserved));
|
||||||
}
|
}
|
||||||
if (!protocolExtra.WgInterfaceAddress.IsNullOrEmpty())
|
if (!item.GetProtocolExtra().WgInterfaceAddress.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("address", Utils.UrlEncode(protocolExtra.WgInterfaceAddress));
|
dicQuery.Add("address", Utils.UrlEncode(item.GetProtocolExtra().WgInterfaceAddress));
|
||||||
}
|
}
|
||||||
dicQuery.Add("mtu", Utils.UrlEncode(protocolExtra.WgMtu > 0 ? protocolExtra.WgMtu.ToString() : "1280"));
|
dicQuery.Add("mtu", Utils.UrlEncode(item.GetProtocolExtra().WgMtu > 0 ? item.GetProtocolExtra().WgMtu.ToString() : "1280"));
|
||||||
return ToUri(EConfigType.WireGuard, item.Address, item.Port, item.Password, dicQuery, remark);
|
return ToUri(EConfigType.WireGuard, item.Address, item.Port, item.Password, dicQuery, remark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -288,34 +288,43 @@ public sealed class AppManager
|
||||||
|
|
||||||
if (item.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
|
if (item.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
|
||||||
{
|
{
|
||||||
extra.GroupType = nameof(item.ConfigType);
|
extra = extra with { GroupType = nameof(item.ConfigType) };
|
||||||
groupItems.TryGetValue(item.IndexId, out var groupItem);
|
groupItems.TryGetValue(item.IndexId, out var groupItem);
|
||||||
if (groupItem != null && !groupItem.NotHasChild())
|
if (groupItem != null && !groupItem.NotHasChild())
|
||||||
{
|
{
|
||||||
extra.ChildItems = groupItem.ChildItems;
|
extra = extra with
|
||||||
extra.SubChildItems = groupItem.SubChildItems;
|
{
|
||||||
extra.Filter = groupItem.Filter;
|
ChildItems = groupItem.ChildItems,
|
||||||
extra.MultipleLoad = groupItem.MultipleLoad;
|
SubChildItems = groupItem.SubChildItems,
|
||||||
|
Filter = groupItem.Filter,
|
||||||
|
MultipleLoad = groupItem.MultipleLoad,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (item.ConfigType)
|
switch (item.ConfigType)
|
||||||
{
|
{
|
||||||
case EConfigType.Shadowsocks:
|
case EConfigType.Shadowsocks:
|
||||||
extra.SsMethod = item.Security.IsNotEmpty() ? item.Security : null;
|
extra = extra with {SsMethod = item.Security.IsNotEmpty() ? item.Security : null};
|
||||||
break;
|
break;
|
||||||
case EConfigType.VMess:
|
case EConfigType.VMess:
|
||||||
extra.VmessSecurity = item.Security.IsNotEmpty() ? item.Security : null;
|
extra = extra with {VmessSecurity = item.Security.IsNotEmpty() ? item.Security : null};
|
||||||
break;
|
break;
|
||||||
case EConfigType.Hysteria2:
|
case EConfigType.Hysteria2:
|
||||||
extra.UpMbps = _config.HysteriaItem.UpMbps;
|
extra = extra with
|
||||||
extra.DownMbps = _config.HysteriaItem.DownMbps;
|
{
|
||||||
extra.HopInterval = _config.HysteriaItem.HopInterval;
|
UpMbps = _config.HysteriaItem.UpMbps,
|
||||||
|
DownMbps = _config.HysteriaItem.DownMbps,
|
||||||
|
HopInterval = _config.HysteriaItem.HopInterval
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
case EConfigType.WireGuard:
|
case EConfigType.WireGuard:
|
||||||
extra.WgPublicKey = item.PublicKey.IsNotEmpty() ? item.PublicKey : null;
|
extra = extra with
|
||||||
extra.WgInterfaceAddress = item.RequestHost.IsNotEmpty() ? item.RequestHost : null;
|
{
|
||||||
extra.WgReserved = item.Path.IsNotEmpty() ? item.Path : null;
|
WgPublicKey = item.PublicKey.IsNotEmpty() ? item.PublicKey : null,
|
||||||
extra.WgMtu = int.TryParse(item.ShortId, out var mtu) ? mtu : 1280;
|
WgInterfaceAddress = item.RequestHost.IsNotEmpty() ? item.RequestHost : null,
|
||||||
|
WgReserved = item.Path.IsNotEmpty() ? item.Path : null,
|
||||||
|
WgMtu = int.TryParse(item.ShortId, out var mtu) ? mtu : 1280
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,10 +106,8 @@ public class ProfileItem : ReactiveObject
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var protocolExtra = GetProtocolExtra();
|
if (string.IsNullOrEmpty(GetProtocolExtra().SsMethod)
|
||||||
|
|| !Global.SsSecuritiesInSingbox.Contains(GetProtocolExtra().SsMethod))
|
||||||
if (string.IsNullOrEmpty(protocolExtra.SsMethod)
|
|
||||||
|| !Global.SsSecuritiesInSingbox.Contains(protocolExtra.SsMethod))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,40 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
public class ProtocolExtraItem
|
public record ProtocolExtraItem
|
||||||
{
|
{
|
||||||
// vmess
|
// vmess
|
||||||
public string? AlterId { get; set; }
|
public string? AlterId { get; init; }
|
||||||
public string? VmessSecurity { get; set; }
|
public string? VmessSecurity { get; init; }
|
||||||
|
|
||||||
// vless
|
// vless
|
||||||
public string? Flow { get; set; }
|
public string? Flow { get; init; }
|
||||||
public string? VlessEncryption { get; set; }
|
public string? VlessEncryption { get; init; }
|
||||||
//public string? VisionSeed { get; set; }
|
//public string? VisionSeed { get; init; }
|
||||||
|
|
||||||
// shadowsocks
|
// shadowsocks
|
||||||
//public string? PluginArgs { get; set; }
|
//public string? PluginArgs { get; init; }
|
||||||
public string? SsMethod { get; set; }
|
public string? SsMethod { get; init; }
|
||||||
|
|
||||||
// socks and http
|
// socks and http
|
||||||
public string? Username { get; set; }
|
public string? Username { get; init; }
|
||||||
|
|
||||||
// wireguard
|
// wireguard
|
||||||
public string? WgPublicKey { get; set; }
|
public string? WgPublicKey { get; init; }
|
||||||
public string? WgPresharedKey { get; set; }
|
public string? WgPresharedKey { get; init; }
|
||||||
public string? WgInterfaceAddress { get; set; }
|
public string? WgInterfaceAddress { get; init; }
|
||||||
public string? WgReserved { get; set; }
|
public string? WgReserved { get; init; }
|
||||||
public int? WgMtu { get; set; }
|
public int? WgMtu { get; init; }
|
||||||
|
|
||||||
// hysteria2
|
// hysteria2
|
||||||
public int? UpMbps { get; set; }
|
public int? UpMbps { get; init; }
|
||||||
public int? DownMbps { get; set; }
|
public int? DownMbps { get; init; }
|
||||||
public string? Ports { get; set; }
|
public string? Ports { get; init; }
|
||||||
public int? HopInterval { get; set; }
|
public int? HopInterval { get; init; }
|
||||||
|
|
||||||
// group profile
|
// group profile
|
||||||
public string? GroupType { get; set; }
|
public string? GroupType { get; init; }
|
||||||
public string? ChildItems { get; set; }
|
public string? ChildItems { get; init; }
|
||||||
public string? SubChildItems { get; set; }
|
public string? SubChildItems { get; init; }
|
||||||
public string? Filter { get; set; }
|
public string? Filter { get; init; }
|
||||||
public EMultipleLoad? MultipleLoad { get; set; }
|
public EMultipleLoad? MultipleLoad { get; init; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,31 +202,30 @@ public class AddGroupServerViewModel : MyReactiveObject
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var protocolExtra = SelectedSource.GetProtocolExtra();
|
SelectedSource.SetProtocolExtra(SelectedSource.GetProtocolExtra() with
|
||||||
protocolExtra.ChildItems =
|
|
||||||
Utils.List2String(ChildItemsObs.Where(s => !s.IndexId.IsNullOrEmpty()).Select(s => s.IndexId).ToList());
|
|
||||||
protocolExtra.MultipleLoad = PolicyGroupType switch
|
|
||||||
{
|
{
|
||||||
var s when s == ResUI.TbLeastPing => EMultipleLoad.LeastPing,
|
ChildItems =
|
||||||
var s when s == ResUI.TbFallback => EMultipleLoad.Fallback,
|
Utils.List2String(ChildItemsObs.Where(s => !s.IndexId.IsNullOrEmpty()).Select(s => s.IndexId).ToList()),
|
||||||
var s when s == ResUI.TbRandom => EMultipleLoad.Random,
|
MultipleLoad = PolicyGroupType switch
|
||||||
var s when s == ResUI.TbRoundRobin => EMultipleLoad.RoundRobin,
|
{
|
||||||
var s when s == ResUI.TbLeastLoad => EMultipleLoad.LeastLoad,
|
var s when s == ResUI.TbLeastPing => EMultipleLoad.LeastPing,
|
||||||
_ => EMultipleLoad.LeastPing,
|
var s when s == ResUI.TbFallback => EMultipleLoad.Fallback,
|
||||||
};
|
var s when s == ResUI.TbRandom => EMultipleLoad.Random,
|
||||||
|
var s when s == ResUI.TbRoundRobin => EMultipleLoad.RoundRobin,
|
||||||
|
var s when s == ResUI.TbLeastLoad => EMultipleLoad.LeastLoad,
|
||||||
|
_ => EMultipleLoad.LeastPing,
|
||||||
|
},
|
||||||
|
SubChildItems = SelectedSubItem?.Id,
|
||||||
|
Filter = Filter,
|
||||||
|
});
|
||||||
|
|
||||||
protocolExtra.SubChildItems = SelectedSubItem?.Id;
|
var hasCycle = await GroupProfileManager.HasCycle(SelectedSource.IndexId, SelectedSource.GetProtocolExtra());
|
||||||
protocolExtra.Filter = Filter;
|
|
||||||
|
|
||||||
var hasCycle = await GroupProfileManager.HasCycle(SelectedSource.IndexId, protocolExtra);
|
|
||||||
if (hasCycle)
|
if (hasCycle)
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.Enqueue(string.Format(ResUI.GroupSelfReference, remarks));
|
NoticeManager.Instance.Enqueue(string.Format(ResUI.GroupSelfReference, remarks));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectedSource.SetProtocolExtra(protocolExtra);
|
|
||||||
|
|
||||||
if (await ConfigHandler.AddServerCommon(_config, SelectedSource) == 0)
|
if (await ConfigHandler.AddServerCommon(_config, SelectedSource) == 0)
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
|
|
|
||||||
|
|
@ -166,22 +166,23 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
SelectedSource.CoreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType);
|
SelectedSource.CoreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType);
|
||||||
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();
|
SelectedSource.SetProtocolExtra(SelectedSource.GetProtocolExtra() with
|
||||||
protocolExtra.Ports = Ports.IsNullOrEmpty() ? null : Ports;
|
{
|
||||||
protocolExtra.AlterId = AlterId > 0 ? AlterId.ToString() : string.Empty;
|
Ports = Ports.IsNullOrEmpty() ? null : Ports,
|
||||||
protocolExtra.Flow = Flow.IsNullOrEmpty() ? null : Flow;
|
AlterId = AlterId > 0 ? AlterId.ToString() : string.Empty,
|
||||||
protocolExtra.UpMbps = UpMbps > 0 ? UpMbps : null;
|
Flow = Flow.IsNullOrEmpty() ? null : Flow,
|
||||||
protocolExtra.DownMbps = DownMbps > 0 ? DownMbps : null;
|
UpMbps = UpMbps > 0 ? UpMbps : null,
|
||||||
protocolExtra.HopInterval = HopInterval >= 5 ? HopInterval : null;
|
DownMbps = DownMbps > 0 ? DownMbps : null,
|
||||||
protocolExtra.VmessSecurity = VmessSecurity.IsNullOrEmpty() ? null : VmessSecurity;
|
HopInterval = HopInterval >= 5 ? HopInterval : null,
|
||||||
protocolExtra.VlessEncryption = VlessEncryption.IsNullOrEmpty() ? null : VlessEncryption;
|
VmessSecurity = VmessSecurity.IsNullOrEmpty() ? null : VmessSecurity,
|
||||||
protocolExtra.SsMethod = SsMethod.IsNullOrEmpty() ? null : SsMethod;
|
VlessEncryption = VlessEncryption.IsNullOrEmpty() ? null : VlessEncryption,
|
||||||
protocolExtra.Username = Username.IsNullOrEmpty() ? null : Username;
|
SsMethod = SsMethod.IsNullOrEmpty() ? null : SsMethod,
|
||||||
protocolExtra.WgPublicKey = WgPublicKey.IsNullOrEmpty() ? null : WgPublicKey;
|
Username = Username.IsNullOrEmpty() ? null : Username,
|
||||||
protocolExtra.WgInterfaceAddress = WgInterfaceAddress.IsNullOrEmpty() ? null : WgInterfaceAddress;
|
WgPublicKey = WgPublicKey.IsNullOrEmpty() ? null : WgPublicKey,
|
||||||
protocolExtra.WgReserved = WgReserved.IsNullOrEmpty() ? null : WgReserved;
|
WgInterfaceAddress = WgInterfaceAddress.IsNullOrEmpty() ? null : WgInterfaceAddress,
|
||||||
protocolExtra.WgMtu = WgMtu >= 576 ? WgMtu : null;
|
WgReserved = WgReserved.IsNullOrEmpty() ? null : WgReserved,
|
||||||
SelectedSource.SetProtocolExtra(protocolExtra);
|
WgMtu = WgMtu >= 576 ? WgMtu : null,
|
||||||
|
});
|
||||||
|
|
||||||
if (await ConfigHandler.AddServer(_config, SelectedSource) == 0)
|
if (await ConfigHandler.AddServer(_config, SelectedSource) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue