mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-30 01:34:08 +00:00
Merge branch '2dust:master' into master
This commit is contained in:
commit
bbdf29d69b
3 changed files with 38 additions and 12 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using AwesomeAssertions;
|
||||
using ServiceLib.Common;
|
||||
using ServiceLib.Enums;
|
||||
using ServiceLib.Manager;
|
||||
using ServiceLib.Models;
|
||||
using ServiceLib.Services.CoreConfig;
|
||||
using Xunit;
|
||||
|
|
@ -28,6 +29,31 @@ public class CoreConfigSingboxServiceTests
|
|||
singboxConfig.inbounds.Should().Contain(i => i.type == nameof(EInboundProtocol.mixed));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_TunWithLoopbackPreSocks_ShouldKeepMixedInbound()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box);
|
||||
node.Address = Global.Loopback;
|
||||
node.Port = 1080;
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||
{
|
||||
IsTunEnabled = true,
|
||||
};
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.inbounds.Should().Contain(i =>
|
||||
i.type == nameof(EInboundProtocol.mixed)
|
||||
&& i.listen == Global.Loopback
|
||||
&& i.listen_port == AppManager.Instance.GetLocalPort(EInboundProtocol.socks));
|
||||
cfg.inbounds.Should().Contain(i => i.type == "tun");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_PolicyGroup_ShouldExpandChildrenAndBuildSelector()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1684,7 +1684,7 @@
|
|||
<value>ICMP 路由策略</value>
|
||||
</data>
|
||||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>Legacy TUN Protect</value>
|
||||
<value>舊版 TUN 保護</value>
|
||||
</data>
|
||||
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||
<value>偽裝域名</value>
|
||||
|
|
@ -1702,30 +1702,30 @@
|
|||
<value>僅用於抓取自簽證書,存在中間人風險。</value>
|
||||
</data>
|
||||
<data name="menuUdpTestServer" xml:space="preserve">
|
||||
<value>Test Configurations UDP Delay</value>
|
||||
<value>測試 UDP 延遲(多選)</value>
|
||||
</data>
|
||||
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
|
||||
<value>UDP Test Url</value>
|
||||
<value>UDP 測試網址</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThrough" xml:space="preserve">
|
||||
<value>Local outbound address (SendThrough)</value>
|
||||
<value>本機出站位址 (SendThrough)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||
<value>適用於多網路介面環境,請填寫本機 IPv4 位址</value>
|
||||
</data>
|
||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||
<value>Please fill in the correct IPv4 address for SendThrough.</value>
|
||||
<value>請填寫正確的 SendThrough IPv4 位址。</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterface" xml:space="preserve">
|
||||
<value>Bind Interface</value>
|
||||
<value>綁定網路介面</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems and TUN mode</value>
|
||||
<value>適用於多網路介面環境,請填寫要綁定的介面名稱;Windows 系統有效,其他系統僅在 TUN 模式下生效。</value>
|
||||
</data>
|
||||
<data name="TbPreSharedKey" xml:space="preserve">
|
||||
<value>PreSharedKey</value>
|
||||
</data>
|
||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
||||
<value>匯出 v2rayN 內部分享連結至剪貼簿(多選)</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ public partial class CoreConfigSingboxService
|
|||
{
|
||||
var listen = "0.0.0.0";
|
||||
var listenPort = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||
var isUsingLocalMixedPort = _node.Address == Global.Loopback && _node.Port == listenPort;
|
||||
_coreConfig.inbounds = [];
|
||||
|
||||
if (!context.IsTunEnabled
|
||||
|| (context.IsTunEnabled && _node.Address != Global.Loopback && _node.Port != listenPort))
|
||||
if (!context.IsTunEnabled || !isUsingLocalMixedPort)
|
||||
{
|
||||
var inbound = new Inbound4Sbox()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue