mirror of https://github.com/2dust/v2rayN
Adjust some config for sing-box
parent
c8ae834f50
commit
42f7c7cb43
|
@ -50,7 +50,7 @@ namespace v2rayN.Handler
|
|||
|
||||
routing(singboxConfig);
|
||||
|
||||
dns(singboxConfig);
|
||||
dns(node, singboxConfig);
|
||||
|
||||
//statistic(singboxConfig);
|
||||
|
||||
|
@ -133,7 +133,7 @@ namespace v2rayN.Handler
|
|||
inbound.listen_port = LazyConfig.Instance.GetLocalPort(Global.InboundSocks);
|
||||
inbound.sniff = _config.inbound[0].sniffingEnabled;
|
||||
inbound.sniff_override_destination = _config.inbound[0].routeOnly ? false : _config.inbound[0].sniffingEnabled;
|
||||
inbound.domain_strategy = Utils.IsNullOrEmpty(_config.routingBasicItem.domainStrategy4Singbox) ? null: _config.routingBasicItem.domainStrategy4Singbox;
|
||||
inbound.domain_strategy = Utils.IsNullOrEmpty(_config.routingBasicItem.domainStrategy4Singbox) ? null : _config.routingBasicItem.domainStrategy4Singbox;
|
||||
|
||||
//http
|
||||
var inbound2 = GetInbound(inbound, Global.InboundHttp, 1, false);
|
||||
|
@ -635,10 +635,13 @@ namespace v2rayN.Handler
|
|||
|
||||
#endregion routing rule private
|
||||
|
||||
private int dns(SingboxConfig singboxConfig)
|
||||
#region dns private
|
||||
|
||||
private int dns(ProfileItem node, SingboxConfig singboxConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dns4Sbox? dns4Sbox;
|
||||
if (_config.tunModeItem.enableTun)
|
||||
{
|
||||
string tunDNS = String.Empty;
|
||||
|
@ -650,12 +653,11 @@ namespace v2rayN.Handler
|
|||
{
|
||||
tunDNS = _config.tunModeItem.proxyDNS;
|
||||
}
|
||||
if (tunDNS.IsNullOrEmpty() || Utils.ParseJson(tunDNS)?.ContainsKey("servers") == false)
|
||||
if (tunDNS.IsNullOrEmpty() || Utils.FromJson<Dns4Sbox>(tunDNS) is null)
|
||||
{
|
||||
tunDNS = Utils.GetEmbedText(Global.TunSingboxDNSFileName);
|
||||
}
|
||||
var obj = Utils.ParseJson(tunDNS);
|
||||
singboxConfig.dns = obj;
|
||||
dns4Sbox = Utils.FromJson<Dns4Sbox>(tunDNS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -666,12 +668,33 @@ namespace v2rayN.Handler
|
|||
normalDNS = "{\"servers\":[{\"address\":\"tcp://8.8.8.8\"}]}";
|
||||
}
|
||||
|
||||
var obj = Utils.ParseJson(normalDNS);
|
||||
if (obj?.ContainsKey("servers") == true)
|
||||
{
|
||||
singboxConfig.dns = obj;
|
||||
}
|
||||
dns4Sbox = Utils.FromJson<Dns4Sbox>(normalDNS);
|
||||
}
|
||||
if (dns4Sbox is null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
//Add the dns of the remote server domain
|
||||
if (Utils.IsDomain(node.address))
|
||||
{
|
||||
if (dns4Sbox.rules is null)
|
||||
{
|
||||
dns4Sbox.rules = new();
|
||||
}
|
||||
dns4Sbox.servers.Add(new()
|
||||
{
|
||||
tag = "local_local",
|
||||
address = "223.5.5.5",
|
||||
detour = "direct"
|
||||
});
|
||||
dns4Sbox.rules.Add(new()
|
||||
{
|
||||
server = "local_local",
|
||||
domain = new List<string>() { node.address }
|
||||
});
|
||||
}
|
||||
|
||||
singboxConfig.dns = dns4Sbox;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -680,6 +703,8 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endregion dns private
|
||||
|
||||
private int statistic(SingboxConfig singboxConfig)
|
||||
{
|
||||
if (_config.guiItem.enableStatistics)
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
],
|
||||
"rules": [
|
||||
{
|
||||
"geosite": "cn",
|
||||
"geosite": [ "cn" ],
|
||||
"server": "local"
|
||||
},
|
||||
{
|
||||
"geosite": "category-ads-all",
|
||||
"geosite": [ "category-ads-all" ],
|
||||
"server": "block"
|
||||
}
|
||||
]}
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
],
|
||||
"rules": [
|
||||
{
|
||||
"geosite": "cn",
|
||||
"geosite": [ "cn" ],
|
||||
"server": "local",
|
||||
"disable_cache": true
|
||||
},
|
||||
{
|
||||
"geosite": "category-ads-all",
|
||||
"geosite": [ "category-ads-all" ],
|
||||
"server": "block",
|
||||
"disable_cache": true
|
||||
}
|
||||
|
|
|
@ -554,14 +554,7 @@ namespace v2rayN
|
|||
return false;
|
||||
}
|
||||
|
||||
//清除要验证字符串中的空格
|
||||
//domain = domain.TrimEx();
|
||||
|
||||
//模式字符串
|
||||
string pattern = @"^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$";
|
||||
|
||||
//验证
|
||||
return IsMatch(domain, pattern);
|
||||
return Uri.CheckHostName(domain) == UriHostNameType.Dns;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -73,8 +73,8 @@ namespace v2rayN.ViewModels
|
|||
}
|
||||
if (!Utils.IsNullOrEmpty(normalDNS2))
|
||||
{
|
||||
var obj2 = Utils.ParseJson(normalDNS2);
|
||||
if (obj2 == null || obj2.ContainsKey("servers") == false)
|
||||
var obj2 = Utils.FromJson<Dns4Sbox>(normalDNS2);
|
||||
if (obj2 == null)
|
||||
{
|
||||
UI.Show(ResUI.FillCorrectDNSText);
|
||||
return;
|
||||
|
|
|
@ -939,6 +939,7 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
subid = _subId,
|
||||
configType = eConfigType,
|
||||
isSub = false,
|
||||
};
|
||||
}
|
||||
else
|
||||
|
@ -1337,7 +1338,6 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
//RefreshServers();
|
||||
Reload();
|
||||
TunModeSwitch();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1352,6 +1352,7 @@ namespace v2rayN.ViewModels
|
|||
Reload();
|
||||
}
|
||||
}
|
||||
|
||||
private void DNSSetting()
|
||||
{
|
||||
var ret = (new DNSSettingWindow()).ShowDialog();
|
||||
|
@ -1483,10 +1484,6 @@ namespace v2rayN.ViewModels
|
|||
BlReloadEnabled = false;
|
||||
}));
|
||||
|
||||
//if (Global.reloadV2ray)
|
||||
//{
|
||||
// _noticeHandler?.SendMessage(Global.CommandClearMsg);
|
||||
//}
|
||||
await Task.Run(() =>
|
||||
{
|
||||
_coreHandler.LoadCore(_config);
|
||||
|
@ -1620,8 +1617,8 @@ namespace v2rayN.ViewModels
|
|||
if (_config.tunModeItem.enableTun != EnableTun)
|
||||
{
|
||||
_config.tunModeItem.enableTun = EnableTun;
|
||||
Reload();
|
||||
}
|
||||
TunModeSwitch();
|
||||
}
|
||||
|
||||
private void TunModeSwitch()
|
||||
|
|
Loading…
Reference in New Issue