@@ -15,6 +15,7 @@ final class SettingsInteractor {
15
15
private var tunnelObserver : TunnelObserver ?
16
16
17
17
var didUpdateDeviceState : ( ( DeviceState ) -> Void ) ?
18
+ var didUpdateTunnelSettings : ( ( LatestTunnelSettings ) -> Void ) ?
18
19
19
20
var tunnelSettings : LatestTunnelSettings {
20
21
tunnelManager. settings
@@ -28,41 +29,17 @@ final class SettingsInteractor {
28
29
self . tunnelManager = tunnelManager
29
30
30
31
let tunnelObserver =
31
- TunnelBlockObserver ( didUpdateDeviceState: { [ weak self] _, deviceState, _ in
32
- self ? . didUpdateDeviceState ? ( deviceState)
33
- } )
32
+ TunnelBlockObserver (
33
+ didUpdateDeviceState: { [ weak self] _, deviceState, _ in
34
+ self ? . didUpdateDeviceState ? ( deviceState)
35
+ } ,
36
+ didUpdateTunnelSettings: { [ weak self] _, settings in
37
+ self ? . didUpdateTunnelSettings ? ( settings)
38
+ }
39
+ )
34
40
35
41
tunnelManager. addObserver ( tunnelObserver)
36
42
37
43
self . tunnelObserver = tunnelObserver
38
44
}
39
-
40
- func updateDAITASettings( _ settings: DAITASettings ) {
41
- tunnelManager. updateSettings ( [ . daita( settings) ] )
42
- }
43
-
44
- func evaluateDaitaSettingsCompatibility( _ settings: DAITASettings ) -> DAITASettingsCompatibilityError ? {
45
- guard settings. daitaState. isEnabled else { return nil }
46
-
47
- var tunnelSettings = tunnelSettings
48
- tunnelSettings. daita = settings
49
-
50
- var compatibilityError : DAITASettingsCompatibilityError ?
51
-
52
- do {
53
- _ = try tunnelManager. selectRelays ( tunnelSettings: tunnelSettings)
54
- } catch let error as NoRelaysSatisfyingConstraintsError where error. reason == . noDaitaRelaysFound {
55
- // Return error if no relays could be selected due to DAITA constraints.
56
- compatibilityError = tunnelSettings. tunnelMultihopState. isEnabled ? . multihop : . singlehop
57
- } catch _ as NoRelaysSatisfyingConstraintsError {
58
- // Even if the constraints error is not DAITA specific, if both DAITA and Direct only are enabled,
59
- // we should return a DAITA related error since the current settings would have resulted in the
60
- // relay selector not being able to select a DAITA relay anyway.
61
- if settings. isDirectOnly {
62
- compatibilityError = tunnelSettings. tunnelMultihopState. isEnabled ? . multihop : . singlehop
63
- }
64
- } catch { }
65
-
66
- return compatibilityError
67
- }
68
45
}
0 commit comments