Expose server configuration via provider message
This commit is contained in:
parent
74ec321946
commit
7608ae2e3c
|
@ -51,6 +51,11 @@ extension OpenVPNTunnelProvider {
|
|||
/// Data is 16 bytes: low 8 = received, high 8 = sent.
|
||||
public static let dataCount = Message(0xfe)
|
||||
|
||||
/// Requests the configuration pulled from the server (if connected and available).
|
||||
///
|
||||
/// Data is JSON (Decodable).
|
||||
public static let serverConfiguration = Message(0xfd)
|
||||
|
||||
/// The underlying raw message `Data` to forward to the tunnel via IPC.
|
||||
public let data: Data
|
||||
|
||||
|
|
|
@ -277,6 +277,12 @@ open class OpenVPNTunnelProvider: NEPacketTunnelProvider {
|
|||
response?.append(UInt64(dataCount.1)) // outbound
|
||||
}
|
||||
|
||||
case .serverConfiguration:
|
||||
if let cfg = session?.serverConfiguration() {
|
||||
let encoder = JSONEncoder()
|
||||
response = try? encoder.encode(cfg)
|
||||
}
|
||||
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
|
|
@ -308,6 +308,10 @@ public class OpenVPNSession: Session {
|
|||
return controlChannel.currentDataCount()
|
||||
}
|
||||
|
||||
public func serverConfiguration() -> OpenVPN.Configuration? {
|
||||
return pushReply?.options
|
||||
}
|
||||
|
||||
public func shutdown(error: Error?) {
|
||||
guard !isStopping else {
|
||||
log.warning("Ignore stop request, already stopping!")
|
||||
|
|
Loading…
Reference in New Issue