mirror of https://github.com/2dust/v2rayN
Previous and next proxy 4 sing-box
parent
51576b54c3
commit
b74188d904
|
@ -45,7 +45,9 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
GenInbounds(singboxConfig);
|
GenInbounds(singboxConfig);
|
||||||
|
|
||||||
GenOutbound(node, singboxConfig);
|
GenOutbound(node, singboxConfig.outbounds[0]);
|
||||||
|
|
||||||
|
GenMoreOutbounds(node, singboxConfig);
|
||||||
|
|
||||||
GenRouting(singboxConfig);
|
GenRouting(singboxConfig);
|
||||||
|
|
||||||
|
@ -202,20 +204,10 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
#region outbound private
|
#region outbound private
|
||||||
|
|
||||||
private int GenOutbound(ProfileItem node, SingboxConfig singboxConfig)
|
private int GenOutbound(ProfileItem node, Outbound4Sbox outbound)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_config.tunModeItem.enableTun)
|
|
||||||
{
|
|
||||||
singboxConfig.outbounds.Add(new()
|
|
||||||
{
|
|
||||||
type = "dns",
|
|
||||||
tag = "dns_out"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var outbound = singboxConfig.outbounds[0];
|
|
||||||
outbound.server = node.address;
|
outbound.server = node.address;
|
||||||
outbound.server_port = node.port;
|
outbound.server_port = node.port;
|
||||||
|
|
||||||
|
@ -442,6 +434,59 @@ namespace v2rayN.Handler
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int GenMoreOutbounds(ProfileItem node, SingboxConfig singboxConfig)
|
||||||
|
{
|
||||||
|
if (node.subid.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var subItem = LazyConfig.Instance.GetSubItem(node.subid);
|
||||||
|
if (subItem is null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//current proxy
|
||||||
|
var outbound = singboxConfig.outbounds[0];
|
||||||
|
var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
|
||||||
|
|
||||||
|
//Previous proxy
|
||||||
|
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);
|
||||||
|
if (prevNode is not null
|
||||||
|
&& prevNode.configType != EConfigType.Custom)
|
||||||
|
{
|
||||||
|
var prevOutbound = Utils.FromJson<Outbound4Sbox>(txtOutbound);
|
||||||
|
GenOutbound(prevNode, prevOutbound);
|
||||||
|
prevOutbound.tag = $"{Global.ProxyTag}2";
|
||||||
|
singboxConfig.outbounds.Add(prevOutbound);
|
||||||
|
|
||||||
|
outbound.detour = prevOutbound.tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Next proxy
|
||||||
|
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile!);
|
||||||
|
if (nextNode is not null
|
||||||
|
&& nextNode.configType != EConfigType.Custom)
|
||||||
|
{
|
||||||
|
var nextOutbound = Utils.FromJson<Outbound4Sbox>(txtOutbound);
|
||||||
|
GenOutbound(nextNode, nextOutbound);
|
||||||
|
nextOutbound.tag = Global.ProxyTag;
|
||||||
|
singboxConfig.outbounds.Insert(0, nextOutbound);
|
||||||
|
|
||||||
|
outbound.tag = $"{Global.ProxyTag}1";
|
||||||
|
nextOutbound.detour = outbound.tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Utils.SaveLog(ex.Message, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion outbound private
|
#endregion outbound private
|
||||||
|
|
||||||
#region routing rule private
|
#region routing rule private
|
||||||
|
|
|
@ -838,12 +838,15 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
//current proxy
|
//current proxy
|
||||||
var outbound = v2rayConfig.outbounds[0];
|
var outbound = v2rayConfig.outbounds[0];
|
||||||
|
var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
|
||||||
|
|
||||||
//Previous proxy
|
//Previous proxy
|
||||||
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);
|
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);
|
||||||
if (prevNode is not null)
|
if (prevNode is not null
|
||||||
|
&& prevNode.configType != EConfigType.Custom
|
||||||
|
&& prevNode.configType != EConfigType.Hysteria2
|
||||||
|
&& prevNode.configType != EConfigType.Tuic)
|
||||||
{
|
{
|
||||||
var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
|
|
||||||
var prevOutbound = Utils.FromJson<Outbounds4Ray>(txtOutbound);
|
var prevOutbound = Utils.FromJson<Outbounds4Ray>(txtOutbound);
|
||||||
GenOutbound(prevNode, prevOutbound);
|
GenOutbound(prevNode, prevOutbound);
|
||||||
prevOutbound.tag = $"{Global.ProxyTag}2";
|
prevOutbound.tag = $"{Global.ProxyTag}2";
|
||||||
|
@ -857,9 +860,11 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
//Next proxy
|
//Next proxy
|
||||||
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile!);
|
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile!);
|
||||||
if (nextNode is not null)
|
if (nextNode is not null
|
||||||
|
&& nextNode.configType != EConfigType.Custom
|
||||||
|
&& nextNode.configType != EConfigType.Hysteria2
|
||||||
|
&& nextNode.configType != EConfigType.Tuic)
|
||||||
{
|
{
|
||||||
var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
|
|
||||||
var nextOutbound = Utils.FromJson<Outbounds4Ray>(txtOutbound);
|
var nextOutbound = Utils.FromJson<Outbounds4Ray>(txtOutbound);
|
||||||
GenOutbound(nextNode, nextOutbound);
|
GenOutbound(nextNode, nextOutbound);
|
||||||
nextOutbound.tag = Global.ProxyTag;
|
nextOutbound.tag = Global.ProxyTag;
|
||||||
|
|
|
@ -105,7 +105,7 @@
|
||||||
public int? recv_window_conn { get; set; }
|
public int? recv_window_conn { get; set; }
|
||||||
public int? recv_window { get; set; }
|
public int? recv_window { get; set; }
|
||||||
public bool? disable_mtu_discovery { get; set; }
|
public bool? disable_mtu_discovery { get; set; }
|
||||||
public string detour { get; set; }
|
public string? detour { get; set; }
|
||||||
public string method { get; set; }
|
public string method { get; set; }
|
||||||
public string username { get; set; }
|
public string username { get; set; }
|
||||||
public string password { get; set; }
|
public string password { get; set; }
|
||||||
|
|
|
@ -25,9 +25,18 @@
|
||||||
{
|
{
|
||||||
"type": "block",
|
"type": "block",
|
||||||
"tag": "block"
|
"tag": "block"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "dns_out",
|
||||||
|
"type": "dns"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"route": {
|
"route": {
|
||||||
"rules": []
|
"rules": [
|
||||||
|
{
|
||||||
|
"protocol": [ "dns" ],
|
||||||
|
"outbound": "dns_out"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,5 +24,9 @@
|
||||||
"geoip:private",
|
"geoip:private",
|
||||||
"geoip:cn"
|
"geoip:cn"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"port": "0-65535",
|
||||||
|
"outboundTag": "proxy"
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -1,8 +1,4 @@
|
||||||
[
|
[
|
||||||
{
|
|
||||||
"inbound": [ "dns_in" ],
|
|
||||||
"outbound": "dns_out"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"protocol": [ "dns" ],
|
"protocol": [ "dns" ],
|
||||||
"outbound": "dns_out"
|
"outbound": "dns_out"
|
||||||
|
|
Loading…
Reference in New Issue