Redefine generic Session.serverConfiguration()

For reuse in Session implementations.
This commit is contained in:
Davide De Rosa 2020-06-13 01:17:21 +02:00
parent 68f308934a
commit a232af1100
3 changed files with 9 additions and 2 deletions

View File

@ -70,6 +70,13 @@ public protocol Session {
*/ */
func dataCount() -> (Int, Int)? func dataCount() -> (Int, Int)?
/**
Returns the current server configuration.
- Returns: The current server configuration, represented as a generic object.
*/
func serverConfiguration() -> Any?
/** /**
Shuts down the session with an optional `Error` reason. Does nothing if the session is already stopped or about to stop. Shuts down the session with an optional `Error` reason. Does nothing if the session is already stopped or about to stop.

View File

@ -293,7 +293,7 @@ open class OpenVPNTunnelProvider: NEPacketTunnelProvider {
} }
case .serverConfiguration: case .serverConfiguration:
if let cfg = session?.serverConfiguration() { if let cfg = session?.serverConfiguration() as? OpenVPN.Configuration {
let encoder = JSONEncoder() let encoder = JSONEncoder()
response = try? encoder.encode(cfg) response = try? encoder.encode(cfg)
} }

View File

@ -309,7 +309,7 @@ public class OpenVPNSession: Session {
return controlChannel.currentDataCount() return controlChannel.currentDataCount()
} }
public func serverConfiguration() -> OpenVPN.Configuration? { public func serverConfiguration() -> Any? {
return pushReply?.options return pushReply?.options
} }