diff --git a/v2rayN/ServiceLib/Models/SingboxConfig.cs b/v2rayN/ServiceLib/Models/SingboxConfig.cs index 2c616776..f0e74e19 100644 --- a/v2rayN/ServiceLib/Models/SingboxConfig.cs +++ b/v2rayN/ServiceLib/Models/SingboxConfig.cs @@ -1,3 +1,5 @@ +using System.Text.Json.Serialization; + namespace ServiceLib.Models; public class SingboxConfig @@ -226,7 +228,7 @@ public class Server4Sbox public string? type { get; set; } public string? server { get; set; } public string? server_resolver { get; set; } - //public string? interface { get; set; } + [JsonPropertyName("interface")] public string? Interface { get; set; } } public class Experimental4Sbox diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 303c57a3..a99678b1 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -1314,7 +1314,7 @@ public class CoreConfigSingboxService var tag = "local_local"; var localDnsAddress = string.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.SingboxDomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress; string? localDnsType = null; - //string? dhcpDnsInterface = null; + string? dhcpDnsInterface = null; if (localDnsAddress == "local") { localDnsType = "local"; @@ -1323,8 +1323,12 @@ public class CoreConfigSingboxService else if (localDnsAddress.StartsWith("dhcp") && localDnsAddress.Length > 7) { localDnsType = "dhcp"; - // // dhcp:// - // dhcpDnsInterface = localDnsAddress.Substring(7); + // dhcp:// + dhcpDnsInterface = localDnsAddress.Substring(7); + if (dhcpDnsInterface == "auto") + { + dhcpDnsInterface = null; + } localDnsAddress = null; } else if (localDnsAddress.StartsWith("tcp") && localDnsAddress.Length > 6) @@ -1360,7 +1364,8 @@ public class CoreConfigSingboxService { tag = tag, type = localDnsType, - server = localDnsAddress + server = localDnsAddress, + Interface = dhcpDnsInterface }); dns4Sbox.rules.Insert(0, new() {