mirror of
https://github.com/2dust/v2rayN.git
synced 2026-03-30 12:07:40 +00:00
Fix xhttp dialer proxy (#8993)
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled
release Linux / deb (push) Has been cancelled
release Linux / rpm (push) Has been cancelled
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled
release Linux / deb (push) Has been cancelled
release Linux / rpm (push) Has been cancelled
This commit is contained in:
parent
005cb620ec
commit
80178aeb2f
2 changed files with 29 additions and 25 deletions
|
|
@ -109,9 +109,7 @@ public partial class CoreConfigV2rayService
|
||||||
?? string.Empty;
|
?? string.Empty;
|
||||||
if (!Utils.IsPrivateNetwork(outboundAddress))
|
if (!Utils.IsPrivateNetwork(outboundAddress))
|
||||||
{
|
{
|
||||||
outbound.streamSettings ??= new StreamSettings4Ray();
|
FillDialerProxy(outbound, fullConfigTemplate.ProxyDetour);
|
||||||
outbound.streamSettings.sockopt ??= new Sockopt4Ray();
|
|
||||||
outbound.streamSettings.sockopt.dialerProxy = fullConfigTemplate.ProxyDetour;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
customOutboundsNode.Add(JsonUtils.DeepCopy(outbound));
|
customOutboundsNode.Add(JsonUtils.DeepCopy(outbound));
|
||||||
|
|
|
||||||
|
|
@ -51,10 +51,7 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
foreach (var outbound in actOutboundWithTlsList)
|
foreach (var outbound in actOutboundWithTlsList)
|
||||||
{
|
{
|
||||||
outbound.streamSettings.sockopt = new()
|
FillDialerProxy(outbound, fragmentOutbound.tag);
|
||||||
{
|
|
||||||
dialerProxy = fragmentOutbound.tag
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return proxyOutboundList;
|
return proxyOutboundList;
|
||||||
|
|
@ -748,10 +745,7 @@ public partial class CoreConfigV2rayService
|
||||||
childProfiles.Where(n => n?.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true);
|
childProfiles.Where(n => n?.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true);
|
||||||
foreach (var chainEndNode in chainEndNodes)
|
foreach (var chainEndNode in chainEndNodes)
|
||||||
{
|
{
|
||||||
chainEndNode.streamSettings.sockopt = new()
|
FillDialerProxy(chainEndNode, dialerProxyTag);
|
||||||
{
|
|
||||||
dialerProxy = dialerProxyTag
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
|
|
@ -759,12 +753,10 @@ public partial class CoreConfigV2rayService
|
||||||
var chainStartNodes = childProfiles.Where(n => n.tag.StartsWith(currentTag)).ToList();
|
var chainStartNodes = childProfiles.Where(n => n.tag.StartsWith(currentTag)).ToList();
|
||||||
if (chainStartNodes.Count == 1)
|
if (chainStartNodes.Count == 1)
|
||||||
{
|
{
|
||||||
|
var firstChainTag = chainStartNodes.First().tag;
|
||||||
foreach (var existedChainEndNode in resultOutbounds.Where(n => n.streamSettings?.sockopt?.dialerProxy == currentTag))
|
foreach (var existedChainEndNode in resultOutbounds.Where(n => n.streamSettings?.sockopt?.dialerProxy == currentTag))
|
||||||
{
|
{
|
||||||
existedChainEndNode.streamSettings.sockopt = new()
|
FillDialerProxy(existedChainEndNode, firstChainTag);
|
||||||
{
|
|
||||||
dialerProxy = chainStartNodes.First().tag
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (chainStartNodes.Count > 1)
|
else if (chainStartNodes.Count > 1)
|
||||||
|
|
@ -787,12 +779,8 @@ public partial class CoreConfigV2rayService
|
||||||
var nextTag = k + 1 < existedChainNodesClone.Count
|
var nextTag = k + 1 < existedChainNodesClone.Count
|
||||||
? existedChainNodesClone[k + 1].tag
|
? existedChainNodesClone[k + 1].tag
|
||||||
: chainStartNode.tag;
|
: chainStartNode.tag;
|
||||||
existedChainNode.streamSettings.sockopt = new()
|
FillDialerProxy(existedChainNode,
|
||||||
{
|
previousDialerProxyTag == currentTag ? chainStartNode.tag : nextTag);
|
||||||
dialerProxy = (previousDialerProxyTag == currentTag)
|
|
||||||
? chainStartNode.tag
|
|
||||||
: nextTag
|
|
||||||
};
|
|
||||||
resultOutbounds.Add(existedChainNode);
|
resultOutbounds.Add(existedChainNode);
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
|
|
@ -808,14 +796,32 @@ public partial class CoreConfigV2rayService
|
||||||
|
|
||||||
if (!dialerProxyTag.IsNullOrEmpty())
|
if (!dialerProxyTag.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
outbound.streamSettings.sockopt = new()
|
FillDialerProxy(outbound, dialerProxyTag);
|
||||||
{
|
|
||||||
dialerProxy = dialerProxyTag
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultOutbounds.Add(outbound);
|
resultOutbounds.Add(outbound);
|
||||||
}
|
}
|
||||||
return resultOutbounds;
|
return resultOutbounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void FillDialerProxy(Outbounds4Ray outbound, string dialerProxyTag)
|
||||||
|
{
|
||||||
|
outbound.streamSettings ??= new();
|
||||||
|
outbound.streamSettings.sockopt ??= new();
|
||||||
|
outbound.streamSettings.sockopt.dialerProxy = dialerProxyTag;
|
||||||
|
|
||||||
|
// xhttp download dialer proxy
|
||||||
|
if (outbound?.streamSettings?.xhttpSettings?.extra is not null)
|
||||||
|
{
|
||||||
|
var xhttpExtra = JsonUtils.ParseJson(JsonUtils.Serialize(outbound.streamSettings.xhttpSettings!.extra));
|
||||||
|
if (xhttpExtra is JsonObject xhttpExtraObject
|
||||||
|
&& xhttpExtraObject["downloadSettings"] is JsonObject downloadSettings)
|
||||||
|
{
|
||||||
|
var sockopt = downloadSettings["sockopt"] as JsonObject ?? new JsonObject();
|
||||||
|
sockopt["dialerProxy"] = dialerProxyTag;
|
||||||
|
downloadSettings["sockopt"] = sockopt;
|
||||||
|
outbound.streamSettings.xhttpSettings.extra = xhttpExtraObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue