Add custom on-demand rules support
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user