@@ -82,28 +82,28 @@ enum State: Equatable {
82
82
case error( BlockingData )
83
83
}
84
84
85
- /// Policy describing what WG key to use for tunnel communication.
86
- enum KeyPolicy {
87
- /// Use current key stored in device data.
88
- case useCurrent
89
-
90
- /// Use prior key until timer fires.
91
- case usePrior( _ priorKey: PrivateKey , _ timerTask: AutoCancellingTask )
92
- }
93
-
94
85
/// Enum describing network availability.
95
86
public enum NetworkReachability : Equatable , Codable {
96
87
case undetermined, reachable, unreachable
97
88
}
98
89
99
90
protocol StateAssociatedData {
100
91
var currentKey : PrivateKey ? { get set }
101
- var keyPolicy : KeyPolicy { get set }
92
+ var keyPolicy : State . KeyPolicy { get set }
102
93
var networkReachability : NetworkReachability { get set }
103
94
var lastKeyRotation : Date ? { get set }
104
95
}
105
96
106
97
extension State {
98
+ /// Policy describing what WG key to use for tunnel communication.
99
+ enum KeyPolicy {
100
+ /// Use current key stored in device data.
101
+ case useCurrent
102
+
103
+ /// Use prior key until timer fires.
104
+ case usePrior( _ priorKey: PrivateKey , _ timerTask: AutoCancellingTask )
105
+ }
106
+
107
107
/// Data associated with states that hold connection data.
108
108
struct ConnectionData : Equatable , StateAssociatedData {
109
109
/// Current selected relay.
@@ -173,7 +173,7 @@ extension State {
173
173
public var recoveryTask : AutoCancellingTask ?
174
174
175
175
/// Prior state of the actor before entering blocked state
176
- public var priorState : StatePriorToBlockedState
176
+ public var priorState : PriorState
177
177
}
178
178
}
179
179
@@ -214,14 +214,11 @@ public enum BlockedStateReason: String, Codable, Equatable {
214
214
case unknown
215
215
}
216
216
217
- /// Legal states that can precede error state.
218
- enum StatePriorToBlockedState : Equatable {
219
- case initial, connecting, connected, reconnecting
220
- }
221
-
222
- /// Target state the actor should transition into upon request to either start (connect) or reconnect.
223
- enum TargetStateForReconnect {
224
- case reconnecting, connecting
217
+ extension State . BlockingData {
218
+ /// Legal states that can precede error state.
219
+ enum PriorState : Equatable {
220
+ case initial, connecting, connected, reconnecting
221
+ }
225
222
}
226
223
227
224
/// Describes which relay the tunnel should connect to next.
@@ -235,13 +232,3 @@ public enum NextRelay: Equatable, Codable {
235
232
/// Use pre-selected relay.
236
233
case preSelected( SelectedRelay )
237
234
}
238
-
239
- /// Describes the reason for reconnection request.
240
- enum ReconnectReason {
241
- /// Initiated by user.
242
- case userInitiated
243
-
244
- /// Initiated by tunnel monitor due to loss of connectivity.
245
- /// Actor will increment the connection attempt counter before picking next relay.
246
- case connectionLoss
247
- }
0 commit comments