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 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 InboundAPITagName = "api";
|
||||||
public const string InboundAPIProtocol = "dokodemo-door";
|
public const string InboundAPIProtocol = "dokodemo-door";
|
||||||
|
|
|
@ -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,
|
||||||
|
@ -75,7 +75,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
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)
|
||||||
|
|
|
@ -115,8 +115,8 @@ 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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -933,9 +933,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
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
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";
|
inbound3.listen = "0.0.0.0";
|
||||||
v2rayConfig.inbounds.Add(inbound3);
|
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";
|
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;
|
||||||
|
@ -975,9 +975,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
|
||||||
|
|
|
@ -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(EInboundProtocol.socks)}]");
|
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(EInboundProtocol.http)}]");
|
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(EInboundProtocol.socks2)}]");
|
sb2.Append($"[{EInboundProtocol.socks}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks2)}]");
|
||||||
sb2.Append(" | ");
|
sb2.Append(" | ");
|
||||||
sb2.Append($"[{Global.InboundHttp}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.http2)}]");
|
sb2.Append($"[{EInboundProtocol.http}:{LazyConfig.Instance.GetLocalPort(EInboundProtocol.http2)}]");
|
||||||
InboundLanDisplay = $"{ResUI.LabLAN}:{sb2}";
|
InboundLanDisplay = $"{ResUI.LabLAN}:{sb2}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue