mirror of https://github.com/2dust/v2rayN
Refactor
parent
9427340ab7
commit
0e7bfa65de
|
@ -69,13 +69,7 @@ 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
|
||||||
{
|
{
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -121,7 +121,7 @@ namespace v2rayN.Handler
|
||||||
};
|
};
|
||||||
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;
|
||||||
|
@ -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,7 +421,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -433,8 +433,8 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
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 +445,12 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "quic":
|
case nameof(ETransport.quic):
|
||||||
transport.type = "quic";
|
transport.type = nameof(ETransport.quic);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "grpc":
|
case nameof(ETransport.grpc):
|
||||||
transport.type = "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");
|
||||||
|
@ -881,7 +881,7 @@ namespace v2rayN.Handler
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,11 +111,11 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
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], Global.InboundSocks2, 2, 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], Global.InboundHttp2, 3, false);
|
||||||
inbound4.listen = "0.0.0.0";
|
inbound4.listen = "0.0.0.0";
|
||||||
v2rayConfig.inbounds.Add(inbound4);
|
v2rayConfig.inbounds.Add(inbound4);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -608,7 +608,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
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 +621,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 +645,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "grpc":
|
case nameof(ETransport.grpc):
|
||||||
GrpcSettings4Ray grpcSettings = new()
|
GrpcSettings4Ray grpcSettings = new()
|
||||||
{
|
{
|
||||||
serviceName = node.path,
|
serviceName = node.path,
|
||||||
|
@ -923,7 +923,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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "ws":
|
case nameof(ETransport.ws):
|
||||||
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 +341,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 +354,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));
|
||||||
|
@ -599,32 +599,32 @@ 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):
|
||||||
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 +945,39 @@ 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):
|
||||||
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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
namespace v2rayN.Model
|
||||||
|
{
|
||||||
|
public enum EInboundProtocol
|
||||||
|
{
|
||||||
|
socks = 0,
|
||||||
|
http,
|
||||||
|
socks2,
|
||||||
|
http2,
|
||||||
|
pac,
|
||||||
|
api = 11,
|
||||||
|
speedtest = 21
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
namespace v2rayN.Model
|
||||||
|
{
|
||||||
|
public enum ETransport
|
||||||
|
{
|
||||||
|
tcp,
|
||||||
|
kcp,
|
||||||
|
ws,
|
||||||
|
h2,
|
||||||
|
http,
|
||||||
|
quic,
|
||||||
|
grpc
|
||||||
|
}
|
||||||
|
}
|
|
@ -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($"[{Global.InboundSocks}:{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($"[{Global.InboundHttp}:{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($"[{Global.InboundSocks}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks2)}]");
|
||||||
sb2.Append(" | ");
|
sb2.Append(" | ");
|
||||||
sb2.Append($"[{Global.InboundHttp}:{LazyConfig.Instance.GetLocalPort(Global.InboundHttp2)}]");
|
sb2.Append($"[{Global.InboundHttp}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.http2)}]");
|
||||||
InboundLanDisplay = $"{ResUI.LabLAN}:{sb2}";
|
InboundLanDisplay = $"{ResUI.LabLAN}:{sb2}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -284,7 +284,7 @@ namespace v2rayN.Views
|
||||||
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,33 @@ 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):
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue