mirror of
https://github.com/2dust/v2rayN.git
synced 2026-03-30 12:07:40 +00:00
Add xhttp download protect (#8987)
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
7ddb46e74d
commit
005cb620ec
1 changed files with 29 additions and 3 deletions
|
|
@ -316,24 +316,50 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||||
SsMethod = Global.None,
|
SsMethod = Global.None,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const string protectTag = "tun-protect-ss";
|
||||||
foreach (var outbound in _coreConfig.outbounds
|
foreach (var outbound in _coreConfig.outbounds
|
||||||
.Where(o => o.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
|
.Where(o => o.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
|
||||||
{
|
{
|
||||||
outbound.streamSettings ??= new();
|
outbound.streamSettings ??= new();
|
||||||
outbound.streamSettings.sockopt ??= new();
|
outbound.streamSettings.sockopt ??= new();
|
||||||
outbound.streamSettings.sockopt.dialerProxy = "tun-protect-ss";
|
outbound.streamSettings.sockopt.dialerProxy = protectTag;
|
||||||
}
|
}
|
||||||
// ech protected
|
// ech protected
|
||||||
foreach (var outbound in _coreConfig.outbounds
|
foreach (var outbound in _coreConfig.outbounds
|
||||||
.Where(outbound => outbound.streamSettings?.tlsSettings?.echConfigList?.IsNullOrEmpty() == false))
|
.Where(outbound => outbound.streamSettings?.tlsSettings?.echConfigList?.IsNullOrEmpty() == false))
|
||||||
{
|
{
|
||||||
outbound.streamSettings!.tlsSettings!.echSockopt ??= new();
|
outbound.streamSettings!.tlsSettings!.echSockopt ??= new();
|
||||||
outbound.streamSettings.tlsSettings.echSockopt.dialerProxy = "tun-protect-ss";
|
outbound.streamSettings.tlsSettings.echSockopt.dialerProxy = protectTag;
|
||||||
|
}
|
||||||
|
// xhttp download protected
|
||||||
|
foreach (var outbound in _coreConfig.outbounds
|
||||||
|
.Where(o => o.streamSettings?.xhttpSettings?.extra is not null))
|
||||||
|
{
|
||||||
|
var xhttpExtra = JsonUtils.ParseJson(JsonUtils.Serialize(outbound.streamSettings.xhttpSettings!.extra));
|
||||||
|
if (xhttpExtra is not JsonObject xhttpExtraObject
|
||||||
|
|| xhttpExtraObject["downloadSettings"] is not JsonObject downloadSettings)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// dialerProxy
|
||||||
|
var sockopt = downloadSettings["sockopt"] as JsonObject ?? new JsonObject();
|
||||||
|
sockopt["dialerProxy"] = protectTag;
|
||||||
|
downloadSettings["sockopt"] = sockopt;
|
||||||
|
// ech protected
|
||||||
|
if (downloadSettings["tlsSettings"] is JsonObject tlsSettings
|
||||||
|
&& tlsSettings["echConfigList"] is not null)
|
||||||
|
{
|
||||||
|
tlsSettings["echSockopt"] = new JsonObject
|
||||||
|
{
|
||||||
|
["dialerProxy"] = protectTag
|
||||||
|
};
|
||||||
|
}
|
||||||
|
outbound.streamSettings.xhttpSettings.extra = xhttpExtraObject;
|
||||||
}
|
}
|
||||||
_coreConfig.outbounds.Add(new CoreConfigV2rayService(context with
|
_coreConfig.outbounds.Add(new CoreConfigV2rayService(context with
|
||||||
{
|
{
|
||||||
Node = protectNode,
|
Node = protectNode,
|
||||||
}).BuildProxyOutbound("tun-protect-ss"));
|
}).BuildProxyOutbound(protectTag));
|
||||||
|
|
||||||
_coreConfig.routing.rules ??= [];
|
_coreConfig.routing.rules ??= [];
|
||||||
var hasBalancer = _coreConfig.routing.balancers is { Count: > 0 };
|
var hasBalancer = _coreConfig.routing.balancers is { Count: > 0 };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue