Compare commits

..

9 Commits
6.38 ... 6.39

Author SHA1 Message Date
2dust
5805ac9f7f Update 6.39 2024-03-12 09:19:19 +08:00
2dust
4e2f38a343 Clean 2024-03-12 09:14:21 +08:00
2dust
572c924e5c Add httpupgrade 2024-03-12 09:05:59 +08:00
2dust
e90353e550 Bug fix 2024-03-11 14:46:24 +08:00
2dust
f8ae1b8c49 Bug fix 2024-03-11 08:34:07 +08:00
2dust
186d995919 Improve 2024-03-09 14:30:39 +08:00
2dust
70584aff9d Refactor 2024-03-09 10:12:45 +08:00
2dust
dcdc63785a HTTP port=SOCKS port+1;Pac port=SOCKS port+4;API port=SOCKS port+5; 2024-03-09 09:40:19 +08:00
2dust
0e7bfa65de Refactor 2024-03-09 09:27:55 +08:00
28 changed files with 216 additions and 224 deletions

View File

@@ -8,9 +8,6 @@ namespace v2rayN
public const string GithubUrl = "https://github.com"; public const string GithubUrl = "https://github.com";
public const string GithubApiUrl = "https://api.github.com/repos"; public const string GithubApiUrl = "https://api.github.com/repos";
public const string V2rayWebsiteUrl = @"https://www.v2fly.org/";
public const string AboutUrl = @"https://github.com/2dust/v2rayN";
public const string UpdateUrl = AboutUrl + @"/releases";
public const string V2flyCoreUrl = "https://github.com/v2fly/v2ray-core/releases"; public const string V2flyCoreUrl = "https://github.com/v2fly/v2ray-core/releases";
public const string XrayCoreUrl = "https://github.com/XTLS/Xray-core/releases"; public const string XrayCoreUrl = "https://github.com/XTLS/Xray-core/releases";
public const string SagerNetCoreUrl = "https://github.com/SagerNet/v2ray-core/releases"; public const string SagerNetCoreUrl = "https://github.com/SagerNet/v2ray-core/releases";
@@ -23,7 +20,6 @@ namespace v2rayN
public const string TuicCoreUrl = "https://github.com/EAimTY/tuic/releases"; public const string TuicCoreUrl = "https://github.com/EAimTY/tuic/releases";
public const string SingboxCoreUrl = "https://github.com/SagerNet/sing-box/releases"; public const string SingboxCoreUrl = "https://github.com/SagerNet/sing-box/releases";
public const string GeoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/{0}.dat"; public const string GeoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/{0}.dat";
public const string SingboxGeoUrl = "https://github.com/soffchen/sing-{0}/releases/latest/download/{0}.db";
public const string SpeedPingTestUrl = @"https://www.google.com/generate_204"; public const string SpeedPingTestUrl = @"https://www.google.com/generate_204";
public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases"; public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases";
public const string CustomRoutingListUrl = @"https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/"; public const string CustomRoutingListUrl = @"https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/";
@@ -56,21 +52,14 @@ namespace v2rayN
public const string BlockTag = "block"; public const string BlockTag = "block";
public const string StreamSecurity = "tls"; public const string StreamSecurity = "tls";
public const string StreamSecurityReality = "reality"; public const string StreamSecurityReality = "reality";
public const string InboundSocks = "socks";
public const string InboundHttp = "http";
public const string InboundSocks2 = "socks2";
public const string InboundHttp2 = "http2";
public const string Loopback = "127.0.0.1"; public const string Loopback = "127.0.0.1";
public const string InboundAPITagName = "api";
public const string InboundAPIProtocol = "dokodemo-door"; public const string InboundAPIProtocol = "dokodemo-door";
public const string HttpProtocol = "http://"; public const string HttpProtocol = "http://";
public const string HttpsProtocol = "https://"; public const string HttpsProtocol = "https://";
public const string UserEMail = "t@t.tt"; public const string UserEMail = "t@t.tt";
public const string MyRegPath = "Software\\v2rayNGUI";
public const string AutoRunRegPath = @"Software\Microsoft\Windows\CurrentVersion\Run"; public const string AutoRunRegPath = @"Software\Microsoft\Windows\CurrentVersion\Run";
public const string AutoRunName = "v2rayNAutoRun"; public const string AutoRunName = "v2rayNAutoRun";
public const string MyRegKeyLanguage = "CurrentLanguage";
public const string CustomIconName = "v2rayN.ico"; public const string CustomIconName = "v2rayN.ico";
public const string IEProxyExceptions = "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*"; public const string IEProxyExceptions = "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*";
public const string RoutingRuleComma = "<COMMA>"; public const string RoutingRuleComma = "<COMMA>";
@@ -122,6 +111,8 @@ namespace v2rayN
public static readonly List<string> SpeedPingTestUrls = new() { public static readonly List<string> SpeedPingTestUrls = new() {
@"https://www.google.com/generate_204", @"https://www.google.com/generate_204",
@"https://www.apple.com/library/test/success.html",
@"http://www.msftconnecttest.com/connecttest.txt",
}; };
public static readonly Dictionary<string, string> UserAgentTexts = new() public static readonly Dictionary<string, string> UserAgentTexts = new()
@@ -165,7 +156,7 @@ namespace v2rayN
public static readonly List<string> SsSecuritiesInXray = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "xchacha20-poly1305", "xchacha20-ietf-poly1305", "none", "plain", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305" }; public static readonly List<string> SsSecuritiesInXray = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "xchacha20-poly1305", "xchacha20-ietf-poly1305", "none", "plain", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305" };
public static readonly List<string> SsSecuritiesInSingbox = new() { "aes-256-gcm", "aes-192-gcm", "aes-128-gcm", "chacha20-ietf-poly1305", "xchacha20-ietf-poly1305", "none", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "rc4-md5", "chacha20-ietf", "xchacha20" }; public static readonly List<string> SsSecuritiesInSingbox = new() { "aes-256-gcm", "aes-192-gcm", "aes-128-gcm", "chacha20-ietf-poly1305", "xchacha20-ietf-poly1305", "none", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "rc4-md5", "chacha20-ietf", "xchacha20" };
public static readonly List<string> Flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" }; public static readonly List<string> Flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" };
public static readonly List<string> Networks = new() { "tcp", "kcp", "ws", "h2", "quic", "grpc" }; public static readonly List<string> Networks = new() { "tcp", "kcp", "ws", "httpupgrade", "h2", "quic", "grpc" };
public static readonly List<string> KcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" }; public static readonly List<string> KcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" };
public static readonly List<string> CoreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" }; public static readonly List<string> CoreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" };
public static readonly List<string> CoreTypes4VLESS = new() { "Xray", "sing_box" }; public static readonly List<string> CoreTypes4VLESS = new() { "Xray", "sing_box" };

View File

@@ -61,7 +61,7 @@ namespace v2rayN.Handler
config.inbound = new List<InItem>(); config.inbound = new List<InItem>();
InItem inItem = new() InItem inItem = new()
{ {
protocol = Global.InboundSocks, protocol = EInboundProtocol.socks.ToString(),
localPort = 10808, localPort = 10808,
udpEnabled = true, udpEnabled = true,
sniffingEnabled = true, sniffingEnabled = true,
@@ -69,19 +69,12 @@ namespace v2rayN.Handler
}; };
config.inbound.Add(inItem); config.inbound.Add(inItem);
//inItem = new InItem();
//inItem.protocol = "http";
//inItem.localPort = 1081;
//inItem.udpEnabled = true;
//config.inbound.Add(inItem);
} }
else else
{ {
if (config.inbound.Count > 0) if (config.inbound.Count > 0)
{ {
config.inbound[0].protocol = Global.InboundSocks; config.inbound[0].protocol = EInboundProtocol.socks.ToString();
} }
} }
if (config.routingBasicItem == null) if (config.routingBasicItem == null)

View File

@@ -132,8 +132,8 @@ namespace v2rayN.Handler
fileContent.RemoveAt(indexPort); fileContent.RemoveAt(indexPort);
} }
fileContent.Add($"port: {LazyConfig.Instance.GetLocalPort(Global.InboundHttp)}"); fileContent.Add($"port: {LazyConfig.Instance.GetLocalPort(EInboundProtocol.http)}");
fileContent.Add($"socks-port: {LazyConfig.Instance.GetLocalPort(Global.InboundSocks)}"); fileContent.Add($"socks-port: {LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks)}");
break; break;
} }
File.WriteAllLines(fileName, fileContent); File.WriteAllLines(fileName, fileContent);

View File

@@ -115,13 +115,13 @@ namespace v2rayN.Handler
{ {
var inbound = new Inbound4Sbox() var inbound = new Inbound4Sbox()
{ {
type = Global.InboundSocks, type = EInboundProtocol.socks.ToString(),
tag = Global.InboundSocks, tag = EInboundProtocol.socks.ToString(),
listen = Global.Loopback, listen = Global.Loopback,
}; };
singboxConfig.inbounds.Add(inbound); singboxConfig.inbounds.Add(inbound);
inbound.listen_port = LazyConfig.Instance.GetLocalPort(Global.InboundSocks); inbound.listen_port = LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks);
inbound.sniff = _config.inbound[0].sniffingEnabled; inbound.sniff = _config.inbound[0].sniffingEnabled;
inbound.sniff_override_destination = _config.inbound[0].routeOnly ? false : _config.inbound[0].sniffingEnabled; inbound.sniff_override_destination = _config.inbound[0].routeOnly ? false : _config.inbound[0].sniffingEnabled;
inbound.domain_strategy = Utile.IsNullOrEmpty(_config.routingBasicItem.domainStrategy4Singbox) ? null : _config.routingBasicItem.domainStrategy4Singbox; inbound.domain_strategy = Utile.IsNullOrEmpty(_config.routingBasicItem.domainStrategy4Singbox) ? null : _config.routingBasicItem.domainStrategy4Singbox;
@@ -136,18 +136,18 @@ namespace v2rayN.Handler
} }
//http //http
var inbound2 = GetInbound(inbound, Global.InboundHttp, 1, false); var inbound2 = GetInbound(inbound, EInboundProtocol.http, false);
singboxConfig.inbounds.Add(inbound2); singboxConfig.inbounds.Add(inbound2);
if (_config.inbound[0].allowLANConn) if (_config.inbound[0].allowLANConn)
{ {
if (_config.inbound[0].newPort4LAN) if (_config.inbound[0].newPort4LAN)
{ {
var inbound3 = GetInbound(inbound, Global.InboundSocks2, 2, true); var inbound3 = GetInbound(inbound, EInboundProtocol.socks2, true);
inbound3.listen = "::"; inbound3.listen = "::";
singboxConfig.inbounds.Add(inbound3); singboxConfig.inbounds.Add(inbound3);
var inbound4 = GetInbound(inbound, Global.InboundHttp2, 3, false); var inbound4 = GetInbound(inbound, EInboundProtocol.http2, false);
inbound4.listen = "::"; inbound4.listen = "::";
singboxConfig.inbounds.Add(inbound4); singboxConfig.inbounds.Add(inbound4);
@@ -198,12 +198,12 @@ namespace v2rayN.Handler
return 0; return 0;
} }
private Inbound4Sbox GetInbound(Inbound4Sbox inItem, string tag, int offset, bool bSocks) private Inbound4Sbox GetInbound(Inbound4Sbox inItem, EInboundProtocol protocol, bool bSocks)
{ {
var inbound = JsonUtile.DeepCopy(inItem); var inbound = JsonUtile.DeepCopy(inItem);
inbound.tag = tag; inbound.tag = protocol.ToString();
inbound.listen_port = inItem.listen_port + offset; inbound.listen_port = inItem.listen_port + (int)protocol;
inbound.type = bSocks ? Global.InboundSocks : Global.InboundHttp; inbound.type = bSocks ? EInboundProtocol.socks.ToString() : EInboundProtocol.http.ToString();
return inbound; return inbound;
} }
@@ -405,13 +405,13 @@ namespace v2rayN.Handler
switch (node.GetNetwork()) switch (node.GetNetwork())
{ {
case "h2": case nameof(ETransport.h2):
transport.type = "http"; transport.type = nameof(ETransport.http);
transport.host = Utile.IsNullOrEmpty(node.requestHost) ? null : Utile.String2List(node.requestHost); transport.host = Utile.IsNullOrEmpty(node.requestHost) ? null : Utile.String2List(node.requestHost);
transport.path = Utile.IsNullOrEmpty(node.path) ? null : node.path; transport.path = Utile.IsNullOrEmpty(node.path) ? null : node.path;
break; break;
case "tcp": //http case nameof(ETransport.tcp): //http
if (node.headerType == Global.TcpHeaderHttp) if (node.headerType == Global.TcpHeaderHttp)
{ {
if (node.configType == EConfigType.Shadowsocks) if (node.configType == EConfigType.Shadowsocks)
@@ -421,20 +421,15 @@ namespace v2rayN.Handler
} }
else else
{ {
transport.type = "http"; transport.type = nameof(ETransport.http);
transport.host = Utile.IsNullOrEmpty(node.requestHost) ? null : Utile.String2List(node.requestHost); transport.host = Utile.IsNullOrEmpty(node.requestHost) ? null : Utile.String2List(node.requestHost);
transport.path = Utile.IsNullOrEmpty(node.path) ? null : node.path; transport.path = Utile.IsNullOrEmpty(node.path) ? null : node.path;
} }
} }
else
{
transport = null;
}
break; break;
case "ws": case nameof(ETransport.ws):
transport.type = "ws"; transport.type = nameof(ETransport.ws);
transport.path = Utile.IsNullOrEmpty(node.path) ? null : node.path; transport.path = Utile.IsNullOrEmpty(node.path) ? null : node.path;
if (!Utile.IsNullOrEmpty(node.requestHost)) if (!Utile.IsNullOrEmpty(node.requestHost))
{ {
@@ -445,12 +440,19 @@ namespace v2rayN.Handler
} }
break; break;
case "quic": case nameof(ETransport.httpupgrade):
transport.type = "quic"; transport.type = nameof(ETransport.httpupgrade);
transport.path = Utile.IsNullOrEmpty(node.path) ? null : node.path;
transport.host = Utile.IsNullOrEmpty(node.requestHost) ? null : node.requestHost;
break; break;
case "grpc": case nameof(ETransport.quic):
transport.type = "grpc"; transport.type = nameof(ETransport.quic);
break;
case nameof(ETransport.grpc):
transport.type = nameof(ETransport.grpc);
transport.service_name = node.path; transport.service_name = node.path;
transport.idle_timeout = _config.grpcItem.idle_timeout.ToString("##s"); transport.idle_timeout = _config.grpcItem.idle_timeout.ToString("##s");
transport.ping_timeout = _config.grpcItem.health_check_timeout.ToString("##s"); transport.ping_timeout = _config.grpcItem.health_check_timeout.ToString("##s");
@@ -458,12 +460,13 @@ namespace v2rayN.Handler
break; break;
default: default:
transport = null;
break; break;
} }
if (transport.type != null)
{
outbound.transport = transport; outbound.transport = transport;
} }
}
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(ex.Message, ex); Logging.SaveLog(ex.Message, ex);
@@ -877,11 +880,11 @@ namespace v2rayN.Handler
} }
GenLog(singboxConfig); GenLog(singboxConfig);
GenDns(new(), singboxConfig); //GenDns(new(), singboxConfig);
singboxConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts. singboxConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts.
singboxConfig.outbounds.RemoveAt(0); singboxConfig.outbounds.RemoveAt(0);
int httpPort = LazyConfig.Instance.GetLocalPort("speedtest"); int httpPort = LazyConfig.Instance.GetLocalPort(EInboundProtocol.speedtest);
foreach (var it in selecteds) foreach (var it in selecteds)
{ {
@@ -933,9 +936,9 @@ namespace v2rayN.Handler
{ {
listen = Global.Loopback, listen = Global.Loopback,
listen_port = port, listen_port = port,
type = Global.InboundHttp type = EInboundProtocol.http.ToString(),
}; };
inbound.tag = Global.InboundHttp + inbound.listen_port.ToString(); inbound.tag = inbound.type + inbound.listen_port.ToString();
singboxConfig.inbounds.Add(inbound); singboxConfig.inbounds.Add(inbound);
//outbound //outbound

View File

@@ -100,22 +100,22 @@ namespace v2rayN.Handler
{ {
v2rayConfig.inbounds = new List<Inbounds4Ray>(); v2rayConfig.inbounds = new List<Inbounds4Ray>();
Inbounds4Ray? inbound = GetInbound(_config.inbound[0], Global.InboundSocks, 0, true); Inbounds4Ray? inbound = GetInbound(_config.inbound[0], EInboundProtocol.socks, true);
v2rayConfig.inbounds.Add(inbound); v2rayConfig.inbounds.Add(inbound);
//http //http
Inbounds4Ray? inbound2 = GetInbound(_config.inbound[0], Global.InboundHttp, 1, false); Inbounds4Ray? inbound2 = GetInbound(_config.inbound[0], EInboundProtocol.http, false);
v2rayConfig.inbounds.Add(inbound2); v2rayConfig.inbounds.Add(inbound2);
if (_config.inbound[0].allowLANConn) if (_config.inbound[0].allowLANConn)
{ {
if (_config.inbound[0].newPort4LAN) if (_config.inbound[0].newPort4LAN)
{ {
Inbounds4Ray inbound3 = GetInbound(_config.inbound[0], Global.InboundSocks2, 2, true); var inbound3 = GetInbound(_config.inbound[0], EInboundProtocol.socks2, true);
inbound3.listen = "0.0.0.0"; inbound3.listen = "0.0.0.0";
v2rayConfig.inbounds.Add(inbound3); v2rayConfig.inbounds.Add(inbound3);
Inbounds4Ray inbound4 = GetInbound(_config.inbound[0], Global.InboundHttp2, 3, false); var inbound4 = GetInbound(_config.inbound[0], EInboundProtocol.http2, false);
inbound4.listen = "0.0.0.0"; inbound4.listen = "0.0.0.0";
v2rayConfig.inbounds.Add(inbound4); v2rayConfig.inbounds.Add(inbound4);
@@ -143,7 +143,7 @@ namespace v2rayN.Handler
return 0; return 0;
} }
private Inbounds4Ray? GetInbound(InItem inItem, string tag, int offset, bool bSocks) private Inbounds4Ray? GetInbound(InItem inItem, EInboundProtocol protocol, bool bSocks)
{ {
string result = Utile.GetEmbedText(Global.V2raySampleInbound); string result = Utile.GetEmbedText(Global.V2raySampleInbound);
if (Utile.IsNullOrEmpty(result)) if (Utile.IsNullOrEmpty(result))
@@ -156,9 +156,9 @@ namespace v2rayN.Handler
{ {
return null; return null;
} }
inbound.tag = tag; inbound.tag = protocol.ToString();
inbound.port = inItem.localPort + offset; inbound.port = inItem.localPort + (int)protocol;
inbound.protocol = bSocks ? Global.InboundSocks : Global.InboundHttp; inbound.protocol = bSocks ? EInboundProtocol.socks.ToString() : EInboundProtocol.http.ToString();
inbound.settings.udp = inItem.udpEnabled; inbound.settings.udp = inItem.udpEnabled;
inbound.sniffing.enabled = inItem.sniffingEnabled; inbound.sniffing.enabled = inItem.sniffingEnabled;
inbound.sniffing.routeOnly = inItem.routeOnly; inbound.sniffing.routeOnly = inItem.routeOnly;
@@ -564,7 +564,7 @@ namespace v2rayN.Handler
//streamSettings //streamSettings
switch (node.GetNetwork()) switch (node.GetNetwork())
{ {
case "kcp": case nameof(ETransport.kcp):
KcpSettings4Ray kcpSettings = new() KcpSettings4Ray kcpSettings = new()
{ {
mtu = _config.kcpItem.mtu, mtu = _config.kcpItem.mtu,
@@ -588,7 +588,7 @@ namespace v2rayN.Handler
streamSettings.kcpSettings = kcpSettings; streamSettings.kcpSettings = kcpSettings;
break; break;
//ws //ws
case "ws": case nameof(ETransport.ws):
WsSettings4Ray wsSettings = new(); WsSettings4Ray wsSettings = new();
wsSettings.headers = new Headers4Ray(); wsSettings.headers = new Headers4Ray();
string path = node.path; string path = node.path;
@@ -606,9 +606,24 @@ namespace v2rayN.Handler
} }
streamSettings.wsSettings = wsSettings; streamSettings.wsSettings = wsSettings;
break;
//httpupgrade
case nameof(ETransport.httpupgrade):
HttpupgradeSettings4Ray httpupgradeSettings = new();
if (!string.IsNullOrWhiteSpace(node.path))
{
httpupgradeSettings.path = node.path;
}
if (!string.IsNullOrWhiteSpace(host))
{
httpupgradeSettings.host = host;
}
streamSettings.httpupgradeSettings = httpupgradeSettings;
break; break;
//h2 //h2
case "h2": case nameof(ETransport.h2):
HttpSettings4Ray httpSettings = new(); HttpSettings4Ray httpSettings = new();
if (!string.IsNullOrWhiteSpace(host)) if (!string.IsNullOrWhiteSpace(host))
@@ -621,7 +636,7 @@ namespace v2rayN.Handler
break; break;
//quic //quic
case "quic": case nameof(ETransport.quic):
QuicSettings4Ray quicsettings = new() QuicSettings4Ray quicsettings = new()
{ {
security = host, security = host,
@@ -645,7 +660,7 @@ namespace v2rayN.Handler
} }
break; break;
case "grpc": case nameof(ETransport.grpc):
GrpcSettings4Ray grpcSettings = new() GrpcSettings4Ray grpcSettings = new()
{ {
serviceName = node.path, serviceName = node.path,
@@ -764,7 +779,7 @@ namespace v2rayN.Handler
{ {
if (_config.guiItem.enableStatistics) if (_config.guiItem.enableStatistics)
{ {
string tag = Global.InboundAPITagName; string tag = EInboundProtocol.api.ToString();
API4Ray apiObj = new(); API4Ray apiObj = new();
Policy4Ray policyObj = new(); Policy4Ray policyObj = new();
SystemPolicy4Ray policySystemSetting = new(); SystemPolicy4Ray policySystemSetting = new();
@@ -923,7 +938,7 @@ namespace v2rayN.Handler
v2rayConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts. v2rayConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts.
v2rayConfig.outbounds.RemoveAt(0); v2rayConfig.outbounds.RemoveAt(0);
int httpPort = LazyConfig.Instance.GetLocalPort("speedtest"); int httpPort = LazyConfig.Instance.GetLocalPort(EInboundProtocol.speedtest);
foreach (var it in selecteds) foreach (var it in selecteds)
{ {
@@ -975,9 +990,9 @@ namespace v2rayN.Handler
{ {
listen = Global.Loopback, listen = Global.Loopback,
port = port, port = port,
protocol = Global.InboundHttp protocol = EInboundProtocol.http.ToString(),
}; };
inbound.tag = Global.InboundHttp + inbound.port.ToString(); inbound.tag = inbound.protocol + inbound.port.ToString();
v2rayConfig.inbounds.Add(inbound); v2rayConfig.inbounds.Add(inbound);
//outbound //outbound

View File

@@ -4,6 +4,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Sockets; using System.Net.Sockets;
using v2rayN.Model;
using v2rayN.Resx; using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
@@ -311,7 +312,7 @@ namespace v2rayN.Handler
{ {
return null; return null;
} }
var httpPort = LazyConfig.Instance.GetLocalPort(Global.InboundHttp); var httpPort = LazyConfig.Instance.GetLocalPort(EInboundProtocol.http);
if (!SocketCheck(Global.Loopback, httpPort)) if (!SocketCheck(Global.Loopback, httpPort))
{ {
return null; return null;

View File

@@ -19,7 +19,7 @@ namespace v2rayN.Handler
{ {
if (_statePort is null) if (_statePort is null)
{ {
_statePort = Utile.GetFreePort(GetLocalPort(Global.InboundAPITagName)); _statePort = Utile.GetFreePort(GetLocalPort(EInboundProtocol.api));
} }
return _statePort.Value; return _statePort.Value;
@@ -50,20 +50,10 @@ namespace v2rayN.Handler
return _config; return _config;
} }
public int GetLocalPort(string protocol) public int GetLocalPort(EInboundProtocol protocol)
{ {
var localPort = _config.inbound.FirstOrDefault(t => t.protocol == Global.InboundSocks)?.localPort ?? 10808; var localPort = _config.inbound.FirstOrDefault(t => t.protocol == nameof(EInboundProtocol.socks))?.localPort ?? 10808;
return protocol.ToLower() switch return localPort + (int)protocol;
{
Global.InboundSocks => localPort,
Global.InboundHttp => localPort + 1,
Global.InboundSocks2 => localPort + 2,
Global.InboundHttp2 => localPort + 3,
"pac" => localPort + 4,
Global.InboundAPITagName => localPort + 11,
"speedtest" => localPort + 21,
_ => localPort,
};
} }
public void AddProcess(IntPtr processHandle) public void AddProcess(IntPtr processHandle)

View File

@@ -51,18 +51,18 @@ namespace v2rayN.Handler
public System.Windows.Media.ImageSource GetAppIcon(Config config) public System.Windows.Media.ImageSource GetAppIcon(Config config)
{ {
int index = 1; int index = 1;
switch ((int)config.sysProxyType) switch (config.sysProxyType)
{ {
case 0: case ESysProxyType.ForcedClear:
index = 1; index = 1;
break; break;
case 1: case ESysProxyType.ForcedChange:
case 3: case ESysProxyType.Pac:
index = 2; index = 2;
break; break;
case 2: case ESysProxyType.Unchanged:
index = 3; index = 3;
break; break;
} }

View File

@@ -310,11 +310,11 @@ namespace v2rayN.Handler
dicQuery.Add("spx", Utile.UrlEncode(item.spiderX)); dicQuery.Add("spx", Utile.UrlEncode(item.spiderX));
} }
dicQuery.Add("type", !Utile.IsNullOrEmpty(item.network) ? item.network : "tcp"); dicQuery.Add("type", !Utile.IsNullOrEmpty(item.network) ? item.network : nameof(ETransport.tcp));
switch (item.network) switch (item.network)
{ {
case "tcp": case nameof(ETransport.tcp):
dicQuery.Add("headerType", !Utile.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None); dicQuery.Add("headerType", !Utile.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None);
if (!Utile.IsNullOrEmpty(item.requestHost)) if (!Utile.IsNullOrEmpty(item.requestHost))
{ {
@@ -322,7 +322,7 @@ namespace v2rayN.Handler
} }
break; break;
case "kcp": case nameof(ETransport.kcp):
dicQuery.Add("headerType", !Utile.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None); dicQuery.Add("headerType", !Utile.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None);
if (!Utile.IsNullOrEmpty(item.path)) if (!Utile.IsNullOrEmpty(item.path))
{ {
@@ -330,7 +330,8 @@ namespace v2rayN.Handler
} }
break; break;
case "ws": case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
if (!Utile.IsNullOrEmpty(item.requestHost)) if (!Utile.IsNullOrEmpty(item.requestHost))
{ {
dicQuery.Add("host", Utile.UrlEncode(item.requestHost)); dicQuery.Add("host", Utile.UrlEncode(item.requestHost));
@@ -341,9 +342,9 @@ namespace v2rayN.Handler
} }
break; break;
case "http": case nameof(ETransport.http):
case "h2": case nameof(ETransport.h2):
dicQuery["type"] = "http"; dicQuery["type"] = nameof(ETransport.http);
if (!Utile.IsNullOrEmpty(item.requestHost)) if (!Utile.IsNullOrEmpty(item.requestHost))
{ {
dicQuery.Add("host", Utile.UrlEncode(item.requestHost)); dicQuery.Add("host", Utile.UrlEncode(item.requestHost));
@@ -354,13 +355,13 @@ namespace v2rayN.Handler
} }
break; break;
case "quic": case nameof(ETransport.quic):
dicQuery.Add("headerType", !Utile.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None); dicQuery.Add("headerType", !Utile.IsNullOrEmpty(item.headerType) ? item.headerType : Global.None);
dicQuery.Add("quicSecurity", Utile.UrlEncode(item.requestHost)); dicQuery.Add("quicSecurity", Utile.UrlEncode(item.requestHost));
dicQuery.Add("key", Utile.UrlEncode(item.path)); dicQuery.Add("key", Utile.UrlEncode(item.path));
break; break;
case "grpc": case nameof(ETransport.grpc):
if (!Utile.IsNullOrEmpty(item.path)) if (!Utile.IsNullOrEmpty(item.path))
{ {
dicQuery.Add("serviceName", Utile.UrlEncode(item.path)); dicQuery.Add("serviceName", Utile.UrlEncode(item.path));
@@ -587,7 +588,7 @@ namespace v2rayN.Handler
} }
switch (i.streamSecurity) switch (i.streamSecurity)
{ {
case "tls": case Global.StreamSecurity:
break; break;
default: default:
@@ -599,32 +600,33 @@ namespace v2rayN.Handler
i.network = m.Groups["network"].Value; i.network = m.Groups["network"].Value;
switch (i.network) switch (i.network)
{ {
case "tcp": case nameof(ETransport.tcp):
string t1 = query["type"] ?? Global.None; string t1 = query["type"] ?? Global.None;
i.headerType = t1; i.headerType = t1;
break; break;
case "kcp": case nameof(ETransport.kcp):
i.headerType = query["type"] ?? Global.None; i.headerType = query["type"] ?? Global.None;
break; break;
case "ws": case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
string p1 = query["path"] ?? "/"; string p1 = query["path"] ?? "/";
string h1 = query["host"] ?? ""; string h1 = query["host"] ?? "";
i.requestHost = Utile.UrlDecode(h1); i.requestHost = Utile.UrlDecode(h1);
i.path = p1; i.path = p1;
break; break;
case "http": case nameof(ETransport.http):
case "h2": case nameof(ETransport.h2):
i.network = "h2"; i.network = nameof(ETransport.h2);
string p2 = query["path"] ?? "/"; string p2 = query["path"] ?? "/";
string h2 = query["host"] ?? ""; string h2 = query["host"] ?? "";
i.requestHost = Utile.UrlDecode(h2); i.requestHost = Utile.UrlDecode(h2);
i.path = p2; i.path = p2;
break; break;
case "quic": case nameof(ETransport.quic):
string s = query["security"] ?? Global.None; string s = query["security"] ?? Global.None;
string k = query["key"] ?? ""; string k = query["key"] ?? "";
string t3 = query["type"] ?? Global.None; string t3 = query["type"] ?? Global.None;
@@ -945,39 +947,40 @@ namespace v2rayN.Handler
item.shortId = Utile.UrlDecode(query["sid"] ?? ""); item.shortId = Utile.UrlDecode(query["sid"] ?? "");
item.spiderX = Utile.UrlDecode(query["spx"] ?? ""); item.spiderX = Utile.UrlDecode(query["spx"] ?? "");
item.network = query["type"] ?? "tcp"; item.network = query["type"] ?? nameof(ETransport.tcp);
switch (item.network) switch (item.network)
{ {
case "tcp": case nameof(ETransport.tcp):
item.headerType = query["headerType"] ?? Global.None; item.headerType = query["headerType"] ?? Global.None;
item.requestHost = Utile.UrlDecode(query["host"] ?? ""); item.requestHost = Utile.UrlDecode(query["host"] ?? "");
break; break;
case "kcp": case nameof(ETransport.kcp):
item.headerType = query["headerType"] ?? Global.None; item.headerType = query["headerType"] ?? Global.None;
item.path = Utile.UrlDecode(query["seed"] ?? ""); item.path = Utile.UrlDecode(query["seed"] ?? "");
break; break;
case "ws": case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
item.requestHost = Utile.UrlDecode(query["host"] ?? ""); item.requestHost = Utile.UrlDecode(query["host"] ?? "");
item.path = Utile.UrlDecode(query["path"] ?? "/"); item.path = Utile.UrlDecode(query["path"] ?? "/");
break; break;
case "http": case nameof(ETransport.http):
case "h2": case nameof(ETransport.h2):
item.network = "h2"; item.network = nameof(ETransport.h2);
item.requestHost = Utile.UrlDecode(query["host"] ?? ""); item.requestHost = Utile.UrlDecode(query["host"] ?? "");
item.path = Utile.UrlDecode(query["path"] ?? "/"); item.path = Utile.UrlDecode(query["path"] ?? "/");
break; break;
case "quic": case nameof(ETransport.quic):
item.headerType = query["headerType"] ?? Global.None; item.headerType = query["headerType"] ?? Global.None;
item.requestHost = query["quicSecurity"] ?? Global.None; item.requestHost = query["quicSecurity"] ?? Global.None;
item.path = Utile.UrlDecode(query["key"] ?? ""); item.path = Utile.UrlDecode(query["key"] ?? "");
break; break;
case "grpc": case nameof(ETransport.grpc):
item.path = Utile.UrlDecode(query["serviceName"] ?? ""); item.path = Utile.UrlDecode(query["serviceName"] ?? "");
item.headerType = Utile.UrlDecode(query["mode"] ?? Global.GrpcGunMode); item.headerType = Utile.UrlDecode(query["mode"] ?? Global.GrpcGunMode);
break; break;

View File

@@ -1,6 +1,4 @@
using System.Net; using v2rayN.Model;
using System.Net.Sockets;
using v2rayN.Model;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {

View File

@@ -41,9 +41,9 @@ namespace v2rayN.Handler
try try
{ {
int port = LazyConfig.Instance.GetLocalPort(Global.InboundHttp); int port = LazyConfig.Instance.GetLocalPort(EInboundProtocol.http);
int portSocks = LazyConfig.Instance.GetLocalPort(Global.InboundSocks); int portSocks = LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks);
int portPac = LazyConfig.Instance.GetLocalPort(ESysProxyType.Pac.ToString()); int portPac = LazyConfig.Instance.GetLocalPort(EInboundProtocol.pac);
if (port <= 0) if (port <= 0)
{ {
return false; return false;

View File

@@ -602,54 +602,6 @@ namespace v2rayN.Handler
await AskToDownload(downloadHandle, url, false); await AskToDownload(downloadHandle, url, false);
} }
private async Task UpdateGeoFile4Singbox(string geoName, Config config, bool needStop, Action<bool, string> update)
{
_config = config;
_updateFunc = update;
var url = string.Format(Global.SingboxGeoUrl, geoName);
DownloadHandle downloadHandle = new();
downloadHandle.UpdateCompleted += async (sender2, args) =>
{
if (args.Success)
{
_updateFunc(false, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, geoName));
var coreHandler = Locator.Current.GetService<CoreHandler>();
try
{
if (needStop)
{
coreHandler?.CoreStop();
await Task.Delay(3000);
}
string fileName = Utile.GetTempPath(Utile.GetDownloadFileName(url));
if (File.Exists(fileName))
{
string targetPath = Utile.GetConfigPath($"{geoName}.db");
File.Copy(fileName, targetPath, true);
File.Delete(fileName);
}
if (needStop) coreHandler?.LoadCore();
}
catch (Exception ex)
{
_updateFunc(false, ex.Message);
}
}
else
{
_updateFunc(false, args.Msg);
}
};
downloadHandle.Error += (sender2, args) =>
{
_updateFunc(false, args.GetException().Message);
};
await AskToDownload(downloadHandle, url, false);
}
#endregion private #endregion private
} }
} }

View File

@@ -0,0 +1,13 @@
namespace v2rayN.Model
{
public enum EInboundProtocol
{
socks = 0,
http,
socks2,
http2,
pac,
api,
speedtest = 21
}
}

View File

@@ -0,0 +1,14 @@
namespace v2rayN.Model
{
public enum ETransport
{
tcp,
kcp,
ws,
httpupgrade,
h2,
http,
quic,
grpc
}
}

View File

@@ -158,14 +158,14 @@
public class Transport4Sbox public class Transport4Sbox
{ {
public string type { get; set; } public string? type { get; set; }
public List<string>? host { get; set; } public object? host { get; set; }
public string? path { get; set; } public string? path { get; set; }
public Headers4Sbox? headers { get; set; } public Headers4Sbox? headers { get; set; }
public string service_name { get; set; } public string? service_name { get; set; }
public string idle_timeout { get; set; } public string? idle_timeout { get; set; }
public string ping_timeout { get; set; } public string? ping_timeout { get; set; }
public bool? permit_without_stream { get; set; } public bool? permit_without_stream { get; set; }
} }

View File

@@ -431,6 +431,11 @@ namespace v2rayN.Model
/// </summary> /// </summary>
public WsSettings4Ray wsSettings { get; set; } public WsSettings4Ray wsSettings { get; set; }
/// <summary>
///
/// </summary>
public HttpupgradeSettings4Ray? httpupgradeSettings { get; set; }
/// <summary> /// <summary>
/// h2传输额外设置 /// h2传输额外设置
/// </summary> /// </summary>
@@ -583,6 +588,19 @@ namespace v2rayN.Model
public string UserAgent { get; set; } public string UserAgent { get; set; }
} }
public class HttpupgradeSettings4Ray
{
/// <summary>
///
/// </summary>
public string? path { get; set; }
/// <summary>
///
/// </summary>
public string? host { get; set; }
}
public class HttpSettings4Ray public class HttpSettings4Ray
{ {
/// <summary> /// <summary>

View File

@@ -466,7 +466,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Previous proxy remakrs 的本地化字符串。 /// 查找类似 Previous proxy remarks 的本地化字符串。
/// </summary> /// </summary>
public static string LvPrevProfile { public static string LvPrevProfile {
get { get {
@@ -2852,7 +2852,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 HTTP port=SOCKS port+1 的本地化字符串。 /// 查找类似 HTTP port=SOCKS port+1;Pac port=SOCKS port+4;API port=SOCKS port+5; 的本地化字符串。
/// </summary> /// </summary>
public static string TbSettingsSocksPortTip { public static string TbSettingsSocksPortTip {
get { get {
@@ -3203,7 +3203,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 *ws path 的本地化字符串。 /// 查找类似 *ws/httpupgrade path 的本地化字符串。
/// </summary> /// </summary>
public static string TransportPathTip1 { public static string TransportPathTip1 {
get { get {
@@ -3257,7 +3257,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 *ws host 的本地化字符串。 /// 查找类似 *ws/httpupgrade host 的本地化字符串。
/// </summary> /// </summary>
public static string TransportRequestHostTip2 { public static string TransportRequestHostTip2 {
get { get {

View File

@@ -359,7 +359,7 @@
<value>Please fill in the correct custom DNS</value> <value>Please fill in the correct custom DNS</value>
</data> </data>
<data name="TransportPathTip1" xml:space="preserve"> <data name="TransportPathTip1" xml:space="preserve">
<value>*ws path</value> <value>*ws/httpupgrade path</value>
</data> </data>
<data name="TransportPathTip2" xml:space="preserve"> <data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value> <value>*h2 path</value>
@@ -374,7 +374,7 @@
<value>*http host Separated by commas (,)</value> <value>*http host Separated by commas (,)</value>
</data> </data>
<data name="TransportRequestHostTip2" xml:space="preserve"> <data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws host</value> <value>*ws/httpupgrade host</value>
</data> </data>
<data name="TransportRequestHostTip3" xml:space="preserve"> <data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host Separated by commas (,)</value> <value>*h2 host Separated by commas (,)</value>
@@ -1037,7 +1037,7 @@
<value>Copy the font TTF/TTC file to the directory guiFonts, restart the settings</value> <value>Copy the font TTF/TTC file to the directory guiFonts, restart the settings</value>
</data> </data>
<data name="TbSettingsSocksPortTip" xml:space="preserve"> <data name="TbSettingsSocksPortTip" xml:space="preserve">
<value>HTTP port=SOCKS port+1</value> <value>HTTP port=SOCKS port+1;Pac port=SOCKS port+4;API port=SOCKS port+5;</value>
</data> </data>
<data name="TbSettingsStartBootTip" xml:space="preserve"> <data name="TbSettingsStartBootTip" xml:space="preserve">
<value>Set this with admin privileges, get admin privileges after startup</value> <value>Set this with admin privileges, get admin privileges after startup</value>
@@ -1151,7 +1151,7 @@
<value>Congestion control</value> <value>Congestion control</value>
</data> </data>
<data name="LvPrevProfile" xml:space="preserve"> <data name="LvPrevProfile" xml:space="preserve">
<value>Previous proxy remakrs</value> <value>Previous proxy remarks</value>
</data> </data>
<data name="LvNextProfile" xml:space="preserve"> <data name="LvNextProfile" xml:space="preserve">
<value>Next proxy remarks</value> <value>Next proxy remarks</value>

View File

@@ -359,7 +359,7 @@
<value>请填写正确的自定义DNS</value> <value>请填写正确的自定义DNS</value>
</data> </data>
<data name="TransportPathTip1" xml:space="preserve"> <data name="TransportPathTip1" xml:space="preserve">
<value>*ws path</value> <value>*ws/httpupgrade path</value>
</data> </data>
<data name="TransportPathTip2" xml:space="preserve"> <data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value> <value>*h2 path</value>
@@ -374,7 +374,7 @@
<value>*http host中间逗号(,)分隔</value> <value>*http host中间逗号(,)分隔</value>
</data> </data>
<data name="TransportRequestHostTip2" xml:space="preserve"> <data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws host</value> <value>*ws/httpupgrade host</value>
</data> </data>
<data name="TransportRequestHostTip3" xml:space="preserve"> <data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host中间逗号(,)分隔</value> <value>*h2 host中间逗号(,)分隔</value>
@@ -1037,7 +1037,7 @@
<value>拷贝字体TTF/TTC文件到目录guiFonts重启设置</value> <value>拷贝字体TTF/TTC文件到目录guiFonts重启设置</value>
</data> </data>
<data name="TbSettingsSocksPortTip" xml:space="preserve"> <data name="TbSettingsSocksPortTip" xml:space="preserve">
<value>http端口=socks端口+1</value> <value>http端口=socks端口+1Pac端口=socks端口+4API端口=socks端口+5</value>
</data> </data>
<data name="TbSettingsStartBootTip" xml:space="preserve"> <data name="TbSettingsStartBootTip" xml:space="preserve">
<value>以管理员权限设置此项,在启动后获得管理员权限</value> <value>以管理员权限设置此项,在启动后获得管理员权限</value>

View File

@@ -358,7 +358,7 @@
<value>請填寫正確的自訂DNS</value> <value>請填寫正確的自訂DNS</value>
</data> </data>
<data name="TransportPathTip1" xml:space="preserve"> <data name="TransportPathTip1" xml:space="preserve">
<value>*ws path</value> <value>*ws/httpupgrade path</value>
</data> </data>
<data name="TransportPathTip2" xml:space="preserve"> <data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value> <value>*h2 path</value>
@@ -373,7 +373,7 @@
<value>*http host中間逗號(,)分隔</value> <value>*http host中間逗號(,)分隔</value>
</data> </data>
<data name="TransportRequestHostTip2" xml:space="preserve"> <data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws host</value> <value>*ws/httpupgrade host</value>
</data> </data>
<data name="TransportRequestHostTip3" xml:space="preserve"> <data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host中間逗號(,)分隔</value> <value>*h2 host中間逗號(,)分隔</value>

View File

@@ -1811,7 +1811,7 @@ namespace v2rayN.ViewModels
public void InboundDisplayStaus() public void InboundDisplayStaus()
{ {
StringBuilder sb = new(); StringBuilder sb = new();
sb.Append($"[{Global.InboundSocks}:{LazyConfig.Instance.GetLocalPort(Global.InboundSocks)}]"); sb.Append($"[{EInboundProtocol.socks}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks)}]");
sb.Append(" | "); sb.Append(" | ");
//if (_config.sysProxyType == ESysProxyType.ForcedChange) //if (_config.sysProxyType == ESysProxyType.ForcedChange)
//{ //{
@@ -1819,7 +1819,7 @@ namespace v2rayN.ViewModels
//} //}
//else //else
//{ //{
sb.Append($"[{Global.InboundHttp}:{LazyConfig.Instance.GetLocalPort(Global.InboundHttp)}]"); sb.Append($"[{EInboundProtocol.http}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.http)}]");
//} //}
InboundDisplay = $"{ResUI.LabLocal}:{sb}"; InboundDisplay = $"{ResUI.LabLocal}:{sb}";
@@ -1828,9 +1828,9 @@ namespace v2rayN.ViewModels
if (_config.inbound[0].newPort4LAN) if (_config.inbound[0].newPort4LAN)
{ {
StringBuilder sb2 = new(); StringBuilder sb2 = new();
sb2.Append($"[{Global.InboundSocks}:{LazyConfig.Instance.GetLocalPort(Global.InboundSocks2)}]"); sb2.Append($"[{EInboundProtocol.socks}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks2)}]");
sb2.Append(" | "); sb2.Append(" | ");
sb2.Append($"[{Global.InboundHttp}:{LazyConfig.Instance.GetLocalPort(Global.InboundHttp2)}]"); sb2.Append($"[{EInboundProtocol.http}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.http2)}]");
InboundLanDisplay = $"{ResUI.LabLAN}:{sb2}"; InboundLanDisplay = $"{ResUI.LabLAN}:{sb2}";
} }
else else

View File

@@ -1,12 +1,12 @@
<reactiveui:ReactiveWindow <reactiveui:ReactiveWindow
x:Class="v2rayN.Views.AddServer2Window" x:Class="v2rayN.Views.AddServer2Window"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveui="http://reactiveui.net" xmlns:reactiveui="http://reactiveui.net"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:resx="clr-namespace:v2rayN.Resx" xmlns:resx="clr-namespace:v2rayN.Resx"
xmlns:vms="clr-namespace:v2rayN.ViewModels" xmlns:vms="clr-namespace:v2rayN.ViewModels"
Title="v2rayN" Title="v2rayN"

View File

@@ -1,12 +1,12 @@
<reactiveui:ReactiveWindow <reactiveui:ReactiveWindow
x:Class="v2rayN.Views.AddServerWindow" x:Class="v2rayN.Views.AddServerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveui="http://reactiveui.net" xmlns:reactiveui="http://reactiveui.net"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:resx="clr-namespace:v2rayN.Resx" xmlns:resx="clr-namespace:v2rayN.Resx"
xmlns:vms="clr-namespace:v2rayN.ViewModels" xmlns:vms="clr-namespace:v2rayN.ViewModels"
Title="{x:Static resx:ResUI.menuServers}" Title="{x:Static resx:ResUI.menuServers}"

View File

@@ -279,12 +279,12 @@ namespace v2rayN.Views
return; return;
} }
if (network == Global.DefaultNetwork) if (network == nameof(ETransport.tcp))
{ {
cmbHeaderType.Items.Add(Global.None); cmbHeaderType.Items.Add(Global.None);
cmbHeaderType.Items.Add(Global.TcpHeaderHttp); cmbHeaderType.Items.Add(Global.TcpHeaderHttp);
} }
else if (network is "kcp" or "quic") else if (network is nameof(ETransport.kcp) or nameof(ETransport.quic))
{ {
cmbHeaderType.Items.Add(Global.None); cmbHeaderType.Items.Add(Global.None);
Global.KcpHeaderTypes.ForEach(it => Global.KcpHeaderTypes.ForEach(it =>
@@ -292,7 +292,7 @@ namespace v2rayN.Views
cmbHeaderType.Items.Add(it); cmbHeaderType.Items.Add(it);
}); });
} }
else if (network == "grpc") else if (network == nameof(ETransport.grpc))
{ {
cmbHeaderType.Items.Add(Global.GrpcGunMode); cmbHeaderType.Items.Add(Global.GrpcGunMode);
cmbHeaderType.Items.Add(Global.GrpcMultiMode); cmbHeaderType.Items.Add(Global.GrpcMultiMode);
@@ -318,33 +318,34 @@ namespace v2rayN.Views
switch (network) switch (network)
{ {
case Global.DefaultNetwork: case nameof(ETransport.tcp):
tipRequestHost.Text = ResUI.TransportRequestHostTip1; tipRequestHost.Text = ResUI.TransportRequestHostTip1;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip1; tipHeaderType.Text = ResUI.TransportHeaderTypeTip1;
break; break;
case "kcp": case nameof(ETransport.kcp):
tipHeaderType.Text = ResUI.TransportHeaderTypeTip2; tipHeaderType.Text = ResUI.TransportHeaderTypeTip2;
tipPath.Text = ResUI.TransportPathTip5; tipPath.Text = ResUI.TransportPathTip5;
break; break;
case "ws": case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
tipRequestHost.Text = ResUI.TransportRequestHostTip2; tipRequestHost.Text = ResUI.TransportRequestHostTip2;
tipPath.Text = ResUI.TransportPathTip1; tipPath.Text = ResUI.TransportPathTip1;
break; break;
case "h2": case nameof(ETransport.h2):
tipRequestHost.Text = ResUI.TransportRequestHostTip3; tipRequestHost.Text = ResUI.TransportRequestHostTip3;
tipPath.Text = ResUI.TransportPathTip2; tipPath.Text = ResUI.TransportPathTip2;
break; break;
case "quic": case nameof(ETransport.quic):
tipRequestHost.Text = ResUI.TransportRequestHostTip4; tipRequestHost.Text = ResUI.TransportRequestHostTip4;
tipPath.Text = ResUI.TransportPathTip3; tipPath.Text = ResUI.TransportPathTip3;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip3; tipHeaderType.Text = ResUI.TransportHeaderTypeTip3;
break; break;
case "grpc": case nameof(ETransport.grpc):
tipPath.Text = ResUI.TransportPathTip4; tipPath.Text = ResUI.TransportPathTip4;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip4; tipHeaderType.Text = ResUI.TransportHeaderTypeTip4;
labHeaderType.Visibility = Visibility.Hidden; labHeaderType.Visibility = Visibility.Hidden;

View File

@@ -1,17 +1,17 @@
<reactiveui:ReactiveWindow <reactiveui:ReactiveWindow
x:Class="v2rayN.Views.MainWindow" x:Class="v2rayN.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:reactiveui="http://reactiveui.net"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tb="clr-namespace:H.NotifyIcon;assembly=H.NotifyIcon.Wpf"
xmlns:base="clr-namespace:v2rayN.Base" xmlns:base="clr-namespace:v2rayN.Base"
xmlns:conv="clr-namespace:v2rayN.Converters" xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:v2rayN.Views"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveui="http://reactiveui.net"
xmlns:resx="clr-namespace:v2rayN.Resx" xmlns:resx="clr-namespace:v2rayN.Resx"
xmlns:tb="clr-namespace:H.NotifyIcon;assembly=H.NotifyIcon.Wpf"
xmlns:vms="clr-namespace:v2rayN.ViewModels" xmlns:vms="clr-namespace:v2rayN.ViewModels"
xmlns:local="clr-namespace:v2rayN.Views"
Title="v2rayN" Title="v2rayN"
Width="900" Width="900"
Height="700" Height="700"

View File

@@ -1,12 +1,12 @@
<reactiveui:ReactiveWindow <reactiveui:ReactiveWindow
x:Class="v2rayN.Views.SubEditWindow" x:Class="v2rayN.Views.SubEditWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveui="http://reactiveui.net" xmlns:reactiveui="http://reactiveui.net"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:resx="clr-namespace:v2rayN.Resx" xmlns:resx="clr-namespace:v2rayN.Resx"
xmlns:vms="clr-namespace:v2rayN.ViewModels" xmlns:vms="clr-namespace:v2rayN.ViewModels"
Title="{x:Static resx:ResUI.menuSubSetting}" Title="{x:Static resx:ResUI.menuSubSetting}"

View File

@@ -10,7 +10,7 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>v2rayN.ico</ApplicationIcon> <ApplicationIcon>v2rayN.ico</ApplicationIcon>
<Copyright>Copyright © 2017-2024 (GPLv3)</Copyright> <Copyright>Copyright © 2017-2024 (GPLv3)</Copyright>
<FileVersion>6.38</FileVersion> <FileVersion>6.39</FileVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion> <SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
</PropertyGroup> </PropertyGroup>