Compare commits

..

1 commit

Author SHA1 Message Date
DHR60
e01d5cfdc1
Merge 4da5dc4c96 into 53041906b3 2026-04-07 10:29:38 +00:00
10 changed files with 67 additions and 44 deletions

View file

@ -47,7 +47,7 @@ jobs:
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r linux-arm64 -p:SelfContained=true -p:PublishTrimmed=true -o "$OutputPathArm64"
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.1
uses: actions/upload-artifact@v7.0.0
with:
name: v2rayN-linux
path: |
@ -116,7 +116,7 @@ jobs:
ls -R "$GITHUB_WORKSPACE/dist/deb" || true
- name: Upload DEB artifacts
uses: actions/upload-artifact@v7.0.1
uses: actions/upload-artifact@v7.0.0
with:
name: v2rayN-deb
path: dist/deb/**/*.deb
@ -229,7 +229,7 @@ jobs:
ls -R "$GITHUB_WORKSPACE/dist/rpm" || true
- name: Upload RPM artifacts
uses: actions/upload-artifact@v7.0.1
uses: actions/upload-artifact@v7.0.0
with:
name: v2rayN-rpm
path: dist/rpm/**/*.rpm

View file

@ -45,7 +45,7 @@ jobs:
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r osx-arm64 -p:SelfContained=true -p:PublishTrimmed=true -o $OutputPathArm64
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.1
uses: actions/upload-artifact@v7.0.0
with:
name: v2rayN-macos
path: |

View file

@ -45,7 +45,7 @@ jobs:
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-arm64 -p:SelfContained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPathArm64
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.1
uses: actions/upload-artifact@v7.0.0
with:
name: v2rayN-windows-desktop
path: |

View file

@ -42,7 +42,7 @@ jobs:
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-arm64 -p:SelfContained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPathArm64
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.1
uses: actions/upload-artifact@v7.0.0
with:
name: v2rayN-windows
path: |

View file

@ -145,7 +145,7 @@ public class Global
@"https://cachefly.cachefly.net/50mb.test",
@"https://speed.cloudflare.com/__down?bytes=10000000",
@"https://speed.cloudflare.com/__down?bytes=50000000",
@"https://speed.cloudflare.com/__down?bytes=99999999",
@"https://speed.cloudflare.com/__down?bytes=100000000",
];
public static readonly List<string> SpeedPingTestUrls =

View file

@ -25,14 +25,14 @@ public record CoreConfigContextBuilderAllResult(
[.. MainResult.ValidatorResult.Warnings, .. PreSocksResult?.ValidatorResult.Warnings ?? []]);
/// <summary>
/// The main context with TunProtectSocksPort/ProxyRelaySocksPort and ProtectDomainList merged in
/// The main context with TunProtectSsPort/ProxyRelaySsPort and ProtectDomainList merged in
/// from the pre-socks result (if any). Pass this to the core runner.
/// </summary>
public CoreConfigContext ResolvedMainContext => PreSocksResult is not null
? MainResult.Context with
{
TunProtectSocksPort = PreSocksResult.Context.TunProtectSocksPort,
ProxyRelaySocksPort = PreSocksResult.Context.ProxyRelaySocksPort,
TunProtectSsPort = PreSocksResult.Context.TunProtectSsPort,
ProxyRelaySsPort = PreSocksResult.Context.ProxyRelaySsPort,
ProtectDomainList = [.. MainResult.Context.ProtectDomainList ?? [], .. PreSocksResult.Context.ProtectDomainList ?? []],
}
: MainResult.Context;
@ -58,8 +58,8 @@ public class CoreConfigContextBuilder
IsTunEnabled = config.TunModeItem.EnableTun,
SimpleDnsItem = config.SimpleDNSItem,
ProtectDomainList = [],
TunProtectSocksPort = 0,
ProxyRelaySocksPort = 0,
TunProtectSsPort = 0,
ProxyRelaySsPort = 0,
RawDnsItem = await AppManager.Instance.GetDNSItem(coreType),
RoutingItem = await ConfigHandler.GetDefaultRouting(config),
};
@ -155,23 +155,28 @@ public class CoreConfigContextBuilder
return null;
}
var tunProtectSocksPort = Utils.GetFreePort();
var proxyRelaySocksPort = Utils.GetFreePort();
var tunProtectSsPort = Utils.GetFreePort();
var proxyRelaySsPort = Utils.GetFreePort();
var preItem = new ProfileItem()
{
CoreType = ECoreType.sing_box,
ConfigType = EConfigType.SOCKS,
ConfigType = EConfigType.Shadowsocks,
Address = Global.Loopback,
Port = proxyRelaySocksPort,
Port = proxyRelaySsPort,
Password = Global.None,
};
preItem.SetProtocolExtra(preItem.GetProtocolExtra() with
{
SsMethod = Global.None,
});
var preResult2 = await Build(nodeContext.AppConfig, preItem);
return preResult2 with
{
Context = preResult2.Context with
{
ProtectDomainList = [.. nodeContext.ProtectDomainList ?? [], .. preResult2.Context.ProtectDomainList ?? []],
TunProtectSocksPort = tunProtectSocksPort,
ProxyRelaySocksPort = proxyRelaySocksPort,
TunProtectSsPort = tunProtectSsPort,
ProxyRelaySsPort = proxyRelaySsPort,
}
};
}

View file

@ -20,6 +20,6 @@ public record CoreConfigContext
// -> tun inbound --(if routing proxy)--> relay outbound
// -> proxy core (relay inbound --> proxy outbound --(dialerProxy)--> protect outbound)
// -> protect inbound -> direct proxy outbound data -> internet
public int TunProtectSocksPort { get; init; } = 0;
public int ProxyRelaySocksPort { get; init; } = 0;
public int TunProtectSsPort { get; init; } = 0;
public int ProxyRelaySsPort { get; init; } = 0;
}

View file

@ -62,23 +62,16 @@ public partial class CoreConfigSingboxService(CoreConfigContext context)
ret.Data = ApplyFullConfigTemplate();
if (!context.AppConfig.TunModeItem.EnableLegacyProtect
&& context.TunProtectSocksPort is > 0 and <= 65535)
&& context.TunProtectSsPort is > 0 and <= 65535)
{
// Replace relay proxy outbound, avoid mux or other feature cause issue, and add a socks inbound for tun protect
var relayProxyIndex = _coreConfig.outbounds.FindIndex(o => o.tag == Global.ProxyTag);
_coreConfig.outbounds[relayProxyIndex] = new Outbound4Sbox()
{
type = Global.ProtocolTypes[EConfigType.SOCKS],
tag = Global.ProxyTag,
server = Global.Loopback,
server_port = context.ProxyRelaySocksPort,
};
var ssInbound = new
{
type = "socks",
tag = "tun-protect-socks",
type = "shadowsocks",
tag = "tun-protect-ss",
listen = Global.Loopback,
listen_port = context.TunProtectSocksPort,
listen_port = context.TunProtectSsPort,
method = "none",
password = "none",
};
var directRule = new Rule4Sbox()
{

View file

@ -343,6 +343,14 @@ public partial class CoreConfigSingboxService
{
try
{
// The synthetic TUN relay outbound talks to the local Xray shadowsocks relay.
// Xray cannot terminate sing-box h2mux, so muxing here turns local relay traffic
// into sp.mux.sing-box.arpa pseudo-destinations and breaks DNS over TUN.
if (IsTunRelayProxyOutbound())
{
return;
}
var muxEnabled = _node.MuxEnabled ?? _config.CoreBasicItem.MuxEnabled;
if (muxEnabled && _config.Mux4SboxItem.Protocol.IsNotEmpty())
{
@ -362,6 +370,21 @@ public partial class CoreConfigSingboxService
}
}
private bool IsTunRelayProxyOutbound()
{
if (!context.IsTunEnabled
|| _node.ConfigType != EConfigType.Shadowsocks
|| _node.Address != Global.Loopback
|| _node.Port != context.ProxyRelaySsPort
|| _node.Password != Global.None)
{
return false;
}
var protocolExtra = _node.GetProtocolExtra();
return protocolExtra.SsMethod == Global.None;
}
private void FillOutboundTls(Outbound4Sbox outbound)
{
try

View file

@ -17,8 +17,8 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
{
if (!context.AppConfig.TunModeItem.EnableLegacyProtect
&& context.IsTunEnabled
&& context.TunProtectSocksPort is > 0 and <= 65535
&& context.ProxyRelaySocksPort is > 0 and <= 65535)
&& context.TunProtectSsPort is > 0 and <= 65535
&& context.ProxyRelaySsPort is > 0 and <= 65535)
{
return GenerateClientProxyRelayConfig();
}
@ -309,16 +309,17 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
var protectNode = new ProfileItem()
{
CoreType = ECoreType.Xray,
ConfigType = EConfigType.SOCKS,
ConfigType = EConfigType.Shadowsocks,
Address = Global.Loopback,
Port = context.TunProtectSocksPort,
Port = context.TunProtectSsPort,
Password = Global.None,
};
protectNode.SetProtocolExtra(protectNode.GetProtocolExtra() with
{
SsMethod = Global.None,
});
const string protectTag = "tun-protect-socks";
const string protectTag = "tun-protect-ss";
foreach (var outbound in _coreConfig.outbounds
.Where(o => o.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
{
@ -367,7 +368,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
var hasBalancer = _coreConfig.routing.balancers is { Count: > 0 };
_coreConfig.routing.rules.Add(new()
{
inboundTag = ["proxy-relay-socks"],
inboundTag = ["proxy-relay-ss"],
outboundTag = hasBalancer ? null : Global.ProxyTag,
balancerTag = hasBalancer ? Global.ProxyTag + Global.BalancerTagSuffix : null,
type = "field"
@ -379,14 +380,15 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
configNode["inbounds"]!.AsArray().Add(new
{
listen = Global.Loopback,
port = context.ProxyRelaySocksPort,
protocol = "socks",
port = context.ProxyRelaySsPort,
protocol = "shadowsocks",
settings = new
{
auth = "noauth",
udp = true,
network = "tcp,udp",
method = Global.None,
password = Global.None,
},
tag = "proxy-relay-socks",
tag = "proxy-relay-ss",
});
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");