From 4df2c0bec66010ae447dd57210558e38fc04e567 Mon Sep 17 00:00:00 2001 From: yicheng <11733500+yichengchen@users.noreply.github.com> Date: Tue, 5 Sep 2023 09:46:04 +0800 Subject: [PATCH] misc: sync core between ClashX and ClashXPro --- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- .../General/Managers/RemoteConfigManager.swift | 3 ++- ClashX/General/Managers/Settings.swift | 3 --- .../General/Utils/NetworkChangeNotifier.swift | 18 ++++++++++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ClashX.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ClashX.xcworkspace/xcshareddata/swiftpm/Package.resolved index 04a8d00..a900cdd 100644 --- a/ClashX.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ClashX.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/sindresorhus/KeyboardShortcuts.git", "state" : { - "revision" : "b878f8132be59576fc87e39405b1914eff9f55d3", - "version" : "1.14.1" + "revision" : "8b1a9ce78c2f35c8a55dcc95897573abd2cc4f6e", + "version" : "1.13.0" } } ], diff --git a/ClashX/General/Managers/RemoteConfigManager.swift b/ClashX/General/Managers/RemoteConfigManager.swift index a4f5364..3ec9ba9 100755 --- a/ClashX/General/Managers/RemoteConfigManager.swift +++ b/ClashX/General/Managers/RemoteConfigManager.swift @@ -175,7 +175,8 @@ class RemoteConfigManager { if ICloudManager.shared.useiCloud.value { ConfigFileManager.shared.stopWatchConfigFile() - } else if config.name == ConfigManager.selectConfigName { + } + if config.name == ConfigManager.selectConfigName { ConfigFileManager.shared.pauseForNextChange() } diff --git a/ClashX/General/Managers/Settings.swift b/ClashX/General/Managers/Settings.swift index 8a6c93d..643dce3 100644 --- a/ClashX/General/Managers/Settings.swift +++ b/ClashX/General/Managers/Settings.swift @@ -18,9 +18,6 @@ enum Settings { @UserDefault("disableNoti", defaultValue: false) static var disableNoti: Bool - @UserDefault("usePacMode", defaultValue: false) - static var usePacMode: Bool - @UserDefault("configAutoUpdateInterval", defaultValue: 48*60*60) static var configAutoUpdateInterval: TimeInterval diff --git a/ClashX/General/Utils/NetworkChangeNotifier.swift b/ClashX/General/Utils/NetworkChangeNotifier.swift index 39a0486..92c99d9 100644 --- a/ClashX/General/Utils/NetworkChangeNotifier.swift +++ b/ClashX/General/Utils/NetworkChangeNotifier.swift @@ -128,6 +128,24 @@ class NetworkChangeNotifier { return dict?[kSCDynamicStorePropNetPrimaryInterface as String] } + static func getPrimaryIsDhcp() -> Bool { + let store = SCDynamicStoreCreate(nil, "ClashX" as CFString, nil, nil) + if store == nil { + return false + } + + let key = SCDynamicStoreKeyCreateNetworkGlobalEntity(nil, kSCDynamicStoreDomainState, kSCEntNetIPv4) + let dict = SCDynamicStoreCopyValue(store, key) as? [String: String] + + guard let serviceID = dict?[kSCDynamicStorePropNetPrimaryService as String] else { return false } + let dhcpInfoKey = SCDynamicStoreKeyCreateNetworkServiceEntity(nil, + kSCDynamicStoreDomainState, + serviceID as CFString, + kSCEntNetDHCP) + let dhcpInfo = SCDynamicStoreCopyValue(store, dhcpInfoKey) as? [String: Any] + return dhcpInfo != nil + } + static func getCurrentDns() -> [String] { let store = SCDynamicStoreCreate(nil, "ClashX" as CFString, nil, nil) if store == nil {