Skip to content

Commit 8450f2e

Browse files
authored
Add bind interface (2dust#9222)
1 parent 37ef25c commit 8450f2e

21 files changed

Lines changed: 260 additions & 66 deletions

v2rayN/ServiceLib/Handler/Builder/CoreConfigContextBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public static async Task<CoreConfigContextBuilderResult> Build(Config config, Pr
4747
ProtectDomainList = [],
4848
RawDnsItem = await AppManager.Instance.GetDNSItem(coreType),
4949
RoutingItem = await ConfigHandler.GetDefaultRouting(config),
50+
IsWindows = Utils.IsWindows(),
5051
};
5152
var validatorResult = NodeValidatorResult.Empty();
5253
var (actNode, nodeValidatorResult) = await ResolveNodeAsync(context, node);

v2rayN/ServiceLib/Handler/ConfigHandler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public static class ConfigHandler
4141
Loglevel = "warning",
4242
MuxEnabled = false,
4343
};
44-
config.CoreBasicItem.SendThrough = config.CoreBasicItem.SendThrough?.TrimEx();
4544

4645
if (config.Inbound == null)
4746
{

v2rayN/ServiceLib/Models/ConfigItems.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class CoreBasicItem
1717

1818
public string? SendThrough { get; set; }
1919

20+
public string? BindInterface { get; set; }
21+
2022
public bool EnableFragment { get; set; }
2123

2224
public bool EnableCacheFile4Sbox { get; set; } = true;

v2rayN/ServiceLib/Models/CoreConfigContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ public record CoreConfigContext
1717
// TUN Compatibility
1818
public bool IsTunEnabled { get; init; } = false;
1919
public HashSet<string> ProtectDomainList { get; init; } = [];
20+
21+
public bool IsWindows { get; init; }
2022
}

v2rayN/ServiceLib/Resx/ResUI.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,9 +1689,6 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
16891689
<data name="TbLegacyProtect" xml:space="preserve">
16901690
<value>Legacy TUN Protect</value>
16911691
</data>
1692-
<data name="TbSettingsSendThroughTip" xml:space="preserve">
1693-
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
1694-
</data>
16951692
<data name="TbCamouflageDomain" xml:space="preserve">
16961693
<value>Camouflage domain</value>
16971694
</data>
@@ -1713,4 +1710,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
17131710
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
17141711
<value>UDP Test Url</value>
17151712
</data>
1713+
<data name="TbSettingsSendThrough" xml:space="preserve">
1714+
<value>Local outbound address (SendThrough)</value>
1715+
</data>
1716+
<data name="TbSettingsSendThroughTip" xml:space="preserve">
1717+
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
1718+
</data>
1719+
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
1720+
<value>Please fill in the correct IPv4 address for SendThrough.</value>
1721+
</data>
1722+
<data name="TbSettingsBindInterface" xml:space="preserve">
1723+
<value>Bind Interface</value>
1724+
</data>
1725+
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
1726+
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems and TUN mode</value>
1727+
</data>
17161728
</root>

v2rayN/ServiceLib/Resx/ResUI.fr.resx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,15 +1311,6 @@
13111311
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
13121312
<value>Le mot de passe sera vérifié en ligne de commande. En cas d’échec ou de dysfonctionnement, redémarrez l’application. Il n’est pas stocké et doit être saisi à chaque redémarrage.</value>
13131313
</data>
1314-
<data name="TbSettingsSendThrough" xml:space="preserve">
1315-
<value>Adresse sortante locale (SendThrough)</value>
1316-
</data>
1317-
<data name="TbSettingsSendThroughTip" xml:space="preserve">
1318-
<value>Pour environnements multi-interfaces, entrez l'adresse IPv4 de la machine locale.</value>
1319-
</data>
1320-
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
1321-
<value>Veuillez saisir l’adresse IPv4 correcte de SendThrough.</value>
1322-
</data>
13231314
<data name="TransportHeaderType5" xml:space="preserve">
13241315
<value>Mode XHTTP</value>
13251316
</data>
@@ -1710,4 +1701,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
17101701
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
17111702
<value>Only for fetching self-signed certificates. This may expose you to MITM risks.</value>
17121703
</data>
1704+
<data name="TbSettingsSendThrough" xml:space="preserve">
1705+
<value>Adresse sortante locale (SendThrough)</value>
1706+
</data>
1707+
<data name="TbSettingsSendThroughTip" xml:space="preserve">
1708+
<value>Pour environnements multi-interfaces, entrez l'adresse IPv4 de la machine locale</value>
1709+
</data>
1710+
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
1711+
<value>Veuillez saisir l’adresse IPv4 correcte de SendThrough.</value>
1712+
</data>
1713+
<data name="TbSettingsBindInterface" xml:space="preserve">
1714+
<value>Lier l'interface</value>
1715+
</data>
1716+
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
1717+
<value>Pour les environnements multi-interfaces, entrez le nom de l'interface à lier. Ne fonctionne que sur les systèmes Windows et en mode TUN</value>
1718+
</data>
17131719
</root>

v2rayN/ServiceLib/Resx/ResUI.hu.resx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,9 +1689,6 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
16891689
<data name="TbLegacyProtect" xml:space="preserve">
16901690
<value>Legacy TUN Protect</value>
16911691
</data>
1692-
<data name="TbSettingsSendThroughTip" xml:space="preserve">
1693-
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
1694-
</data>
16951692
<data name="TbCamouflageDomain" xml:space="preserve">
16961693
<value>Álcázási tartomány</value>
16971694
</data>
@@ -1713,4 +1710,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
17131710
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
17141711
<value>UDP Test Url</value>
17151712
</data>
1713+
<data name="TbSettingsSendThrough" xml:space="preserve">
1714+
<value>Local outbound address (SendThrough)</value>
1715+
</data>
1716+
<data name="TbSettingsSendThroughTip" xml:space="preserve">
1717+
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
1718+
</data>
1719+
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
1720+
<value>Please fill in the correct IPv4 address for SendThrough.</value>
1721+
</data>
1722+
<data name="TbSettingsBindInterface" xml:space="preserve">
1723+
<value>Bind Interface</value>
1724+
</data>
1725+
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
1726+
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems and TUN mode</value>
1727+
</data>
17161728
</root>

v2rayN/ServiceLib/Resx/ResUI.resx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,15 +1314,6 @@
13141314
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
13151315
<value>The password will be validated via the command line. If a validation error causes the application to malfunction, please restart the application. The password will not be stored and must be entered again after each restart.</value>
13161316
</data>
1317-
<data name="TbSettingsSendThrough" xml:space="preserve">
1318-
<value>Local outbound address (SendThrough)</value>
1319-
</data>
1320-
<data name="TbSettingsSendThroughTip" xml:space="preserve">
1321-
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
1322-
</data>
1323-
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
1324-
<value>Please fill in the correct IPv4 address for SendThrough.</value>
1325-
</data>
13261317
<data name="TransportHeaderType5" xml:space="preserve">
13271318
<value>xhttp mode</value>
13281319
</data>
@@ -1719,4 +1710,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
17191710
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
17201711
<value>UDP Test Url</value>
17211712
</data>
1722-
</root>
1713+
<data name="TbSettingsSendThrough" xml:space="preserve">
1714+
<value>Local outbound address (SendThrough)</value>
1715+
</data>
1716+
<data name="TbSettingsSendThroughTip" xml:space="preserve">
1717+
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
1718+
</data>
1719+
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
1720+
<value>Please fill in the correct IPv4 address for SendThrough.</value>
1721+
</data>
1722+
<data name="TbSettingsBindInterface" xml:space="preserve">
1723+
<value>Bind Interface</value>
1724+
</data>
1725+
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
1726+
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems and TUN mode</value>
1727+
</data>
1728+
</root>

v2rayN/ServiceLib/Resx/ResUI.ru.resx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,9 +1689,6 @@
16891689
<data name="TbLegacyProtect" xml:space="preserve">
16901690
<value>Устаревшая защита TUN (Legacy Protect)</value>
16911691
</data>
1692-
<data name="TbSettingsSendThroughTip" xml:space="preserve">
1693-
<value>Для среды с несколькими сетевыми интерфейсами укажите IPv4-адрес локального компьютера</value>
1694-
</data>
16951692
<data name="TbCamouflageDomain" xml:space="preserve">
16961693
<value>Камуфляжный домен</value>
16971694
</data>
@@ -1713,10 +1710,19 @@
17131710
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
17141711
<value>URL для UDP-теста</value>
17151712
</data>
1713+
<data name="TbSettingsSendThrough" xml:space="preserve">
1714+
<value>Локальный исходящий адрес (SendThrough)</value>
1715+
</data>
1716+
<data name="TbSettingsSendThroughTip" xml:space="preserve">
1717+
<value>Для среды с несколькими сетевыми интерфейсами укажите IPv4-адрес локального компьютера</value>
1718+
</data>
17161719
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
17171720
<value>Укажите корректный IPv4-адрес для SendThrough.</value>
17181721
</data>
1719-
<data name="TbSettingsSendThrough" xml:space="preserve">
1720-
<value>Локальный исходящий адрес (SendThrough)</value>
1722+
<data name="TbSettingsBindInterface" xml:space="preserve">
1723+
<value>Привязать интерфейс</value>
1724+
</data>
1725+
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
1726+
<value>Для среды с несколькими сетевыми интерфейсами укажите имя интерфейса для привязки. Работает только в Windows и режиме TUN</value>
17211727
</data>
1722-
</root>
1728+
</root>

0 commit comments

Comments
 (0)