Skip to content

Commit 285f1a3

Browse files
committed
WIP
1 parent 31f52fd commit 285f1a3

File tree

7 files changed

+20
-26
lines changed

7 files changed

+20
-26
lines changed

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Line wrap the file at 100 chars. Th
3131

3232
### Fixed
3333
- Fix `mullvad-cli` panicking if it tried to write to a closed pipe on Linux and macOS.
34-
- Will no longer try to connect over IPv4 if IPv4 is not available.
3534

3635
#### Windows
3736
- Fix error setting up tunnel when MTU was incorrectly set to a value below 1280 for IPv6.

android/CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Line wrap the file at 100 chars. Th
3838

3939
### Fixed
4040
- Will no longer try to connect over IPv6 if IPv6 is not available.
41-
- Will no longer try to connect over IPv4 if IPv4 is not available.
4241

4342

4443
## [android/2025.1-beta1] - 2025-03-05

android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreenTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class VpnSettingsScreenTest {
7474
navigateToUdp2TcpSettings: () -> Unit = {},
7575
onToggleAutoStartAndConnectOnBoot: (Boolean) -> Unit = {},
7676
onSelectDeviceIpVersion: (Constraint<IpVersion>) -> Unit = {},
77-
onToggleIPv6Toggle: (Boolean) -> Unit = {},
77+
onToggleIpv6Toggle: (Boolean) -> Unit = {},
7878
) {
7979
setContentWithTheme {
8080
VpnSettingsScreen(
@@ -107,7 +107,7 @@ class VpnSettingsScreenTest {
107107
navigateToUdp2TcpSettings = navigateToUdp2TcpSettings,
108108
onToggleAutoStartAndConnectOnBoot = onToggleAutoStartAndConnectOnBoot,
109109
onSelectDeviceIpVersion = onSelectDeviceIpVersion,
110-
onToggleIpv6Toggle = onToggleIPv6Toggle,
110+
onToggleIpv6Toggle = onToggleIpv6Toggle,
111111
)
112112
}
113113
}

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fun VpnSettings(
272272
dropUnlessResumed { navigator.navigate(Udp2TcpSettingsDestination) },
273273
onToggleAutoStartAndConnectOnBoot = vm::onToggleAutoStartAndConnectOnBoot,
274274
onSelectDeviceIpVersion = vm::onDeviceIpVersionSelected,
275-
onToggleIpv6Toggle = vm::setIpV6Enabled,
275+
onToggleIpv6Toggle = vm::setIpv6Enabled,
276276
)
277277
}
278278

android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/SettingsRepository.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ class SettingsRepository(
7575

7676
suspend fun setDaitaDirectOnly(enabled: Boolean) = managementService.setDaitaDirectOnly(enabled)
7777

78-
suspend fun setIpV6Enabled(enabled: Boolean) = managementService.setIpv6Enabled(enabled)
78+
suspend fun setIpv6Enabled(enabled: Boolean) = managementService.setIpv6Enabled(enabled)
7979
}

android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/DnsDialogViewModel.kt

+14-18
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,27 @@ sealed interface DnsDialogSideEffect {
3535
data class DnsDialogViewState(
3636
val input: String,
3737
val validationError: ValidationError?,
38-
val isLocal: Boolean,
3938
val isAllowLanEnabled: Boolean,
40-
val isIpv6: Boolean,
4139
val isIpv6Enabled: Boolean,
4240
val index: Int?,
4341
) {
4442
val isNewEntry = index == null
43+
val isIpv6: Boolean = input.isIpv6()
44+
val isLocal: Boolean = input.isLocalAddress()
4545

4646
fun isValid() = validationError == null
47+
48+
private fun String.isLocalAddress(): Boolean {
49+
return isValid() && InetAddress.getByName(this).isLocalAddress()
50+
}
51+
52+
private fun String.isIpv6(): Boolean {
53+
return isValid() && InetAddress.getByName(this) is Inet6Address
54+
}
55+
56+
private fun InetAddress.isLocalAddress(): Boolean {
57+
return isLinkLocalAddress || isSiteLocalAddress
58+
}
4759
}
4860

4961
sealed class ValidationError {
@@ -74,8 +86,6 @@ class DnsDialogViewModel(
7486
input = input,
7587
validationError =
7688
input.validateDnsEntry(currentIndex, settings.addresses()).leftOrNull(),
77-
isLocal = input.isLocalAddress(),
78-
isIpv6 = input.isIpv6(),
7989
isAllowLanEnabled = settings.allowLan,
8090
isIpv6Enabled = settings.tunnelOptions.genericOptions.enableIpv6,
8191
index = currentIndex,
@@ -87,8 +97,6 @@ class DnsDialogViewModel(
8797
DnsDialogViewState(
8898
input = _ipAddressInput.value,
8999
validationError = null,
90-
isLocal = _ipAddressInput.value.isLocalAddress(),
91-
isIpv6 = _ipAddressInput.value.isIpv6(),
92100
isAllowLanEnabled = false,
93101
isIpv6Enabled = false,
94102
index = null,
@@ -153,18 +161,6 @@ class DnsDialogViewModel(
153161
return inetAddressValidator.isValid(this)
154162
}
155163

156-
private fun String.isLocalAddress(): Boolean {
157-
return isValidIp() && InetAddress.getByName(this).isLocalAddress()
158-
}
159-
160-
private fun String.isIpv6(): Boolean {
161-
return isValidIp() && InetAddress.getByName(this) is Inet6Address
162-
}
163-
164-
private fun InetAddress.isLocalAddress(): Boolean {
165-
return isLinkLocalAddress || isSiteLocalAddress
166-
}
167-
168164
private fun InetAddress.isDuplicateDnsEntry(
169165
currentIndex: Int? = null,
170166
dnsList: List<InetAddress>,

android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModel.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ class VpnSettingsViewModel(
255255
}
256256
}
257257

258-
fun setIpV6Enabled(enable: Boolean) {
258+
fun setIpv6Enabled(enable: Boolean) {
259259
viewModelScope.launch(dispatcher) {
260-
repository.setIpV6Enabled(enable).onLeft {
260+
repository.setIpv6Enabled(enable).onLeft {
261261
_uiSideEffect.send(VpnSettingsSideEffect.ShowToast.GenericError)
262262
}
263263
}

0 commit comments

Comments
 (0)