Add implementation for stop command
This adds implementation for stopping the tunnel via the `Stop` command.
This commit is contained in:
parent
29d2bfae3f
commit
c4c342dc8b
5 changed files with 81 additions and 38 deletions
|
|
@ -44,6 +44,17 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
}
|
||||
}
|
||||
|
||||
override func stopTunnel(with reason: NEProviderStopReason) async {
|
||||
do {
|
||||
let client = try Client()
|
||||
let command = BurrowRequest(id: 0, command: "Stop")
|
||||
let data = try await client.request(command, type: Response<BurrowResult<String>>.self)
|
||||
self.logger.log("Stopped client.")
|
||||
} catch {
|
||||
self.logger.error("Failed to stop tunnel: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
private func generateTunSettings(from: ServerConfigData) -> NETunnelNetworkSettings? {
|
||||
let cfig = from.ServerConfig
|
||||
let nst = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "1.1.1.1")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue