Optimize code

pull/5105/head
2dust 7 months ago
parent 31267cbc33
commit 315d4b75b2

@ -111,7 +111,8 @@ namespace v2rayN.Handler
{
try
{
singboxConfig.inbounds.Clear();
var listen = "::";
singboxConfig.inbounds = [];
if (!_config.tunModeItem.enableTun || (_config.tunModeItem.enableTun && _config.tunModeItem.enableExInbound))
{
@ -146,11 +147,11 @@ namespace v2rayN.Handler
if (_config.inbound[0].newPort4LAN)
{
var inbound3 = GetInbound(inbound, EInboundProtocol.socks2, true);
inbound3.listen = "::";
inbound3.listen = listen;
singboxConfig.inbounds.Add(inbound3);
var inbound4 = GetInbound(inbound, EInboundProtocol.http2, false);
inbound4.listen = "::";
inbound4.listen = listen;
singboxConfig.inbounds.Add(inbound4);
//auth
@ -162,8 +163,8 @@ namespace v2rayN.Handler
}
else
{
inbound.listen = "::";
inbound2.listen = "::";
inbound.listen = listen;
inbound2.listen = listen;
}
}
}

@ -98,7 +98,8 @@ namespace v2rayN.Handler
{
try
{
v2rayConfig.inbounds = new List<Inbounds4Ray>();
var listen = "0.0.0.0";
v2rayConfig.inbounds = [];
Inbounds4Ray? inbound = GetInbound(_config.inbound[0], EInboundProtocol.socks, true);
v2rayConfig.inbounds.Add(inbound);
@ -112,11 +113,11 @@ namespace v2rayN.Handler
if (_config.inbound[0].newPort4LAN)
{
var inbound3 = GetInbound(_config.inbound[0], EInboundProtocol.socks2, true);
inbound3.listen = "0.0.0.0";
inbound3.listen = listen;
v2rayConfig.inbounds.Add(inbound3);
var inbound4 = GetInbound(_config.inbound[0], EInboundProtocol.http2, false);
inbound4.listen = "0.0.0.0";
inbound4.listen = listen;
v2rayConfig.inbounds.Add(inbound4);
//auth
@ -131,8 +132,8 @@ namespace v2rayN.Handler
}
else
{
inbound.listen = "0.0.0.0";
inbound2.listen = "0.0.0.0";
inbound.listen = listen;
inbound2.listen = listen;
}
}
}
@ -143,18 +144,18 @@ namespace v2rayN.Handler
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);
if (Utils.IsNullOrEmpty(result))
{
return null;
return new();
}
var inbound = JsonUtils.Deserialize<Inbounds4Ray>(result);
if (inbound == null)
{
return null;
return new();
}
inbound.tag = protocol.ToString();
inbound.port = inItem.localPort + (int)protocol;

@ -4,56 +4,7 @@
"error": "Verror.log",
"loglevel": "warning"
},
"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"
]
}
}
],
"inbounds": [],
"outbounds": [{
"tag": "proxy",
"protocol": "vmess",

@ -3,14 +3,7 @@
"level": "debug",
"timestamp": true
},
"inbounds": [
{
"type": "socks",
"tag": "socks",
"listen": "127.0.0.1",
"listen_port": 10000
}
],
"inbounds": [],
"outbounds": [
{
"type": "vless",

@ -51,7 +51,7 @@ namespace v2rayN.Views
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)

@ -83,7 +83,7 @@ namespace v2rayN.Views
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)
{
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)

Loading…
Cancel
Save