Skip to content

Commit

Permalink
Merge branch 'out-ip-delay'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jontified committed Dec 21, 2023
2 parents ce7f4f7 + 8ed53a0 commit 9d71ecc
Show file tree
Hide file tree
Showing 51 changed files with 356 additions and 714 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ Line wrap the file at 100 chars. Th
* **Security**: in case of vulnerabilities.

## [Unreleased]
### Fixed
#### Linux
- Out IP missing forever when am.i.mullvad.net returns error

### Changed
- Remove `--location` flag from `mullvad status` CLI. Location and IP will now always
be printed (if available). `mullvad status listen` no longer prints location info.

#### Android
- Migrated to Compose Navigation
- Allow for full rotation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = InAppNotification.TunnelStateBlocked,
Expand Down Expand Up @@ -115,7 +114,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = InAppNotification.TunnelStateBlocked,
Expand Down Expand Up @@ -149,7 +147,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = null,
Expand Down Expand Up @@ -182,7 +179,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = null,
Expand Down Expand Up @@ -216,7 +212,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = true,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = null,
Expand Down Expand Up @@ -245,12 +240,11 @@ class ConnectScreenTest {
ConnectUiState(
location = null,
relayLocation = mockRelayLocation,
tunnelUiState = TunnelState.Disconnected,
tunnelRealState = TunnelState.Disconnected,
tunnelUiState = TunnelState.Disconnected(),
tunnelRealState = TunnelState.Disconnected(),
inAddress = null,
outAddress = "",
showLocation = true,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = null,
Expand Down Expand Up @@ -286,7 +280,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = true,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification =
Expand Down Expand Up @@ -326,7 +319,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = true,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification =
Expand Down Expand Up @@ -363,7 +355,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = InAppNotification.TunnelStateBlocked,
Expand Down Expand Up @@ -399,7 +390,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = true,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = InAppNotification.TunnelStateBlocked,
Expand Down Expand Up @@ -430,12 +420,11 @@ class ConnectScreenTest {
ConnectUiState(
location = null,
relayLocation = mockRelayLocation,
tunnelUiState = TunnelState.Disconnected,
tunnelRealState = TunnelState.Disconnected,
tunnelUiState = TunnelState.Disconnected(),
tunnelRealState = TunnelState.Disconnected(),
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = null,
Expand Down Expand Up @@ -468,7 +457,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = null,
Expand Down Expand Up @@ -501,7 +489,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = null,
Expand All @@ -528,12 +515,11 @@ class ConnectScreenTest {
ConnectUiState(
location = null,
relayLocation = null,
tunnelUiState = TunnelState.Disconnected,
tunnelRealState = TunnelState.Disconnected,
tunnelUiState = TunnelState.Disconnected(),
tunnelRealState = TunnelState.Disconnected(),
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = null,
Expand Down Expand Up @@ -565,7 +551,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = null,
Expand All @@ -582,39 +567,6 @@ class ConnectScreenTest {
verify { mockedClickHandler.invoke() }
}

@Test
fun testToggleTunnelInfo() {
// Arrange
val mockedClickHandler: () -> Unit = mockk(relaxed = true)
val dummyLocation = GeoIpLocation(null, null, "dummy country", null, "dummy hostname")
composeTestRule.setContentWithTheme {
ConnectScreen(
uiState =
ConnectUiState(
location = dummyLocation,
relayLocation = null,
tunnelUiState = TunnelState.Connecting(null, null),
tunnelRealState = TunnelState.Connecting(null, null),
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = null,
isPlayBuild = false
),
onToggleTunnelInfo = mockedClickHandler
)
}

// Act
composeTestRule.onNodeWithTag(LOCATION_INFO_TEST_TAG).performClick()

// Assert
verify { mockedClickHandler.invoke() }
}

@Test
fun showLocationInfo() {
// Arrange
Expand All @@ -638,7 +590,6 @@ class ConnectScreenTest {
inAddress = mockInAddress,
outAddress = mockOutAddress,
showLocation = false,
isTunnelInfoExpanded = true,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = null,
Expand All @@ -647,6 +598,8 @@ class ConnectScreenTest {
)
}

composeTestRule.onNodeWithTag(LOCATION_INFO_TEST_TAG).performClick()

// Assert
composeTestRule.apply {
onNodeWithText(mockHostName).assertExists()
Expand Down Expand Up @@ -677,7 +630,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = InAppNotification.UpdateAvailable(versionInfo),
Expand Down Expand Up @@ -714,7 +666,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = InAppNotification.UnsupportedVersion(versionInfo),
Expand Down Expand Up @@ -748,7 +699,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = InAppNotification.AccountExpiry(expiryDate),
Expand Down Expand Up @@ -787,7 +737,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = InAppNotification.UnsupportedVersion(versionInfo),
Expand Down Expand Up @@ -820,7 +769,6 @@ class ConnectScreenTest {
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = InAppNotification.AccountExpiry(expiryDate),
Expand All @@ -838,10 +786,8 @@ class ConnectScreenTest {

@Test
fun testOpenAccountView() {

val onAccountClickMockk: () -> Unit = mockk(relaxed = true)

// Arrange
val onAccountClickMockk: () -> Unit = mockk(relaxed = true)
composeTestRule.setContentWithTheme {
ConnectScreen(uiState = ConnectUiState.INITIAL, onAccountClick = onAccountClickMockk)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import net.mullvad.talpid.tunnel.ErrorStateCause
private fun PreviewConnectionStatusText() {
AppTheme {
SpacedColumn {
ConnectionStatusText(TunnelState.Disconnected)
ConnectionStatusText(TunnelState.Disconnected())
ConnectionStatusText(TunnelState.Connecting(null, null))
ConnectionStatusText(
state = TunnelState.Error(ErrorState(ErrorStateCause.Ipv6Unavailable, true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -108,7 +110,6 @@ fun Connect(navigator: DestinationsNavigator) {
onSwitchLocationClick = {
navigator.navigate(SelectLocationDestination) { launchSingleTop = true }
},
onToggleTunnelInfo = connectViewModel::toggleTunnelInfoExpansion,
onUpdateVersionClick = {
val intent =
Intent(
Expand Down Expand Up @@ -137,7 +138,6 @@ fun ConnectScreen(
onConnectClick: () -> Unit = {},
onCancelClick: () -> Unit = {},
onSwitchLocationClick: () -> Unit = {},
onToggleTunnelInfo: () -> Unit = {},
onUpdateVersionClick: () -> Unit = {},
onManageAccountClick: () -> Unit = {},
onSettingsClick: () -> Unit = {},
Expand Down Expand Up @@ -233,12 +233,13 @@ fun ConnectScreen(
color = MaterialTheme.colorScheme.onPrimary,
modifier = Modifier.padding(horizontal = Dimens.sideMargin)
)
var expanded by rememberSaveable { mutableStateOf(false) }
LocationInfo(
onToggleTunnelInfo = onToggleTunnelInfo,
onToggleTunnelInfo = { expanded = !expanded },
isVisible =
uiState.tunnelRealState != TunnelState.Disconnected &&
uiState.tunnelRealState !is TunnelState.Disconnected &&
uiState.location?.hostname != null,
isExpanded = uiState.isTunnelInfoExpanded,
isExpanded = expanded,
location = uiState.location,
inAddress = uiState.inAddress,
outAddress = uiState.outAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private fun PreviewOutOfTimeScreenDisconnected() {
OutOfTimeScreen(
uiState =
OutOfTimeUiState(
tunnelState = TunnelState.Disconnected,
tunnelState = TunnelState.Disconnected(),
"Heroic Frog",
showSitePayment = true
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ data class ConnectUiState(
val outAddress: String,
val showLocation: Boolean,
val inAppNotification: InAppNotification?,
val isTunnelInfoExpanded: Boolean,
val deviceName: String?,
val daysLeftUntilExpiry: Int?,
val isPlayBuild: Boolean
Expand All @@ -25,12 +24,11 @@ data class ConnectUiState(
ConnectUiState(
location = null,
relayLocation = null,
tunnelUiState = TunnelState.Disconnected,
tunnelRealState = TunnelState.Disconnected,
tunnelUiState = TunnelState.Disconnected(),
tunnelRealState = TunnelState.Disconnected(),
inAddress = null,
outAddress = "",
showLocation = false,
isTunnelInfoExpanded = false,
inAppNotification = null,
deviceName = null,
daysLeftUntilExpiry = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package net.mullvad.mullvadvpn.compose.state
import net.mullvad.mullvadvpn.model.TunnelState

data class OutOfTimeUiState(
val tunnelState: TunnelState = TunnelState.Disconnected,
val tunnelState: TunnelState = TunnelState.Disconnected(),
val deviceName: String = "",
val showSitePayment: Boolean = false,
val billingPaymentState: PaymentState? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package net.mullvad.mullvadvpn.compose.state
import net.mullvad.mullvadvpn.model.TunnelState

data class WelcomeUiState(
val tunnelState: TunnelState = TunnelState.Disconnected,
val tunnelState: TunnelState = TunnelState.Disconnected(),
val accountNumber: String? = null,
val deviceName: String? = null,
val showSitePayment: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const val ANTICIPATED_STATE_TIMEOUT_MS = 1500L
class ConnectionProxy(private val connection: Messenger, eventDispatcher: EventDispatcher) {
private var resetAnticipatedStateJob: Job? = null

val onStateChange = EventNotifier<TunnelState>(TunnelState.Disconnected)
val onUiStateChange = EventNotifier<TunnelState>(TunnelState.Disconnected)
val onStateChange = EventNotifier<TunnelState>(TunnelState.Disconnected())
val onUiStateChange = EventNotifier<TunnelState>(TunnelState.Disconnected())

var state by onStateChange.notifiable()
private set
Expand Down
Loading

0 comments on commit 9d71ecc

Please sign in to comment.