Fix missing async in Demo

This commit is contained in:
Davide De Rosa 2022-04-12 20:47:58 +02:00
parent 6e7eab421e
commit 7b72114893
3 changed files with 43 additions and 27 deletions

View File

@ -80,7 +80,9 @@ class OpenVPNViewController: UIViewController {
object: nil object: nil
) )
vpn.prepare() Task {
await vpn.prepare()
}
// testFetchRef() // testFetchRef()
} }
@ -123,15 +125,17 @@ class OpenVPNViewController: UIViewController {
return return
} }
Task {
var extra = NetworkExtensionExtra() var extra = NetworkExtensionExtra()
extra.passwordReference = passwordReference extra.passwordReference = passwordReference
vpn.reconnect( try await vpn.reconnect(
tunnelIdentifier, tunnelIdentifier,
configuration: cfg!, configuration: cfg!,
extra: extra, extra: extra,
after: .seconds(2) after: .seconds(2)
) )
} }
}
func disconnect() { func disconnect() {
Task { Task {

View File

@ -75,7 +75,9 @@ class OpenVPNViewController: NSViewController {
object: nil object: nil
) )
vpn.prepare() Task {
await vpn.prepare()
}
// testFetchRef() // testFetchRef()
} }
@ -114,18 +116,22 @@ class OpenVPNViewController: NSViewController {
return return
} }
Task {
var extra = NetworkExtensionExtra() var extra = NetworkExtensionExtra()
extra.passwordReference = passwordReference extra.passwordReference = passwordReference
vpn.reconnect( try await vpn.reconnect(
tunnelIdentifier, tunnelIdentifier,
configuration: cfg!, configuration: cfg!,
extra: extra, extra: extra,
after: .seconds(2) after: .seconds(2)
) )
} }
}
func disconnect() { func disconnect() {
vpn.disconnect() Task {
await vpn.disconnect()
}
} }
func updateButton() { func updateButton() {

View File

@ -72,7 +72,9 @@ class WireGuardViewController: NSViewController {
object: nil object: nil
) )
vpn.prepare() Task {
await vpn.prepare()
}
} }
@IBAction func connectionClicked(_ sender: Any) { @IBAction func connectionClicked(_ sender: Any) {
@ -105,16 +107,20 @@ class WireGuardViewController: NSViewController {
return return
} }
vpn.reconnect( Task {
try await vpn.reconnect(
tunnelIdentifier, tunnelIdentifier,
configuration: cfg, configuration: cfg,
extra: nil, extra: nil,
after: .seconds(2) after: .seconds(2)
) )
} }
}
func disconnect() { func disconnect() {
vpn.disconnect() Task {
await vpn.disconnect()
}
} }
func updateButton() { func updateButton() {