Skip to content

Commit

Permalink
Add missing FirewallPolicyError class
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Nov 17, 2023
1 parent 0a82036 commit efeac6d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import net.mullvad.mullvadvpn.ui.VersionInfo
import net.mullvad.mullvadvpn.ui.notification.StatusLevel
import net.mullvad.talpid.tunnel.ErrorState
import net.mullvad.talpid.tunnel.ErrorStateCause
import net.mullvad.talpid.tunnel.FirewallPolicyError
import org.joda.time.DateTime

@Preview
Expand All @@ -61,7 +62,13 @@ private fun PreviewNotificationBanner() {
InAppNotification.TunnelStateBlocked,
InAppNotification.NewDevice("Courageous Turtle"),
InAppNotification.TunnelStateError(
error = ErrorState(ErrorStateCause.SetFirewallPolicyError, true)
error =
ErrorState(
ErrorStateCause.SetFirewallPolicyError(
FirewallPolicyError.Generic
),
true
)
)
)
.map { it.toNotificationData({}, {}, {}) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import net.mullvad.talpid.net.TunnelEndpoint
import net.mullvad.talpid.tunnel.ActionAfterDisconnect
import net.mullvad.talpid.tunnel.ErrorState
import net.mullvad.talpid.tunnel.ErrorStateCause
import net.mullvad.talpid.tunnel.FirewallPolicyError

sealed class TunnelState : Parcelable {
@Parcelize object Disconnected : TunnelState(), Parcelable
Expand Down Expand Up @@ -73,9 +74,20 @@ sealed class TunnelState : Parcelable {
DISCONNECTING -> Disconnecting(ActionAfterDisconnect.Nothing)
BLOCKING -> Error(ErrorState(ErrorStateCause.StartTunnelError, true))
ERROR -> {
Error(ErrorState(ErrorStateCause.SetFirewallPolicyError, false))
Error(
ErrorState(
ErrorStateCause.SetFirewallPolicyError(FirewallPolicyError.Generic),
false
)
)
}
else -> Error(ErrorState(ErrorStateCause.SetFirewallPolicyError, false))
else ->
Error(
ErrorState(
ErrorStateCause.SetFirewallPolicyError(FirewallPolicyError.Generic),
false
)
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@ sealed class ErrorStateCause : Parcelable {
}
}

@Parcelize object Ipv6Unavailable : ErrorStateCause()
@Parcelize data object Ipv6Unavailable : ErrorStateCause()

@Parcelize object SetFirewallPolicyError : ErrorStateCause()
@Parcelize
data class SetFirewallPolicyError(val firewallPolicyError: FirewallPolicyError) :
ErrorStateCause()

@Parcelize object SetDnsError : ErrorStateCause()
@Parcelize data object SetDnsError : ErrorStateCause()

@Parcelize class InvalidDnsServers(val addresses: ArrayList<InetAddress>) : ErrorStateCause()
@Parcelize
data class InvalidDnsServers(val addresses: ArrayList<InetAddress>) : ErrorStateCause()

@Parcelize object StartTunnelError : ErrorStateCause()
@Parcelize data object StartTunnelError : ErrorStateCause()

@Parcelize class TunnelParameterError(val error: ParameterGenerationError) : ErrorStateCause()
@Parcelize
data class TunnelParameterError(val error: ParameterGenerationError) : ErrorStateCause()

@Parcelize object IsOffline : ErrorStateCause()
@Parcelize data object IsOffline : ErrorStateCause()

@Parcelize object VpnPermissionDenied : ErrorStateCause()
@Parcelize data object VpnPermissionDenied : ErrorStateCause()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.mullvad.talpid.tunnel

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
enum class FirewallPolicyError : Parcelable {
Generic
}
1 change: 1 addition & 0 deletions mullvad-jni/src/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@ pub const CLASSES: &[&str] = &[
"net/mullvad/talpid/CreateTunResult$InvalidDnsServers",
"net/mullvad/talpid/CreateTunResult$PermissionDenied",
"net/mullvad/talpid/CreateTunResult$TunnelDeviceError",
"net/mullvad/talpid/tunnel/FirewallPolicyError",
"net/mullvad/talpid/TalpidVpnService",
];

0 comments on commit efeac6d

Please sign in to comment.