@@ -23,6 +23,7 @@ import net.mullvad.mullvadvpn.constant.WIREGUARD_PRESET_PORTS
23
23
import net.mullvad.mullvadvpn.lib.model.Constraint
24
24
import net.mullvad.mullvadvpn.lib.model.DefaultDnsOptions
25
25
import net.mullvad.mullvadvpn.lib.model.DnsState
26
+ import net.mullvad.mullvadvpn.lib.model.IpVersion
26
27
import net.mullvad.mullvadvpn.lib.model.ObfuscationMode
27
28
import net.mullvad.mullvadvpn.lib.model.Port
28
29
import net.mullvad.mullvadvpn.lib.model.QuantumResistantState
@@ -46,7 +47,7 @@ sealed interface VpnSettingsSideEffect {
46
47
@Suppress(" TooManyFunctions" )
47
48
class VpnSettingsViewModel (
48
49
private val repository : SettingsRepository ,
49
- private val relayListRepository : RelayListRepository ,
50
+ relayListRepository : RelayListRepository ,
50
51
private val systemVpnSettingsUseCase : SystemVpnSettingsAvailableUseCase ,
51
52
private val autoStartAndConnectOnBootRepository : AutoStartAndConnectOnBootRepository ,
52
53
private val wireguardConstraintsRepository : WireguardConstraintsRepository ,
@@ -83,6 +84,7 @@ class VpnSettingsViewModel(
83
84
availablePortRanges = portRanges,
84
85
systemVpnSettingsAvailable = systemVpnSettingsUseCase(),
85
86
autoStartAndConnectOnBoot = autoStartAndConnectOnBoot,
87
+ deviceIpVersion = settings?.getDeviceIpVersion() ? : Constraint .Any ,
86
88
)
87
89
}
88
90
.stateIn(
@@ -122,14 +124,6 @@ class VpnSettingsViewModel(
122
124
}
123
125
}
124
126
125
- fun onToggleDaita (enable : Boolean ) {
126
- viewModelScope.launch(dispatcher) {
127
- repository.setDaitaEnabled(enable).onLeft {
128
- _uiSideEffect .send(VpnSettingsSideEffect .ShowToast .GenericError )
129
- }
130
- }
131
- }
132
-
133
127
fun onDnsDialogDismissed () {
134
128
if (vmState.value.customDnsList.isEmpty()) {
135
129
onToggleCustomDns(enable = false )
@@ -251,6 +245,14 @@ class VpnSettingsViewModel(
251
245
}
252
246
}
253
247
248
+ fun onDeviceIpVersionSelected (ipVersion : Constraint <IpVersion >) {
249
+ viewModelScope.launch(dispatcher) {
250
+ wireguardConstraintsRepository.setDeviceIpVersion(ipVersion).onLeft {
251
+ _uiSideEffect .send(VpnSettingsSideEffect .ShowToast .GenericError )
252
+ }
253
+ }
254
+ }
255
+
254
256
private fun updateDefaultDnsOptionsViaRepository (contentBlockersOption : DefaultDnsOptions ) =
255
257
viewModelScope.launch(dispatcher) {
256
258
repository
@@ -265,7 +267,7 @@ class VpnSettingsViewModel(
265
267
private fun List<String>.asInetAddressList (): List <InetAddress > {
266
268
return try {
267
269
map { InetAddress .getByName(it) }
268
- } catch (ex : UnknownHostException ) {
270
+ } catch (_ : UnknownHostException ) {
269
271
Logger .e(" Error parsing the DNS address list." )
270
272
emptyList()
271
273
}
@@ -290,6 +292,9 @@ class VpnSettingsViewModel(
290
292
private fun Settings.getWireguardPort () =
291
293
relaySettings.relayConstraints.wireguardConstraints.port
292
294
295
+ private fun Settings.getDeviceIpVersion () =
296
+ relaySettings.relayConstraints.wireguardConstraints.ipVersion
297
+
293
298
private fun InetAddress.isLocalAddress (): Boolean {
294
299
return isLinkLocalAddress || isSiteLocalAddress
295
300
}
0 commit comments