mirror of https://github.com/2dust/v2rayN
Refactor
parent
dcdc63785a
commit
70584aff9d
|
@ -56,10 +56,6 @@ namespace v2rayN
|
|||
public const string BlockTag = "block";
|
||||
public const string StreamSecurity = "tls";
|
||||
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 InboundAPITagName = "api";
|
||||
public const string InboundAPIProtocol = "dokodemo-door";
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace v2rayN.Handler
|
|||
config.inbound = new List<InItem>();
|
||||
InItem inItem = new()
|
||||
{
|
||||
protocol = Global.InboundSocks,
|
||||
protocol = EInboundProtocol.socks.ToString(),
|
||||
localPort = 10808,
|
||||
udpEnabled = true,
|
||||
sniffingEnabled = true,
|
||||
|
@ -75,7 +75,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
if (config.inbound.Count > 0)
|
||||
{
|
||||
config.inbound[0].protocol = Global.InboundSocks;
|
||||
config.inbound[0].protocol = EInboundProtocol.socks.ToString();
|
||||
}
|
||||
}
|
||||
if (config.routingBasicItem == null)
|
||||
|
|
|
@ -115,8 +115,8 @@ namespace v2rayN.Handler
|
|||
{
|
||||
var inbound = new Inbound4Sbox()
|
||||
{
|
||||
type = Global.InboundSocks,
|
||||
tag = Global.InboundSocks,
|
||||
type = EInboundProtocol.socks.ToString(),
|
||||
tag = EInboundProtocol.socks.ToString(),
|
||||
listen = Global.Loopback,
|
||||
};
|
||||
singboxConfig.inbounds.Add(inbound);
|
||||
|
@ -136,18 +136,18 @@ namespace v2rayN.Handler
|
|||
}
|
||||
|
||||
//http
|
||||
var inbound2 = GetInbound(inbound, Global.InboundHttp, 1, false);
|
||||
var inbound2 = GetInbound(inbound, EInboundProtocol.http, false);
|
||||
singboxConfig.inbounds.Add(inbound2);
|
||||
|
||||
if (_config.inbound[0].allowLANConn)
|
||||
{
|
||||
if (_config.inbound[0].newPort4LAN)
|
||||
{
|
||||
var inbound3 = GetInbound(inbound, Global.InboundSocks2, 2, true);
|
||||
var inbound3 = GetInbound(inbound, EInboundProtocol.socks2, true);
|
||||
inbound3.listen = "::";
|
||||
singboxConfig.inbounds.Add(inbound3);
|
||||
|
||||
var inbound4 = GetInbound(inbound, Global.InboundHttp2, 3, false);
|
||||
var inbound4 = GetInbound(inbound, EInboundProtocol.http2, false);
|
||||
inbound4.listen = "::";
|
||||
singboxConfig.inbounds.Add(inbound4);
|
||||
|
||||
|
@ -198,12 +198,12 @@ namespace v2rayN.Handler
|
|||
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);
|
||||
inbound.tag = tag;
|
||||
inbound.listen_port = inItem.listen_port + offset;
|
||||
inbound.type = bSocks ? Global.InboundSocks : Global.InboundHttp;
|
||||
inbound.tag = protocol.ToString();
|
||||
inbound.listen_port = inItem.listen_port + (int)protocol;
|
||||
inbound.type = bSocks ? EInboundProtocol.socks.ToString() : EInboundProtocol.http.ToString();
|
||||
return inbound;
|
||||
}
|
||||
|
||||
|
@ -933,9 +933,9 @@ namespace v2rayN.Handler
|
|||
{
|
||||
listen = Global.Loopback,
|
||||
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);
|
||||
|
||||
//outbound
|
||||
|
|
|
@ -100,22 +100,22 @@ namespace v2rayN.Handler
|
|||
{
|
||||
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);
|
||||
|
||||
//http
|
||||
Inbounds4Ray? inbound2 = GetInbound(_config.inbound[0], Global.InboundHttp, 1, false);
|
||||
Inbounds4Ray? inbound2 = GetInbound(_config.inbound[0], EInboundProtocol.http, false);
|
||||
v2rayConfig.inbounds.Add(inbound2);
|
||||
|
||||
if (_config.inbound[0].allowLANConn)
|
||||
{
|
||||
if (_config.inbound[0].newPort4LAN)
|
||||
{
|
||||
var inbound3 = GetInbound(_config.inbound[0], Global.InboundSocks2, 2, true);
|
||||
var inbound3 = GetInbound(_config.inbound[0], EInboundProtocol.socks2, true);
|
||||
inbound3.listen = "0.0.0.0";
|
||||
v2rayConfig.inbounds.Add(inbound3);
|
||||
|
||||
var inbound4 = GetInbound(_config.inbound[0], Global.InboundHttp2, 3, false);
|
||||
var inbound4 = GetInbound(_config.inbound[0], EInboundProtocol.http2, false);
|
||||
inbound4.listen = "0.0.0.0";
|
||||
v2rayConfig.inbounds.Add(inbound4);
|
||||
|
||||
|
@ -143,7 +143,7 @@ namespace v2rayN.Handler
|
|||
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);
|
||||
if (Utile.IsNullOrEmpty(result))
|
||||
|
@ -156,9 +156,9 @@ namespace v2rayN.Handler
|
|||
{
|
||||
return null;
|
||||
}
|
||||
inbound.tag = tag;
|
||||
inbound.port = inItem.localPort + offset;
|
||||
inbound.protocol = bSocks ? Global.InboundSocks : Global.InboundHttp;
|
||||
inbound.tag = protocol.ToString();
|
||||
inbound.port = inItem.localPort + (int)protocol;
|
||||
inbound.protocol = bSocks ? EInboundProtocol.socks.ToString() : EInboundProtocol.http.ToString();
|
||||
inbound.settings.udp = inItem.udpEnabled;
|
||||
inbound.sniffing.enabled = inItem.sniffingEnabled;
|
||||
inbound.sniffing.routeOnly = inItem.routeOnly;
|
||||
|
@ -975,9 +975,9 @@ namespace v2rayN.Handler
|
|||
{
|
||||
listen = Global.Loopback,
|
||||
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);
|
||||
|
||||
//outbound
|
||||
|
|
|
@ -1811,7 +1811,7 @@ namespace v2rayN.ViewModels
|
|||
public void InboundDisplayStaus()
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
sb.Append($"[{Global.InboundSocks}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks)}]");
|
||||
sb.Append($"[{EInboundProtocol.socks}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks)}]");
|
||||
sb.Append(" | ");
|
||||
//if (_config.sysProxyType == ESysProxyType.ForcedChange)
|
||||
//{
|
||||
|
@ -1819,7 +1819,7 @@ namespace v2rayN.ViewModels
|
|||
//}
|
||||
//else
|
||||
//{
|
||||
sb.Append($"[{Global.InboundHttp}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.http)}]");
|
||||
sb.Append($"[{EInboundProtocol.http}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.http)}]");
|
||||
//}
|
||||
InboundDisplay = $"{ResUI.LabLocal}:{sb}";
|
||||
|
||||
|
@ -1828,9 +1828,9 @@ namespace v2rayN.ViewModels
|
|||
if (_config.inbound[0].newPort4LAN)
|
||||
{
|
||||
StringBuilder sb2 = new();
|
||||
sb2.Append($"[{Global.InboundSocks}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks2)}]");
|
||||
sb2.Append($"[{EInboundProtocol.socks}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks2)}]");
|
||||
sb2.Append(" | ");
|
||||
sb2.Append($"[{Global.InboundHttp}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.http2)}]");
|
||||
sb2.Append($"[{EInboundProtocol.http}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.http2)}]");
|
||||
InboundLanDisplay = $"{ResUI.LabLAN}:{sb2}";
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue