Add custom on-demand rules support

This commit is contained in:
世界
2025-12-30 00:18:43 +08:00
parent 6de410c3f7
commit 58b5e9d732
13 changed files with 1310 additions and 59 deletions
@@ -248,12 +248,12 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
}
private func onUpdateDefaultInterface(_ listener: LibboxInterfaceUpdateListenerProtocol, _ path: Network.NWPath) {
if path.status == .unsatisfied {
guard path.status != .unsatisfied,
let defaultInterface = path.availableInterfaces.first else {
listener.updateDefaultInterface("", interfaceIndex: -1, isExpensive: false, isConstrained: false)
} else {
let defaultInterface = path.availableInterfaces.first!
listener.updateDefaultInterface(defaultInterface.name, interfaceIndex: Int32(defaultInterface.index), isExpensive: path.isExpensive, isConstrained: path.isConstrained)
return
}
listener.updateDefaultInterface(defaultInterface.name, interfaceIndex: Int32(defaultInterface.index), isExpensive: path.isExpensive, isConstrained: path.isConstrained)
}
public func closeDefaultInterfaceMonitor(_: LibboxInterfaceUpdateListenerProtocol?) throws {
@@ -356,6 +356,18 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
#endif
}
public func readWIFISSID() -> String? {
#if os(iOS)
return runBlocking {
await NEHotspotNetwork.fetchCurrent()?.ssid
}
#elseif os(macOS)
return CWWiFiClient.shared().interface()?.ssid()
#else
return nil
#endif
}
public func serviceStop() throws {
tunnel.stopService()
}