blob: 1644597b94367a49a2dc9f12780ebbdb50f039a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
//
// WireGuardAdapter+Async.swift
// PacketTunnel
//
// Created by pronebird on 30/06/2023.
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
//
import Foundation
import WireGuardKit
extension WireGuardAdapter {
func start(tunnelConfiguration: TunnelConfiguration) async throws {
return try await withCheckedThrowingContinuation { continuation in
start(tunnelConfiguration: tunnelConfiguration) { error in
if let error {
continuation.resume(throwing: error)
} else {
continuation.resume(returning: ())
}
}
}
}
func stop() async throws {
return try await withCheckedThrowingContinuation { continuation in
stop { error in
if let error {
continuation.resume(throwing: error)
} else {
continuation.resume(returning: ())
}
}
}
}
func update(tunnelConfiguration: TunnelConfiguration) async throws {
return try await withCheckedThrowingContinuation { continuation in
update(tunnelConfiguration: tunnelConfiguration) { error in
if let error {
continuation.resume(throwing: error)
} else {
continuation.resume(returning: ())
}
}
}
}
}
|