mirror of https://github.com/2dust/v2rayN
Optimize code
parent
31267cbc33
commit
315d4b75b2
|
@ -111,7 +111,8 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
singboxConfig.inbounds.Clear();
|
var listen = "::";
|
||||||
|
singboxConfig.inbounds = [];
|
||||||
|
|
||||||
if (!_config.tunModeItem.enableTun || (_config.tunModeItem.enableTun && _config.tunModeItem.enableExInbound))
|
if (!_config.tunModeItem.enableTun || (_config.tunModeItem.enableTun && _config.tunModeItem.enableExInbound))
|
||||||
{
|
{
|
||||||
|
@ -146,11 +147,11 @@ namespace v2rayN.Handler
|
||||||
if (_config.inbound[0].newPort4LAN)
|
if (_config.inbound[0].newPort4LAN)
|
||||||
{
|
{
|
||||||
var inbound3 = GetInbound(inbound, EInboundProtocol.socks2, true);
|
var inbound3 = GetInbound(inbound, EInboundProtocol.socks2, true);
|
||||||
inbound3.listen = "::";
|
inbound3.listen = listen;
|
||||||
singboxConfig.inbounds.Add(inbound3);
|
singboxConfig.inbounds.Add(inbound3);
|
||||||
|
|
||||||
var inbound4 = GetInbound(inbound, EInboundProtocol.http2, false);
|
var inbound4 = GetInbound(inbound, EInboundProtocol.http2, false);
|
||||||
inbound4.listen = "::";
|
inbound4.listen = listen;
|
||||||
singboxConfig.inbounds.Add(inbound4);
|
singboxConfig.inbounds.Add(inbound4);
|
||||||
|
|
||||||
//auth
|
//auth
|
||||||
|
@ -162,8 +163,8 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
inbound.listen = "::";
|
inbound.listen = listen;
|
||||||
inbound2.listen = "::";
|
inbound2.listen = listen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,8 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
v2rayConfig.inbounds = new List<Inbounds4Ray>();
|
var listen = "0.0.0.0";
|
||||||
|
v2rayConfig.inbounds = [];
|
||||||
|
|
||||||
Inbounds4Ray? inbound = GetInbound(_config.inbound[0], EInboundProtocol.socks, true);
|
Inbounds4Ray? inbound = GetInbound(_config.inbound[0], EInboundProtocol.socks, true);
|
||||||
v2rayConfig.inbounds.Add(inbound);
|
v2rayConfig.inbounds.Add(inbound);
|
||||||
|
@ -112,11 +113,11 @@ namespace v2rayN.Handler
|
||||||
if (_config.inbound[0].newPort4LAN)
|
if (_config.inbound[0].newPort4LAN)
|
||||||
{
|
{
|
||||||
var inbound3 = GetInbound(_config.inbound[0], EInboundProtocol.socks2, true);
|
var inbound3 = GetInbound(_config.inbound[0], EInboundProtocol.socks2, true);
|
||||||
inbound3.listen = "0.0.0.0";
|
inbound3.listen = listen;
|
||||||
v2rayConfig.inbounds.Add(inbound3);
|
v2rayConfig.inbounds.Add(inbound3);
|
||||||
|
|
||||||
var inbound4 = GetInbound(_config.inbound[0], EInboundProtocol.http2, false);
|
var inbound4 = GetInbound(_config.inbound[0], EInboundProtocol.http2, false);
|
||||||
inbound4.listen = "0.0.0.0";
|
inbound4.listen = listen;
|
||||||
v2rayConfig.inbounds.Add(inbound4);
|
v2rayConfig.inbounds.Add(inbound4);
|
||||||
|
|
||||||
//auth
|
//auth
|
||||||
|
@ -131,8 +132,8 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
inbound.listen = "0.0.0.0";
|
inbound.listen = listen;
|
||||||
inbound2.listen = "0.0.0.0";
|
inbound2.listen = listen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,18 +144,18 @@ namespace v2rayN.Handler
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Inbounds4Ray? GetInbound(InItem inItem, EInboundProtocol protocol, bool bSocks)
|
private Inbounds4Ray GetInbound(InItem inItem, EInboundProtocol protocol, bool bSocks)
|
||||||
{
|
{
|
||||||
string result = Utils.GetEmbedText(Global.V2raySampleInbound);
|
string result = Utils.GetEmbedText(Global.V2raySampleInbound);
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (Utils.IsNullOrEmpty(result))
|
||||||
{
|
{
|
||||||
return null;
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
var inbound = JsonUtils.Deserialize<Inbounds4Ray>(result);
|
var inbound = JsonUtils.Deserialize<Inbounds4Ray>(result);
|
||||||
if (inbound == null)
|
if (inbound == null)
|
||||||
{
|
{
|
||||||
return null;
|
return new();
|
||||||
}
|
}
|
||||||
inbound.tag = protocol.ToString();
|
inbound.tag = protocol.ToString();
|
||||||
inbound.port = inItem.localPort + (int)protocol;
|
inbound.port = inItem.localPort + (int)protocol;
|
||||||
|
|
|
@ -4,56 +4,7 @@
|
||||||
"error": "Verror.log",
|
"error": "Verror.log",
|
||||||
"loglevel": "warning"
|
"loglevel": "warning"
|
||||||
},
|
},
|
||||||
"inbounds": [{
|
"inbounds": [],
|
||||||
"tag": "tag1",
|
|
||||||
"port": 10808,
|
|
||||||
"protocol": "socks",
|
|
||||||
"listen": "127.0.0.1",
|
|
||||||
"settings": {
|
|
||||||
"auth": "noauth",
|
|
||||||
"udp": true
|
|
||||||
},
|
|
||||||
"sniffing": {
|
|
||||||
"enabled": true,
|
|
||||||
"destOverride": [
|
|
||||||
"http",
|
|
||||||
"tls"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "tag2",
|
|
||||||
"port": 10809,
|
|
||||||
"protocol": "http",
|
|
||||||
"listen": "127.0.0.1",
|
|
||||||
"settings": {
|
|
||||||
"allowTransparent": false
|
|
||||||
},
|
|
||||||
"sniffing": {
|
|
||||||
"enabled": true,
|
|
||||||
"destOverride": [
|
|
||||||
"http",
|
|
||||||
"tls"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "tag3",
|
|
||||||
"port": 10809,
|
|
||||||
"protocol": "http",
|
|
||||||
"listen": "127.0.0.1",
|
|
||||||
"settings": {
|
|
||||||
"allowTransparent": false
|
|
||||||
},
|
|
||||||
"sniffing": {
|
|
||||||
"enabled": true,
|
|
||||||
"destOverride": [
|
|
||||||
"http",
|
|
||||||
"tls"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"outbounds": [{
|
"outbounds": [{
|
||||||
"tag": "proxy",
|
"tag": "proxy",
|
||||||
"protocol": "vmess",
|
"protocol": "vmess",
|
||||||
|
|
|
@ -3,14 +3,7 @@
|
||||||
"level": "debug",
|
"level": "debug",
|
||||||
"timestamp": true
|
"timestamp": true
|
||||||
},
|
},
|
||||||
"inbounds": [
|
"inbounds": [],
|
||||||
{
|
|
||||||
"type": "socks",
|
|
||||||
"tag": "socks",
|
|
||||||
"listen": "127.0.0.1",
|
|
||||||
"listen_port": 10000
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"outbounds": [
|
"outbounds": [
|
||||||
{
|
{
|
||||||
"type": "vless",
|
"type": "vless",
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
|
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Utils.ProcessStart("https://www.v2fly.org/config/dns.html#dnsobject");
|
Utils.ProcessStart("https://xtls.github.io/config/dns.html#dnsobject");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkDnsSingboxObjectDoc_Click(object sender, RoutedEventArgs e)
|
private void linkDnsSingboxObjectDoc_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
private void linkRuleobjectDoc_Click(object sender, RoutedEventArgs e)
|
private void linkRuleobjectDoc_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Utils.ProcessStart("https://www.v2fly.org/config/routing.html#ruleobject");
|
Utils.ProcessStart("https://xtls.github.io/config/routing.html#ruleobject");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -127,7 +127,7 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
private void linkdomainStrategy_Click(object sender, System.Windows.RoutedEventArgs e)
|
private void linkdomainStrategy_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Utils.ProcessStart("https://www.v2fly.org/config/routing.html");
|
Utils.ProcessStart("https://xtls.github.io/config/routing.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkdomainStrategy4Singbox_Click(object sender, RoutedEventArgs e)
|
private void linkdomainStrategy4Singbox_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
Loading…
Reference in New Issue