From f9fa896326f4738aee7e3f0fd6bd8888a30f48cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 11 Mar 2026 17:53:46 +0800 Subject: [PATCH] Set DNS matchDomains when include routes have no default route Without this, the system ignores the NE's DNS server when IPv4 include routes don't contain 0.0.0.0/0 (e.g. segment routing). Only applied conditionally to avoid breaking macOS Internet Sharing. --- .../Views/Setting/ProfileOverrideView.swift | 1 + Library/Network/ExtensionPlatformInterface.swift | 8 ++++++++ Localizable.xcstrings | 10 +++++----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ApplicationLibrary/Views/Setting/ProfileOverrideView.swift b/ApplicationLibrary/Views/Setting/ProfileOverrideView.swift index 6049345..ede6aa6 100644 --- a/ApplicationLibrary/Views/Setting/ProfileOverrideView.swift +++ b/ApplicationLibrary/Views/Setting/ProfileOverrideView.swift @@ -28,6 +28,7 @@ public struct ProfileOverrideView: View { FormToggle("No Default Route", """ By default, segment routing is used in `auto_route` instead of global routing. If `` exists in the configuration, this item will not take effect on the corresponding network (commonly used to resolve HomeKit compatibility issues). + On macOS, enabling this option will cause Internet Sharing to not work properly. """, $autoRouteUseSubRangesByDefault) { newValue in await SharedPreferences.autoRouteUseSubRangesByDefault.set(newValue) await reloadService() diff --git a/Library/Network/ExtensionPlatformInterface.swift b/Library/Network/ExtensionPlatformInterface.swift index a985b77..cbb3797 100644 --- a/Library/Network/ExtensionPlatformInterface.swift +++ b/Library/Network/ExtensionPlatformInterface.swift @@ -146,6 +146,14 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc ipv6Settings.includedRoutes = ipv6Routes ipv6Settings.excludedRoutes = ipv6ExcludeRoutes settings.ipv6Settings = ipv6Settings + + let hasDefaultRoute = ipv4Routes.contains(where: { + $0.destinationAddress == "0.0.0.0" && $0.destinationSubnetMask == "0.0.0.0" + }) + if !hasDefaultRoute { + dnsSettings.matchDomains = [""] + dnsSettings.matchDomainsNoSearch = true + } } if options.isHTTPProxyEnabled() { diff --git a/Localizable.xcstrings b/Localizable.xcstrings index 112ace2..6d0a360 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -1063,30 +1063,30 @@ } } }, - "By default, segment routing is used in `auto_route` instead of global routing.\nIf `` exists in the configuration, this item will not take effect on the corresponding network (commonly used to resolve HomeKit compatibility issues)." : { + "By default, segment routing is used in `auto_route` instead of global routing.\nIf `` exists in the configuration, this item will not take effect on the corresponding network (commonly used to resolve HomeKit compatibility issues).\nOn macOS, enabling this option will cause Internet Sharing to not work properly." : { "localizations" : { "fa" : { "stringUnit" : { "state" : "translated", - "value" : "به‌صورت پیش‌فرض در `auto_route` از مسیریابی بخشی استفاده می‌شود، نه مسیریابی سراسری.\nاگر `` در پیکربندی وجود داشته باشد، این گزینه در شبکه مربوطه اعمال نمی‌شود (معمولاً برای حل مشکلات سازگاری HomeKit استفاده می‌شود)." + "value" : "به‌صورت پیش‌فرض در `auto_route` از مسیریابی بخشی استفاده می‌شود، نه مسیریابی سراسری.\nاگر `` در پیکربندی وجود داشته باشد، این گزینه در شبکه مربوطه اعمال نمی‌شود (معمولاً برای حل مشکلات سازگاری HomeKit استفاده می‌شود).\nدر macOS، فعال کردن این گزینه باعث می‌شود Internet Sharing به درستی کار نکند." } }, "ru" : { "stringUnit" : { "state" : "translated", - "value" : "По умолчанию в `auto_route` используется сегментная маршрутизация, а не глобальная.\nЕсли в конфигурации есть ``, этот пункт не вступит в силу в соответствующей сети (обычно используется для решения проблем совместимости с HomeKit)." + "value" : "По умолчанию в `auto_route` используется сегментная маршрутизация, а не глобальная.\nЕсли в конфигурации есть ``, этот пункт не вступит в силу в соответствующей сети (обычно используется для решения проблем совместимости с HomeKit).\nНа macOS включение этой опции приведёт к неработоспособности Общего интернета (Internet Sharing)." } }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "在默认情况下,`auto_route` 中使用分段路由,而非全局路由。\n若配置中存在 ``,则此项不会在对应网络上生效(常用于解决 HomeKit 兼容性问题)。" + "value" : "在默认情况下,`auto_route` 中使用分段路由,而非全局路由。\n若配置中存在 ``,则此项不会在对应网络上生效(常用于解决 HomeKit 兼容性问题)。\n在 macOS 上,启用此选项将导致互联网共享无法正常工作。" } }, "zh-Hant" : { "stringUnit" : { "state" : "translated", - "value" : "在默認情況下,`auto_route` 中使用分段路由,而非全局路由。\n若配置中存在 ``,則此項不會在對應網絡上生效(常用於解決 HomeKit 兼容性問題)。" + "value" : "在默認情況下,`auto_route` 中使用分段路由,而非全局路由。\n若配置中存在 ``,則此項不會在對應網絡上生效(常用於解決 HomeKit 兼容性問題)。\n在 macOS 上,啟用此選項將導致網際網路共享無法正常工作。" } } }