diff --git a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/service/tunnel/NymTunnelManager.kt b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/service/tunnel/NymTunnelManager.kt index 748a1711d5..5df7c1695e 100644 --- a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/service/tunnel/NymTunnelManager.kt +++ b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/service/tunnel/NymTunnelManager.kt @@ -21,8 +21,8 @@ import net.nymtech.vpn.backend.Backend import net.nymtech.vpn.backend.Tunnel import net.nymtech.vpn.model.BackendMessage import net.nymtech.vpn.model.Statistics -import nym_vpn_lib.BandwidthStatus -import nym_vpn_lib.VpnException +import nym_vpn_lib.BandwidthEvent +import nym_vpn_lib.BandwidthStatus.NoBandwidth import timber.log.Timber import javax.inject.Inject import javax.inject.Provider @@ -128,7 +128,8 @@ class NymTunnelManager @Inject constructor( private fun onMissingMnemonic() { val message = context.getString(R.string.missing_mnemonic) if (NymVpn.isForeground()) { - emitMessage(BackendMessage.Failure(VpnException.InvalidCredential(details = message))) + // TODO add message for mnemonic + // emitMessage(BackendMessage.Failure(VpnException.InvalidCredential(details = message))) } else { launchMnemonicNotification(message) } @@ -161,32 +162,22 @@ class NymTunnelManager @Inject constructor( private fun launchBackendNotification(backendMessage: BackendMessage) { when (backendMessage) { is BackendMessage.Failure -> { - val launchNotification = when (backendMessage.exception) { - is VpnException.InvalidCredential -> !NymVpn.isForeground() - else -> true - } - if (launchNotification) { - notificationService.showNotification( - title = context.getString(R.string.connection_failed), - description = backendMessage.exception.toUserMessage(context), - ) - } + // TODO if credential error we might need to handle differently if app is in foreground + notificationService.showNotification( + title = context.getString(R.string.connection_failed), + description = backendMessage.reason.toUserMessage(context), + ) } is BackendMessage.BandwidthAlert -> { when (val alert = backendMessage.status) { - BandwidthStatus.NoBandwidth -> { - notificationService.showNotification( - title = context.getString(R.string.bandwidth_alert), - description = context.getString(R.string.no_bandwidth), - ) - } - - is BandwidthStatus.RemainingBandwidth -> { - notificationService.showNotification( - title = context.getString(R.string.bandwidth_alert), - description = context.getString(R.string.low_bandwidth) + " ${alert.bandwidth}", - ) - } + BandwidthEvent.NoBandwidth -> notificationService.showNotification( + title = context.getString(R.string.bandwidth_alert), + description = context.getString(R.string.no_bandwidth), + ) + is BandwidthEvent.RemainingBandwidth -> notificationService.showNotification( + title = context.getString(R.string.bandwidth_alert), + description = context.getString(R.string.low_bandwidth) + " ${alert.v1}", + ) } } BackendMessage.None -> Unit diff --git a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/MainActivity.kt b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/MainActivity.kt index 7c785293e7..660eccbbfa 100644 --- a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/MainActivity.kt +++ b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/MainActivity.kt @@ -38,13 +38,11 @@ import kotlinx.coroutines.delay import net.nymtech.localizationutil.LocaleStorage import net.nymtech.localizationutil.LocaleUtil import net.nymtech.nymvpn.NymVpn -import net.nymtech.nymvpn.R import net.nymtech.nymvpn.manager.shortcut.ShortcutManager import net.nymtech.nymvpn.service.notification.NotificationService import net.nymtech.nymvpn.ui.common.labels.CustomSnackBar import net.nymtech.nymvpn.ui.common.navigation.LocalNavController import net.nymtech.nymvpn.ui.common.navigation.NavBar -import net.nymtech.nymvpn.ui.common.snackbar.SnackbarController import net.nymtech.nymvpn.ui.common.snackbar.SnackbarControllerProvider import net.nymtech.nymvpn.ui.screens.analytics.AnalyticsScreen import net.nymtech.nymvpn.ui.screens.hop.GatewayLocation @@ -67,13 +65,10 @@ import net.nymtech.nymvpn.ui.screens.settings.support.SupportScreen import net.nymtech.nymvpn.ui.theme.NymVPNTheme import net.nymtech.nymvpn.ui.theme.Theme import net.nymtech.nymvpn.util.Constants -import net.nymtech.nymvpn.util.StringValue -import net.nymtech.nymvpn.util.extensions.goFromRoot import net.nymtech.nymvpn.util.extensions.isCurrentRoute import net.nymtech.nymvpn.util.extensions.requestTileServiceStateUpdate import net.nymtech.nymvpn.util.extensions.resetTile import net.nymtech.vpn.model.BackendMessage -import nym_vpn_lib.VpnException import java.util.Locale import javax.inject.Inject @@ -136,16 +131,17 @@ class MainActivity : ComponentActivity() { LaunchedEffect(appState.backendMessage) { when (val message = appState.backendMessage) { is BackendMessage.Failure -> { - when (message.exception) { - is VpnException.InvalidCredential -> { - if (NymVpn.isForeground()) { - SnackbarController.showMessage(StringValue.StringResource(R.string.exception_cred_invalid)) - navController.goFromRoot(Route.Credential) - } - } - - else -> Unit - } + // TODO invalid credential errors? +// when (message.exception) { +// is VpnException.InvalidCredential -> { +// if (NymVpn.isForeground()) { +// SnackbarController.showMessage(StringValue.StringResource(R.string.exception_cred_invalid)) +// navController.goFromRoot(Route.Credential) +// } +// } +// +// else -> Unit +// } } else -> Unit @@ -231,7 +227,7 @@ class MainActivity : ComponentActivity() { composable { FeedbackScreen(appViewModel) } composable { LegalScreen(appViewModel) } composable { - CredentialScreen(appViewModel) + CredentialScreen(appState, appViewModel) } composable { AccountScreen(appViewModel, appState) } composable { diff --git a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/model/StateMessage.kt b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/model/StateMessage.kt index 7f0fbd3b52..7a44a56985 100644 --- a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/model/StateMessage.kt +++ b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/model/StateMessage.kt @@ -1,9 +1,9 @@ package net.nymtech.nymvpn.ui.model import net.nymtech.nymvpn.util.StringValue -import nym_vpn_lib.VpnException +import nym_vpn_lib.ErrorStateReason sealed class StateMessage { data class Status(val message: StringValue) : StateMessage() - data class Error(val exception: VpnException) : StateMessage() + data class Error(val reason: ErrorStateReason) : StateMessage() } diff --git a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainScreen.kt b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainScreen.kt index 71b57d81ca..adfb11356c 100644 --- a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainScreen.kt +++ b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainScreen.kt @@ -171,7 +171,7 @@ fun MainScreen(appViewModel: AppViewModel, appUiState: AppUiState, autoStart: Bo is StateMessage.Error -> StatusInfoLabel( - message = it.exception.toUserMessage(context), + message = it.reason.toUserMessage(context), textColor = CustomColors.error, ) } diff --git a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainViewModel.kt b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainViewModel.kt index a041e5d28b..3e2adfd3fd 100644 --- a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainViewModel.kt +++ b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainViewModel.kt @@ -31,7 +31,7 @@ constructor( var stateMessage = connectionState.stateMessage when (manager.backendMessage) { is BackendMessage.Failure -> { - stateMessage = StateMessage.Error(manager.backendMessage.exception) + stateMessage = StateMessage.Error(manager.backendMessage.reason) } BackendMessage.None -> stateMessage = connectionState.stateMessage is BackendMessage.BandwidthAlert -> Unit diff --git a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/SettingsScreen.kt b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/SettingsScreen.kt index 62a55f161f..aa66623cfa 100644 --- a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/SettingsScreen.kt +++ b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/SettingsScreen.kt @@ -117,7 +117,13 @@ fun SettingsScreen(appViewModel: AppViewModel, appUiState: AppUiState, viewModel }, title = { Text(stringResource(R.string.account), style = MaterialTheme.typography.bodyLarge.copy(MaterialTheme.colorScheme.onSurface)) }, onClick = { - context.openWebUrl(context.getString(R.string.account_url)) + val url = when (appUiState.settings.environment) { + Tunnel.Environment.MAINNET -> context.getString( + R.string.account_url, + ) + else -> context.getString(R.string.account_url_qa) + } + context.openWebUrl(url) }, ), ), diff --git a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/credential/CredentialScreen.kt b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/credential/CredentialScreen.kt index d4ebeca4c6..43d9cec58b 100644 --- a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/credential/CredentialScreen.kt +++ b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/credential/CredentialScreen.kt @@ -41,6 +41,7 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.accompanist.permissions.ExperimentalPermissionsApi import net.nymtech.nymvpn.R +import net.nymtech.nymvpn.ui.AppUiState import net.nymtech.nymvpn.ui.AppViewModel import net.nymtech.nymvpn.ui.Route import net.nymtech.nymvpn.ui.common.buttons.MainStyledButton @@ -55,10 +56,11 @@ import net.nymtech.nymvpn.util.extensions.navigateAndForget import net.nymtech.nymvpn.util.extensions.openWebUrl import net.nymtech.nymvpn.util.extensions.scaledHeight import net.nymtech.nymvpn.util.extensions.scaledWidth +import net.nymtech.vpn.backend.Tunnel @OptIn(ExperimentalPermissionsApi::class) @Composable -fun CredentialScreen(appViewModel: AppViewModel, viewModel: CredentialViewModel = hiltViewModel()) { +fun CredentialScreen(appUiState: AppUiState, appViewModel: AppViewModel, viewModel: CredentialViewModel = hiltViewModel()) { val snackbar = SnackbarController.current val imeState = rememberImeState() val scrollState = rememberScrollState() @@ -219,7 +221,15 @@ fun CredentialScreen(appViewModel: AppViewModel, viewModel: CredentialViewModel val createAccountMessage = buildAnnotatedString { append(stringResource(id = R.string.new_to_nym)) append(" ") - pushStringAnnotation(tag = "create", annotation = stringResource(id = R.string.create_account_link)) + pushStringAnnotation( + tag = "create", + annotation = when (appUiState.settings.environment) { + Tunnel.Environment.MAINNET -> stringResource( + id = R.string.create_account_link, + ) + else -> stringResource(R.string.create_account_link_qa) + }, + ) withStyle(style = SpanStyle(color = MaterialTheme.colorScheme.primary)) { append(stringResource(id = R.string.create_account)) } diff --git a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/environment/EnvironmentScreen.kt b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/environment/EnvironmentScreen.kt index 4dc9008a45..0fffcca4a4 100644 --- a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/environment/EnvironmentScreen.kt +++ b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/ui/screens/settings/environment/EnvironmentScreen.kt @@ -51,29 +51,15 @@ fun EnvironmentScreen(appUiState: AppUiState, appViewModel: AppViewModel, viewMo .padding(top = 24.dp.scaledHeight()) .padding(horizontal = 24.dp.scaledWidth()), ) { - IconSurfaceButton( - title = Tunnel.Environment.CANARY.name, - onClick = { - if (appUiState.settings.environment == Tunnel.Environment.CANARY) return@IconSurfaceButton - viewModel.onEnvironmentChange(Tunnel.Environment.CANARY) - }, - selected = appUiState.settings.environment == Tunnel.Environment.CANARY, - ) - IconSurfaceButton( - title = Tunnel.Environment.SANDBOX.name, - onClick = { - if (appUiState.settings.environment == Tunnel.Environment.SANDBOX) return@IconSurfaceButton - viewModel.onEnvironmentChange(Tunnel.Environment.SANDBOX) - }, - selected = appUiState.settings.environment == Tunnel.Environment.SANDBOX, - ) - IconSurfaceButton( - title = Tunnel.Environment.MAINNET.name, - onClick = { - if (appUiState.settings.environment == Tunnel.Environment.MAINNET) return@IconSurfaceButton - viewModel.onEnvironmentChange(Tunnel.Environment.MAINNET) - }, - selected = appUiState.settings.environment == Tunnel.Environment.MAINNET, - ) + enumValues().forEach { + IconSurfaceButton( + title = it.name, + onClick = { + if (appUiState.settings.environment == it) return@IconSurfaceButton + viewModel.onEnvironmentChange(it) + }, + selected = appUiState.settings.environment == it, + ) + } } } diff --git a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/util/extensions/UiExtensions.kt b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/util/extensions/UiExtensions.kt index ad8fdea393..c549dd97aa 100644 --- a/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/util/extensions/UiExtensions.kt +++ b/nym-vpn-android/app/src/main/java/net/nymtech/nymvpn/util/extensions/UiExtensions.kt @@ -10,9 +10,8 @@ import androidx.navigation.NavDestination.Companion.hasRoute import androidx.navigation.NavDestination.Companion.hierarchy import androidx.navigation.NavGraph.Companion.findStartDestination import net.nymtech.nymvpn.NymVpn -import net.nymtech.nymvpn.R import net.nymtech.nymvpn.ui.Route -import nym_vpn_lib.VpnException +import nym_vpn_lib.ErrorStateReason import kotlin.reflect.KClass fun Dp.scaledHeight(): Dp { @@ -56,20 +55,16 @@ fun NavController.goFromRoot(route: Route) { } } -fun VpnException.toUserMessage(context: Context): String { +fun ErrorStateReason.toUserMessage(context: Context): String { return when (this) { - is VpnException.GatewayException -> context.getString(R.string.gateway_error) - is VpnException.InternalException -> { - // TODO we need improved errors for this scenario from backend - when { - this.details.contains("no exit gateway available for location") -> context.getString(R.string.selected_exit_unavailable) - this.details.contains("no entry gateway available for location") -> context.getString(R.string.selected_entry_unavailable) - else -> context.getString(R.string.internal_error) - } - } - is VpnException.InvalidCredential -> context.getString(R.string.exception_cred_invalid) - is VpnException.InvalidStateException -> context.getString(R.string.state_error) - is VpnException.NetworkConnectionException -> context.getString(R.string.network_error) - is VpnException.OutOfBandwidth -> context.getString(R.string.out_of_bandwidth_error) + ErrorStateReason.FIREWALL -> "A firewall issue occurred" + ErrorStateReason.ROUTING -> "A routing issue occurred" + ErrorStateReason.DNS -> "A dns issue occurred" + ErrorStateReason.TUN_DEVICE -> "A tunnel device issue occurred" + ErrorStateReason.TUNNEL_PROVIDER -> "A tunnel provider issue occurred" + ErrorStateReason.ESTABLISH_MIXNET_CONNECTION -> "Failed to establish mixnet connection" + ErrorStateReason.ESTABLISH_WIREGUARD_CONNECTION -> "Failed to establish wireguard connection" + ErrorStateReason.TUNNEL_DOWN -> "Tunnel down error" + ErrorStateReason.INTERNAL -> "Internal error" } } diff --git a/nym-vpn-android/app/src/main/res/values/strings.xml b/nym-vpn-android/app/src/main/res/values/strings.xml index c58812f13a..6ba4b4ee96 100644 --- a/nym-vpn-android/app/src/main/res/values/strings.xml +++ b/nym-vpn-android/app/src/main/res/values/strings.xml @@ -1,149 +1,150 @@ - NymVPN + NymVPN net.nymtech.nymvpn.provider - Settings - Connected - Disconnected - Disconnecting - Connecting - Anonymous (mixnet) - For payments, emails, messages - Fast (WireGuard) - Best for browsing, streaming, sharing - Entry location - Exit location - Connect - Disconnect - Initializing client… - Establishing connection - Connection time - Select mode - Connect to - Entry location - Exit location - Display theme - Light theme - Dark theme - Automatic - Use device theme - Search - Search country - Selected - Fastest - Auto-connect - Auto connect on reboot - Logs - Feedback - Support - Share anonymous error reports - Sentry - via - applies on restart - Legal - https://nymvpn.com/en/privacy?type=apps - Terms of use - Privacy statement - Licenses - Open a GitHub issue - Send us feedback - Check the FAQ - Join us on Matrix - Join us on Discord - https://matrix.to/#/%23NymVPN:nymtech.chat - http://nymtech.net/go/discord - https://support.nymvpn.com - https://support.nymvpn.com/hc/en-us/requests/new - support@nymvpn.com - https://github.com/nymtech/nym-vpn-client/issues/new/choose - NymVPN Support - Send an email… - Login - Add credential - Add credential to connect - Welcome! - Enter your credential to get started - Redeem your credential, then paste or scan the QR code. Don\'t have one? Sign up at nymvpn.com to get it instantly. - Credential - Invalid credential - An unknown error occurred - Credential - Top up your credential - Top up - Devices - Android - Windows - macOS - Linux - iOS - Credential added successfully - No browser detected - No email app detected - Unknown - Source code url not found - https://nymvpn.com/en/terms - 5-hop - Mode - Okay - 2-hop - Changes to error reporting will not fully take effect until the app has been restarted. - This feature is still in progress. - Logs saved to downloads folder - https://sentry.io - Anonymous analytics - Help us improve NymVPN - Help us refine our app during the beta test! Your feedback is crucial for identifying and resolving issues. - Opt-in for anonymous error monitoring - and analytics at will—you can opt out anytime. - Thanks for your support! - to NymVPN beta - Welcome - Continue - By continuing, you agree to NymVPN\'s - and acknowledge NymVPN\'s - Share anonymous product analytics - Anonymous error reports - Failed to retrieve gateways - Imported credential is invalid - Missing credential - Failed to load hop countries - App shortcuts - Enable app shortcuts - Disabled while connected to VPN - This is experimental software. Do not rely on it for strong anonymity (yet). - Permission required - No imported credential found. - Required permission has not be granted. - Credential is invalid or expired - To ensure the app works correctly on your device, please allow the following permissions. These permissions are required for that app to function. - Notifications - Allow permissions - Required to keep VPN services running while the app is closed. - Failed to lookup Nym gateways. Please check your network connection and try again. - "Selected gateway has a bad peer certificate. Please try again to connect to a different gateway. " - Gateway missing hostname address. Please try again to connect to a different gateway. - VPN has come to an unexpected halt. Please try connecting again. - Kill switch - Contact support - hours - hour - days - day - Scan NymVPN Credential QR - Failed to save logs - Mode selection - Enjoy maximum-level privacy by routing your connection through 5 servers via mixnet. Perfect for securely handling payments, emails, and messages. - Experience maximum speed with 2-server connectivity. Perfect for fast browsing, streaming, and file sharing. - Continue reading - Entry location - Exit location - Appearance - Language - We infer server locations based on their IP addresses, but the actual locations may vary slightly. - Details on server locations - remaining - Entry location selector - https://support.nymvpn.com/hc/en-us/articles/26448676449297-How-is-server-location-determined-by-NymVPN + https://nym-dot-com-git-deploy-canary-nyx-network-staging.vercel.app/en/prototype/account/signup + Settings + Connected + Disconnected + Disconnecting + Connecting + Anonymous (mixnet) + For payments, emails, messages + Fast (WireGuard) + Best for browsing, streaming, sharing + Entry location + Exit location + Connect + Disconnect + Initializing client… + Establishing connection + Connection time + Select mode + Connect to + Entry location + Exit location + Display theme + Light theme + Dark theme + Automatic + Use device theme + Search + Search country + Selected + Fastest + Auto-connect + Auto connect on reboot + Logs + Feedback + Support + Share anonymous error reports + Sentry + via + applies on restart + Legal + https://nymvpn.com/en/privacy?type=apps + Terms of use + Privacy statement + Licenses + Open a GitHub issue + Send us feedback + Check the FAQ + Join us on Matrix + Join us on Discord + https://matrix.to/#/%23NymVPN:nymtech.chat + http://nymtech.net/go/discord + https://support.nymvpn.com + https://support.nymvpn.com/hc/en-us/requests/new + support@nymvpn.com + https://github.com/nymtech/nym-vpn-client/issues/new/choose + NymVPN Support + Send an email… + Login + Add credential + Add credential to connect + Welcome! + Enter your credential to get started + Redeem your credential, then paste or scan the QR code. Don\'t have one? Sign up at nymvpn.com to get it instantly. + Credential + Invalid credential + An unknown error occurred + Credential + Top up your credential + Top up + Devices + Android + Windows + macOS + Linux + iOS + Credential added successfully + No browser detected + No email app detected + Unknown + Source code url not found + https://nymvpn.com/en/terms + 5-hop + Mode + Okay + 2-hop + Changes to error reporting will not fully take effect until the app has been restarted. + This feature is still in progress. + Logs saved to downloads folder + https://sentry.io + Anonymous analytics + Help us improve NymVPN + Help us refine our app during the beta test! Your feedback is crucial for identifying and resolving issues. + Opt-in for anonymous error monitoring + and analytics at will—you can opt out anytime. + Thanks for your support! + to NymVPN beta + Welcome + Continue + By continuing, you agree to NymVPN\'s + and acknowledge NymVPN\'s + Share anonymous product analytics + Anonymous error reports + Failed to retrieve gateways + Imported credential is invalid + Missing credential + Failed to load hop countries + App shortcuts + Enable app shortcuts + Disabled while connected to VPN + This is experimental software. Do not rely on it for strong anonymity (yet). + Permission required + No imported credential found. + Required permission has not be granted. + Credential is invalid or expired + To ensure the app works correctly on your device, please allow the following permissions. These permissions are required for that app to function. + Notifications + Allow permissions + Required to keep VPN services running while the app is closed. + Failed to lookup Nym gateways. Please check your network connection and try again. + "Selected gateway has a bad peer certificate. Please try again to connect to a different gateway. " + Gateway missing hostname address. Please try again to connect to a different gateway. + VPN has come to an unexpected halt. Please try connecting again. + Kill switch + Contact support + hours + hour + days + day + Scan NymVPN Credential QR + Failed to save logs + Mode selection + Enjoy maximum-level privacy by routing your connection through 5 servers via mixnet. Perfect for securely handling payments, emails, and messages. + Experience maximum speed with 2-server connectivity. Perfect for fast browsing, streaming, and file sharing. + Continue reading + Entry location + Exit location + Appearance + Language + We infer server locations based on their IP addresses, but the actual locations may vary slightly. + Details on server locations + remaining + Entry location selector + https://support.nymvpn.com/hc/en-us/articles/26448676449297-How-is-server-location-determined-by-NymVPN https://support.nymvpn.com/hc/en-us/articles/24326365096721-What-s-the-difference-between-Fast-and-Anonymous-mode VPN Connection Attest to the VPN connection request by trying to reconnect. @@ -159,7 +160,7 @@ Once deleted, the logs will not be recoverable. No Yes - Credential bandwidth limitation reached. + Credential bandwidth limitation reached. Failed to connect to gateway. Try again or select a new gateway location. A network connection issue occurred. Please check your network connection and try again. "This should not happen, but a bad state has been reached. Please restart the app and try again. " @@ -171,12 +172,12 @@ Connection failed "Low bandwidth! Bandwidth remaining: " Vpn permission has not been accepted or is being used by another app. - Credential already imported. + Credential already imported. Environment Action requires tunnel down Selected exit country is unavailable. Please select a different exit country. Selected entry country is unavailable. Please select a different entry country. - Missing mnemonic + Missing mnemonic Device successfully added to your account Invalid recovery phrase Recovery phrase @@ -187,6 +188,7 @@ Create an account Account https://nymvpn.com/account/login + https://nym-dot-com-git-deploy-canary-nyx-network-staging.vercel.app/en/prototype/account/signin e.g. smoke artefact velvet skull pop palace tortoise damage rough... Enter your 24-word secret recovery phrase below to log in to your account You can only use the recovery phrase created in NymVPN,
not the Nym Wallet. diff --git a/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/backend/NymBackend.kt b/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/backend/NymBackend.kt index 9c5d80398c..a7757716ef 100644 --- a/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/backend/NymBackend.kt +++ b/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/backend/NymBackend.kt @@ -3,6 +3,7 @@ package net.nymtech.vpn.backend import android.content.Context import android.content.Intent import android.os.Build +import androidx.lifecycle.lifecycleScope import com.getkeepsafe.relinker.ReLinker import com.getkeepsafe.relinker.ReLinker.LoadListener import kotlinx.coroutines.CompletableDeferred @@ -18,17 +19,16 @@ import net.nymtech.vpn.model.BackendMessage import net.nymtech.vpn.model.Statistics import net.nymtech.vpn.util.Action import net.nymtech.vpn.util.Constants +import net.nymtech.vpn.util.LifecycleVpnService import net.nymtech.vpn.util.NotificationManager import net.nymtech.vpn.util.SingletonHolder import net.nymtech.vpn.util.addRoutes import nym_vpn_lib.AndroidTunProvider -import nym_vpn_lib.BandwidthStatus -import nym_vpn_lib.ConnectionStatus -import nym_vpn_lib.ExitStatus -import nym_vpn_lib.NymVpnStatus -import nym_vpn_lib.TunStatus +import nym_vpn_lib.BandwidthEvent +import nym_vpn_lib.MixnetEvent import nym_vpn_lib.TunnelEvent import nym_vpn_lib.TunnelNetworkSettings +import nym_vpn_lib.TunnelState import nym_vpn_lib.TunnelStatusListener import nym_vpn_lib.VpnConfig import nym_vpn_lib.VpnException @@ -185,65 +185,36 @@ class NymBackend private constructor(val context: Context) : Backend, TunnelStat } override fun onEvent(event: TunnelEvent) { - Timber.d(event.toString()) - } - - override fun onTunStatusChange(status: TunStatus) { - state = when (status) { - TunStatus.INITIALIZING_CLIENT -> Tunnel.State.Connecting.InitializingClient - TunStatus.ESTABLISHING_CONNECTION -> Tunnel.State.Connecting.EstablishingConnection - TunStatus.DOWN -> { - Tunnel.State.Down - } - - TunStatus.UP -> { - statsJob = onConnect() - Tunnel.State.Up - } - - TunStatus.DISCONNECTING -> { - onDisconnect() - Tunnel.State.Disconnecting - } - } - tunnel?.onStateChange(state) - } - - override fun onBandwidthStatusChange(status: BandwidthStatus) { - Timber.d("Bandwidth status: $status") - when (status) { - BandwidthStatus.NoBandwidth -> { - tunnel?.onBackendMessage(BackendMessage.Failure(VpnException.OutOfBandwidth())) - onVpnShutdown() - } - is BandwidthStatus.RemainingBandwidth -> tunnel?.onBackendMessage( - BackendMessage.BandwidthAlert(status), - ) - } - } - - override fun onConnectionStatusChange(status: ConnectionStatus) { - Timber.d("Connection status: $status") - } - - override fun onNymVpnStatusChange(status: NymVpnStatus) { - Timber.d("VPN status: $status") - } - - override fun onExitStatusChange(status: ExitStatus) { - when (status) { - ExitStatus.Stopped -> { - state = Tunnel.State.Down + when (event) { + is TunnelEvent.MixnetState -> { + when (event.v1) { + is MixnetEvent.Bandwidth -> { + tunnel?.onBackendMessage(BackendMessage.BandwidthAlert(event.v1.v1)) + if (event.v1.v1 is BandwidthEvent.NoBandwidth) onVpnShutdown() + } + is MixnetEvent.Connection -> { + // just logs these for now + Timber.d(event.v1.v1.toString()) + } + } } - is ExitStatus.Failure -> { - Timber.e(status.error) - tunnel?.onBackendMessage(BackendMessage.Failure(status.error)) - onVpnShutdown() + is TunnelEvent.NewState -> { + state = when (event.v1) { + is TunnelState.Connected -> Tunnel.State.Up.also { statsJob = onConnect() } + TunnelState.Connecting -> Tunnel.State.Connecting.EstablishingConnection + TunnelState.Disconnected -> Tunnel.State.Down + is TunnelState.Disconnecting -> Tunnel.State.Disconnecting.also { onDisconnect() } + is TunnelState.Error -> Tunnel.State.Down.also { + tunnel?.onBackendMessage(BackendMessage.Failure(event.v1.v1)) + onVpnShutdown() + } + } + tunnel?.onStateChange(state) } } } - class VpnService : android.net.VpnService(), AndroidTunProvider { + class VpnService : LifecycleVpnService(), AndroidTunProvider { private var owner: NymBackend? = null private var startId by Delegates.notNull() private val calculator = AllowedIpCalculator() @@ -260,6 +231,9 @@ class NymBackend private constructor(val context: Context) : Backend, TunnelStat override fun onDestroy() { Timber.d("Vpn service destroyed") currentTunnelHandle.getAndSet(-1) + lifecycleScope.launch { + stopVpn() + } vpnService = CompletableDeferred() super.onDestroy() } diff --git a/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/backend/Tunnel.kt b/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/backend/Tunnel.kt index d1f8eb8aa6..0cf4346e01 100644 --- a/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/backend/Tunnel.kt +++ b/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/backend/Tunnel.kt @@ -81,6 +81,12 @@ interface Tunnel { get() = null override val apiUrl: URL get() = URL("https://canary-api.performance.nymte.ch/api") + }, + QA { + override val nymVpnApiUrl: URL? + get() = null + override val apiUrl: URL + get() = URL("https://qa-nym-api.qa.nymte.ch/api") }, ; /** @@ -91,6 +97,7 @@ interface Tunnel { MAINNET -> Constants.setupEnvironmentMainnet() SANDBOX -> Constants.setupEnvironmentSandbox() CANARY -> Constants.setupEnvironmentCanary() + QA -> Constants.setupEnvironmentQA() } } diff --git a/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/model/BackendMessage.kt b/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/model/BackendMessage.kt index 5f29a110f7..a82f53a6cb 100644 --- a/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/model/BackendMessage.kt +++ b/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/model/BackendMessage.kt @@ -1,10 +1,10 @@ package net.nymtech.vpn.model -import nym_vpn_lib.BandwidthStatus -import nym_vpn_lib.VpnException +import nym_vpn_lib.BandwidthEvent +import nym_vpn_lib.ErrorStateReason sealed class BackendMessage { - data class Failure(val exception: VpnException) : BackendMessage() - data class BandwidthAlert(val status: BandwidthStatus) : BackendMessage() + data class Failure(val reason: ErrorStateReason) : BackendMessage() + data class BandwidthAlert(val status: BandwidthEvent) : BackendMessage() data object None : BackendMessage() } diff --git a/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/util/Constants.kt b/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/util/Constants.kt index c6f7e744fb..8ae8adadd0 100644 --- a/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/util/Constants.kt +++ b/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/util/Constants.kt @@ -134,4 +134,34 @@ object Constants { Os.setenv("NYXD", "https://canary-validator.performance.nymte.ch", true) Os.setenv("NYM_API", "https://canary-api.performance.nymte.ch/api", true) } + + fun setupEnvironmentQA() { + setupCommon() + + Os.setenv("REWARDING_VALIDATOR_ADDRESS", "n1rfvpsynktze6wvn6ldskj8xgwfzzk5v6pnff39", true) + Os.setenv( + "MIXNET_CONTRACT_ADDRESS", + "n1hm4y6fzgxgu688jgf7ek66px6xkrtmn3gyk8fax3eawhp68c2d5qujz296", + true, + ) + Os.setenv( + "GROUP_CONTRACT_ADDRESS", + "n13l7rwuwktklrwskc7m6lv70zws07en85uma28j7dxwsz9y5hvvhspl7a2t", + true, + ) + Os.setenv( + "MULTISIG_CONTRACT_ADDRESS", + "n138c9pyf7f3hyx0j3t6vmsz7ultnw2wj0lu6hzndep9z5grgq9haqlc25k0", + true, + ) + Os.setenv( + "COCONUT_DKG_CONTRACT_ADDRESS", + "n1pk8jgr6y4c5k93gz7qf3xc0hvygmp7csk88c2tf8l39tkq6834wq2a6dtr", + true, + ) + + Os.setenv("EXPLORER_API", "https://qa-network-explorer.qa.nymte.ch/api", true) + Os.setenv("NYXD", "https://qa-validator.qa.nymte.ch", true) + Os.setenv("NYM_API", "https://qa-nym-api.qa.nymte.ch/api", true) + } } diff --git a/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/util/LifecycleVpnService.kt b/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/util/LifecycleVpnService.kt new file mode 100644 index 0000000000..0f92744325 --- /dev/null +++ b/nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn/util/LifecycleVpnService.kt @@ -0,0 +1,56 @@ +package net.nymtech.vpn.util + +import android.content.Intent +import android.net.VpnService +import android.os.IBinder +import androidx.annotation.CallSuper +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.ServiceLifecycleDispatcher + +/** + * A VpnService that is also a [LifecycleOwner]. See source: + * https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:lifecycle/lifecycle-service/src/main/java/androidx/lifecycle/LifecycleService.kt?q=file:androidx%2Flifecycle%2FLifecycleService.kt%20class:androidx.lifecycle.LifecycleService + */ +open class LifecycleVpnService : VpnService(), LifecycleOwner { + + private val dispatcher = ServiceLifecycleDispatcher(this) + + @CallSuper + override fun onCreate() { + dispatcher.onServicePreSuperOnCreate() + super.onCreate() + } + + @CallSuper + override fun onBind(intent: Intent?): IBinder? { + dispatcher.onServicePreSuperOnBind() + return super.onBind(intent) + } + + @Deprecated("Deprecated in Java") + @Suppress("DEPRECATION") + @CallSuper + override fun onStart(intent: Intent?, startId: Int) { + dispatcher.onServicePreSuperOnStart() + super.onStart(intent, startId) + } + + // this method is added only to annotate it with @CallSuper. + // In usual Service, super.onStartCommand is no-op, but in LifecycleService + // it results in dispatcher.onServicePreSuperOnStart() call, because + // super.onStartCommand calls onStart(). + @CallSuper + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + return super.onStartCommand(intent, flags, startId) + } + + @CallSuper + override fun onDestroy() { + dispatcher.onServicePreSuperOnDestroy() + super.onDestroy() + } + + override val lifecycle: Lifecycle + get() = dispatcher.lifecycle +} diff --git a/nym-vpn-android/nym-vpn-client/src/main/scripts/build-libs.sh b/nym-vpn-android/nym-vpn-client/src/main/scripts/build-libs.sh index 5fd8f54e4b..8ffdd7d4ea 100644 --- a/nym-vpn-android/nym-vpn-client/src/main/scripts/build-libs.sh +++ b/nym-vpn-android/nym-vpn-client/src/main/scripts/build-libs.sh @@ -12,20 +12,12 @@ bash $PWD/../../wireguard/build-wireguard-go.sh bash $PWD/../../wireguard/libwg/build-android.sh echo "Building nym-vpn-lib dep" -case "$(uname -s)" in - Darwin*) export RUSTFLAGS="-L ${PWD}/../../build/lib/aarch64-linux-android -L ${PWD}/../../build/lib/universal-apple-darwin";; - Linux*) export RUSTFLAGS="-L ${PWD}/../../build/lib/aarch64-linux-android -L ${PWD}/../../build/lib/x86_64-unknown-linux-gnu";; - MINGW*|MSYS_NT*) export RUSTFLAGS="-L ${PWD}/../../build/lib/aarch64-linux-android -L ${PWD}/../../build/lib/x86_64-pc-windows-msvc";; -esac - #fix emulators later #(cd $PWD/src/tools/nym-vpn-client/crates/nym-vpn-lib; cargo ndk -t armeabi-v7a -t arm64-v8a -t i686-linux-android -t x86_64-linux-android -o ../../../main/jniLibs build --release) (cd $PWD/../../nym-vpn-core/crates/nym-vpn-lib; cargo ndk -t arm64-v8a -o ../../../nym-vpn-android/nym-vpn-client/src/main/jniLibs build --release) (cd $PWD/../../nym-vpn-core; cargo run --bin uniffi-bindgen generate --library ./target/aarch64-linux-android/release/libnym_vpn_lib.so --language kotlin --out-dir ../nym-vpn-android/nym-vpn-client/src/main/java/net/nymtech/vpn -n) cargo license -j --avoid-dev-deps --current-dir ../../nym-vpn-core/crates/nym-vpn-lib --filter-platform aarch64-linux-android --avoid-build-deps > ./src/main/assets/licenses_rust.json -#fix package name -#sed -i 's/package nym-vpn-lib;/package nym_vpn_lib;/g' $PWD/src/main/java/net/nymtech/vpn/nym-vpn-lib/nym_vpn_lib.kt mv $PWD/src/main/jniLibs/arm64-v8a/libnym_vpn_lib.so $PWD/src/main/jniLibs/arm64-v8a/libnym_vpn_lib.so #mv $PWD/src/main/jniLibs/armeabi-v7a/libnym_vpn_lib.so $PWD/src/main/jniLibs/armeabi-v7a/libnym_vpn_lib.so diff --git a/nym-vpn-android/scripts/fdroid-prebuild.sh b/nym-vpn-android/scripts/fdroid-init.sh similarity index 78% rename from nym-vpn-android/scripts/fdroid-prebuild.sh rename to nym-vpn-android/scripts/fdroid-init.sh index 3ab26ffb76..cd4acd7812 100644 --- a/nym-vpn-android/scripts/fdroid-prebuild.sh +++ b/nym-vpn-android/scripts/fdroid-init.sh @@ -29,12 +29,5 @@ echo "$GOLANG_HASH go.tgz" | sha256sum -c tar -xzvf go.tgz patch -p1 -f -N -r- -d "$HOME/go" < "$REPO_DIR/wireguard/libwg/goruntime-boottime-over-monotonic.diff" -# Ensure Go compiler is accessible -export GOROOT="$HOME/go" -export PATH="$PATH:$GOROOT/bin" - # install cargo dependencies cargo install cargo-ndk cargo-license --locked - -# install other dependencies -sudo apt-get update && sudo apt-get install -y libdbus-1-dev libmnl-dev libnftnl-dev protobuf-compiler git curl gcc g++ make unzip diff --git a/nym-vpn-core/crates/nym-vpn-lib/src/platform/mod.rs b/nym-vpn-core/crates/nym-vpn-lib/src/platform/mod.rs index 7131425358..76b10b3d93 100644 --- a/nym-vpn-core/crates/nym-vpn-lib/src/platform/mod.rs +++ b/nym-vpn-core/crates/nym-vpn-lib/src/platform/mod.rs @@ -12,7 +12,6 @@ use std::{env, path::PathBuf, str::FromStr, sync::Arc}; use lazy_static::lazy_static; use log::*; -use nym_ip_packet_requests::IpPair; use tokio::{ runtime::Runtime, sync::{mpsc, Mutex}, @@ -33,14 +32,13 @@ use crate::tunnel_provider::ios::OSTunProvider; use crate::{ gateway_directory::GatewayClient, tunnel_state_machine::{ - BandwidthEvent, ConnectionEvent, DnsOptions, GatewayPerformanceOptions, MixnetEvent, - MixnetTunnelOptions, NymConfig, TunnelCommand, TunnelConnectionData, TunnelEvent, - TunnelSettings, TunnelState, TunnelStateMachine, TunnelType, + BandwidthEvent, ConnectionEvent, DnsOptions, GatewayPerformanceOptions, + MixnetTunnelOptions, NymConfig, TunnelCommand, TunnelEvent, TunnelSettings, TunnelState, + TunnelStateMachine, TunnelType, }, uniffi_custom_impls::{ - BandwidthStatus, ConnectionStatus, EntryPoint, ExitPoint, ExitStatus, - GatewayMinPerformance, GatewayType, Location, MixConnectionInfo, MixExitConnectionInfo, - NymVpnStatus, TunStatus, UserAgent, WireguardConnectionInfo, + BandwidthStatus, ConnectionStatus, EntryPoint, ExitPoint, GatewayMinPerformance, + GatewayType, Location, TunStatus, UserAgent, }, }; @@ -304,11 +302,6 @@ pub struct VPNConfig { #[uniffi::export(with_foreign)] pub trait TunnelStatusListener: Send + Sync { fn on_event(&self, event: TunnelEvent); - fn on_tun_status_change(&self, status: TunStatus); - fn on_bandwidth_status_change(&self, status: BandwidthStatus); - fn on_connection_status_change(&self, status: ConnectionStatus); - fn on_nym_vpn_status_change(&self, status: NymVpnStatus); - fn on_exit_status_change(&self, status: ExitStatus); } struct StateMachineHandle { @@ -377,28 +370,6 @@ async fn start_state_machine(config: VPNConfig) -> Result { - if let Some(nym_vpn_status) = nym_vpn_status_from_tunnel_state(state) { - (*state_listener).on_nym_vpn_status_change(nym_vpn_status); - } - - if let Some(exit_status) = exit_status_from_tunnel_state(state) { - (*state_listener).on_exit_status_change(exit_status); - } - - (*state_listener).on_tun_status_change(TunStatus::from(state)); - } - TunnelEvent::MixnetState(MixnetEvent::Bandwidth(sub_event)) => { - (*state_listener) - .on_bandwidth_status_change(BandwidthStatus::from(sub_event)) - } - TunnelEvent::MixnetState(MixnetEvent::Connection(sub_event)) => { - (*state_listener) - .on_connection_status_change(ConnectionStatus::from(sub_event)); - } - } (*state_listener).on_event(event); } } @@ -424,57 +395,6 @@ async fn start_state_machine(config: VPNConfig) -> Result Option { - match value { - TunnelState::Disconnected => Some(ExitStatus::Stopped), - TunnelState::Error(reason) => Some(ExitStatus::Failure { - error: VpnError::InternalError { - details: format!("{:?}", reason), - }, - }), - TunnelState::Disconnecting { .. } - | TunnelState::Connecting - | TunnelState::Connected { .. } => None, - } -} - -fn nym_vpn_status_from_tunnel_state(value: &TunnelState) -> Option { - match value { - TunnelState::Connected { connection_data } => Some(match &connection_data.tunnel { - TunnelConnectionData::Mixnet(mixnet_data) => NymVpnStatus::MixConnectInfo { - mix_connection_info: MixConnectionInfo { - nym_address: *mixnet_data.nym_address, - entry_gateway: *connection_data.entry_gateway, - }, - mix_exit_connection_info: MixExitConnectionInfo { - exit_gateway: *connection_data.exit_gateway, - exit_ipr: *mixnet_data.exit_ipr, - ips: IpPair { - ipv4: mixnet_data.ipv4, - ipv6: mixnet_data.ipv6, - }, - }, - }, - TunnelConnectionData::Wireguard(data) => NymVpnStatus::WgConnectInfo { - entry_connection_info: WireguardConnectionInfo { - gateway_id: *connection_data.entry_gateway, - public_key: data.entry.public_key.to_base64(), - private_ipv4: data.entry.private_ipv4, - }, - exit_connection_info: WireguardConnectionInfo { - gateway_id: *connection_data.exit_gateway, - public_key: data.exit.public_key.to_base64(), - private_ipv4: data.exit.private_ipv4, - }, - }, - }), - TunnelState::Connecting - | TunnelState::Disconnected - | TunnelState::Disconnecting { .. } - | TunnelState::Error(_) => None, - } -} - impl From<&TunnelState> for TunStatus { fn from(value: &TunnelState) -> Self { // TODO: this cannot be accurate so we must switch frontends to use TunnelState instead! But for now that will do. diff --git a/nym-vpn-core/crates/nym-vpn-lib/uniffi/nym_vpn_lib.kt b/nym-vpn-core/crates/nym-vpn-lib/uniffi/nym_vpn_lib.kt index 755d9f0730..1c26080ed5 100644 --- a/nym-vpn-core/crates/nym-vpn-lib/uniffi/nym_vpn_lib.kt +++ b/nym-vpn-core/crates/nym-vpn-lib/uniffi/nym_vpn_lib.kt @@ -642,19 +642,7 @@ internal interface UniffiCallbackInterfaceAndroidTunProviderMethod1 : com.sun.jn fun callback(`uniffiHandle`: Long,`config`: RustBuffer.ByValue,`uniffiOutReturn`: IntByReference,uniffiCallStatus: UniffiRustCallStatus,) } internal interface UniffiCallbackInterfaceTunnelStatusListenerMethod0 : com.sun.jna.Callback { - fun callback(`uniffiHandle`: Long,`status`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) -} -internal interface UniffiCallbackInterfaceTunnelStatusListenerMethod1 : com.sun.jna.Callback { - fun callback(`uniffiHandle`: Long,`status`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) -} -internal interface UniffiCallbackInterfaceTunnelStatusListenerMethod2 : com.sun.jna.Callback { - fun callback(`uniffiHandle`: Long,`status`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) -} -internal interface UniffiCallbackInterfaceTunnelStatusListenerMethod3 : com.sun.jna.Callback { - fun callback(`uniffiHandle`: Long,`status`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) -} -internal interface UniffiCallbackInterfaceTunnelStatusListenerMethod4 : com.sun.jna.Callback { - fun callback(`uniffiHandle`: Long,`status`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) + fun callback(`uniffiHandle`: Long,`event`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) } @Structure.FieldOrder("bypass", "configureTunnel", "uniffiFree") internal open class UniffiVTableCallbackInterfaceAndroidTunProvider( @@ -675,30 +663,18 @@ internal open class UniffiVTableCallbackInterfaceAndroidTunProvider( } } -@Structure.FieldOrder("onTunStatusChange", "onBandwidthStatusChange", "onConnectionStatusChange", "onNymVpnStatusChange", "onExitStatusChange", "uniffiFree") +@Structure.FieldOrder("onEvent", "uniffiFree") internal open class UniffiVTableCallbackInterfaceTunnelStatusListener( - @JvmField internal var `onTunStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod0? = null, - @JvmField internal var `onBandwidthStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod1? = null, - @JvmField internal var `onConnectionStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod2? = null, - @JvmField internal var `onNymVpnStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod3? = null, - @JvmField internal var `onExitStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod4? = null, + @JvmField internal var `onEvent`: UniffiCallbackInterfaceTunnelStatusListenerMethod0? = null, @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, ) : Structure() { class UniffiByValue( - `onTunStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod0? = null, - `onBandwidthStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod1? = null, - `onConnectionStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod2? = null, - `onNymVpnStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod3? = null, - `onExitStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod4? = null, + `onEvent`: UniffiCallbackInterfaceTunnelStatusListenerMethod0? = null, `uniffiFree`: UniffiCallbackInterfaceFree? = null, - ): UniffiVTableCallbackInterfaceTunnelStatusListener(`onTunStatusChange`,`onBandwidthStatusChange`,`onConnectionStatusChange`,`onNymVpnStatusChange`,`onExitStatusChange`,`uniffiFree`,), Structure.ByValue + ): UniffiVTableCallbackInterfaceTunnelStatusListener(`onEvent`,`uniffiFree`,), Structure.ByValue internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceTunnelStatusListener) { - `onTunStatusChange` = other.`onTunStatusChange` - `onBandwidthStatusChange` = other.`onBandwidthStatusChange` - `onConnectionStatusChange` = other.`onConnectionStatusChange` - `onNymVpnStatusChange` = other.`onNymVpnStatusChange` - `onExitStatusChange` = other.`onExitStatusChange` + `onEvent` = other.`onEvent` `uniffiFree` = other.`uniffiFree` } @@ -782,12 +758,6 @@ internal open class UniffiVTableCallbackInterfaceTunnelStatusListener( - - - - - - @@ -832,30 +802,24 @@ internal interface UniffiLib : Library { ): Unit fun uniffi_nym_vpn_lib_fn_init_callback_vtable_tunnelstatuslistener(`vtable`: UniffiVTableCallbackInterfaceTunnelStatusListener, ): Unit - fun uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_tun_status_change(`ptr`: Pointer,`status`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, - ): Unit - fun uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_bandwidth_status_change(`ptr`: Pointer,`status`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, - ): Unit - fun uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_connection_status_change(`ptr`: Pointer,`status`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + fun uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_event(`ptr`: Pointer,`event`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Unit - fun uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_nym_vpn_status_change(`ptr`: Pointer,`status`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, - ): Unit - fun uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_exit_status_change(`ptr`: Pointer,`status`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, - ): Unit - fun uniffi_nym_vpn_lib_fn_func_checkcredential(`credential`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, - ): RustBuffer.ByValue fun uniffi_nym_vpn_lib_fn_func_getgatewaycountries(`apiUrl`: RustBuffer.ByValue,`nymVpnApiUrl`: RustBuffer.ByValue,`gwType`: RustBuffer.ByValue,`userAgent`: RustBuffer.ByValue,`minGatewayPerformance`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue fun uniffi_nym_vpn_lib_fn_func_getlowlatencyentrycountry(`apiUrl`: RustBuffer.ByValue,`vpnApiUrl`: RustBuffer.ByValue,`userAgent`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue - fun uniffi_nym_vpn_lib_fn_func_importcredential(`credential`: RustBuffer.ByValue,`path`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, - ): RustBuffer.ByValue fun uniffi_nym_vpn_lib_fn_func_initlogger(uniffi_out_err: UniffiRustCallStatus, ): Unit + fun uniffi_nym_vpn_lib_fn_func_isaccountmnemonicstored(`path`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + ): Byte + fun uniffi_nym_vpn_lib_fn_func_removeaccountmnemonic(`path`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + ): Byte fun uniffi_nym_vpn_lib_fn_func_startvpn(`config`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Unit fun uniffi_nym_vpn_lib_fn_func_stopvpn(uniffi_out_err: UniffiRustCallStatus, ): Unit + fun uniffi_nym_vpn_lib_fn_func_storeaccountmnemonic(`mnemonic`: RustBuffer.ByValue,`path`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + ): Unit fun ffi_nym_vpn_lib_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue fun ffi_nym_vpn_lib_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus, @@ -968,33 +932,27 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Unit - fun uniffi_nym_vpn_lib_checksum_func_checkcredential( - ): Short fun uniffi_nym_vpn_lib_checksum_func_getgatewaycountries( ): Short fun uniffi_nym_vpn_lib_checksum_func_getlowlatencyentrycountry( ): Short - fun uniffi_nym_vpn_lib_checksum_func_importcredential( - ): Short fun uniffi_nym_vpn_lib_checksum_func_initlogger( ): Short + fun uniffi_nym_vpn_lib_checksum_func_isaccountmnemonicstored( + ): Short + fun uniffi_nym_vpn_lib_checksum_func_removeaccountmnemonic( + ): Short fun uniffi_nym_vpn_lib_checksum_func_startvpn( ): Short fun uniffi_nym_vpn_lib_checksum_func_stopvpn( ): Short + fun uniffi_nym_vpn_lib_checksum_func_storeaccountmnemonic( + ): Short fun uniffi_nym_vpn_lib_checksum_method_androidtunprovider_bypass( ): Short fun uniffi_nym_vpn_lib_checksum_method_androidtunprovider_configure_tunnel( ): Short - fun uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_tun_status_change( - ): Short - fun uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_bandwidth_status_change( - ): Short - fun uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_connection_status_change( - ): Short - fun uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_nym_vpn_status_change( - ): Short - fun uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_exit_status_change( + fun uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_event( ): Short fun ffi_nym_vpn_lib_uniffi_contract_version( ): Int @@ -1013,46 +971,37 @@ private fun uniffiCheckContractApiVersion(lib: UniffiLib) { @Suppress("UNUSED_PARAMETER") private fun uniffiCheckApiChecksums(lib: UniffiLib) { - if (lib.uniffi_nym_vpn_lib_checksum_func_checkcredential() != 1684.toShort()) { - throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } if (lib.uniffi_nym_vpn_lib_checksum_func_getgatewaycountries() != 41607.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_nym_vpn_lib_checksum_func_getlowlatencyentrycountry() != 12628.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_nym_vpn_lib_checksum_func_importcredential() != 49505.toShort()) { - throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } if (lib.uniffi_nym_vpn_lib_checksum_func_initlogger() != 45606.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_nym_vpn_lib_checksum_func_startvpn() != 55890.toShort()) { - throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } - if (lib.uniffi_nym_vpn_lib_checksum_func_stopvpn() != 59823.toShort()) { + if (lib.uniffi_nym_vpn_lib_checksum_func_isaccountmnemonicstored() != 32917.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_nym_vpn_lib_checksum_method_androidtunprovider_bypass() != 2706.toShort()) { + if (lib.uniffi_nym_vpn_lib_checksum_func_removeaccountmnemonic() != 51019.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_nym_vpn_lib_checksum_method_androidtunprovider_configure_tunnel() != 55981.toShort()) { + if (lib.uniffi_nym_vpn_lib_checksum_func_startvpn() != 55890.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_tun_status_change() != 55105.toShort()) { + if (lib.uniffi_nym_vpn_lib_checksum_func_stopvpn() != 59823.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_bandwidth_status_change() != 27737.toShort()) { + if (lib.uniffi_nym_vpn_lib_checksum_func_storeaccountmnemonic() != 55674.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_connection_status_change() != 33534.toShort()) { + if (lib.uniffi_nym_vpn_lib_checksum_method_androidtunprovider_bypass() != 2706.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_nym_vpn_status_change() != 65319.toShort()) { + if (lib.uniffi_nym_vpn_lib_checksum_method_androidtunprovider_configure_tunnel() != 55981.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_exit_status_change() != 8499.toShort()) { + if (lib.uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_event() != 60728.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } } @@ -1270,46 +1219,6 @@ public object FfiConverterString: FfiConverter { } -public object FfiConverterTimestamp: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): java.time.Instant { - val seconds = buf.getLong() - // Type mismatch (should be u32) but we check for overflow/underflow below - val nanoseconds = buf.getInt().toLong() - if (nanoseconds < 0) { - throw java.time.DateTimeException("Instant nanoseconds exceed minimum or maximum supported by uniffi") - } - if (seconds >= 0) { - return java.time.Instant.EPOCH.plus(java.time.Duration.ofSeconds(seconds, nanoseconds)) - } else { - return java.time.Instant.EPOCH.minus(java.time.Duration.ofSeconds(-seconds, nanoseconds)) - } - } - - // 8 bytes for seconds, 4 bytes for nanoseconds - override fun allocationSize(value: java.time.Instant) = 12UL - - override fun write(value: java.time.Instant, buf: ByteBuffer) { - var epochOffset = java.time.Duration.between(java.time.Instant.EPOCH, value) - - var sign = 1 - if (epochOffset.isNegative()) { - sign = -1 - epochOffset = epochOffset.negated() - } - - if (epochOffset.nano < 0) { - // Java docs provide guarantee that nano will always be positive, so this should be impossible - // See: https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html - throw IllegalArgumentException("Invalid timestamp, nano value must be non-negative") - } - - buf.putLong(sign * epochOffset.seconds) - // Type mismatch (should be u32) but since values will always be between 0 and 999,999,999 it should be OK - buf.putInt(epochOffset.nano) - } -} - - // This template implements a class for working with a Rust struct via a Pointer/Arc // to the live Rust struct on the other side of the FFI. // @@ -1796,15 +1705,7 @@ public object FfiConverterTypeAndroidTunProvider: FfiConverter - UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_tun_status_change( - it, FfiConverterTypeTunStatus.lower(`status`),_status) -} - } - - - - override fun `onBandwidthStatusChange`(`status`: BandwidthStatus) - = - callWithPointer { - uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_bandwidth_status_change( - it, FfiConverterTypeBandwidthStatus.lower(`status`),_status) -} - } - - - - override fun `onConnectionStatusChange`(`status`: ConnectionStatus) - = - callWithPointer { - uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_connection_status_change( - it, FfiConverterTypeConnectionStatus.lower(`status`),_status) -} - } - - - - override fun `onNymVpnStatusChange`(`status`: NymVpnStatus) - = - callWithPointer { - uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_nym_vpn_status_change( - it, FfiConverterTypeNymVpnStatus.lower(`status`),_status) -} - } - - - - override fun `onExitStatusChange`(`status`: ExitStatus) + override fun `onEvent`(`event`: TunnelEvent) = callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_exit_status_change( - it, FfiConverterTypeExitStatus.lower(`status`),_status) + UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_event( + it, FfiConverterTypeTunnelEvent.lower(`event`),_status) } } @@ -1956,60 +1813,12 @@ open class TunnelStatusListenerImpl: Disposable, AutoCloseable, TunnelStatusList // Put the implementation in an object so we don't pollute the top-level namespace internal object uniffiCallbackInterfaceTunnelStatusListener { - internal object `onTunStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod0 { - override fun callback(`uniffiHandle`: Long,`status`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { - val uniffiObj = FfiConverterTypeTunnelStatusListener.handleMap.get(uniffiHandle) - val makeCall = { -> - uniffiObj.`onTunStatusChange`( - FfiConverterTypeTunStatus.lift(`status`), - ) - } - val writeReturn = { _: Unit -> Unit } - uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) - } - } - internal object `onBandwidthStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod1 { - override fun callback(`uniffiHandle`: Long,`status`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { - val uniffiObj = FfiConverterTypeTunnelStatusListener.handleMap.get(uniffiHandle) - val makeCall = { -> - uniffiObj.`onBandwidthStatusChange`( - FfiConverterTypeBandwidthStatus.lift(`status`), - ) - } - val writeReturn = { _: Unit -> Unit } - uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) - } - } - internal object `onConnectionStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod2 { - override fun callback(`uniffiHandle`: Long,`status`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { - val uniffiObj = FfiConverterTypeTunnelStatusListener.handleMap.get(uniffiHandle) - val makeCall = { -> - uniffiObj.`onConnectionStatusChange`( - FfiConverterTypeConnectionStatus.lift(`status`), - ) - } - val writeReturn = { _: Unit -> Unit } - uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) - } - } - internal object `onNymVpnStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod3 { - override fun callback(`uniffiHandle`: Long,`status`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { - val uniffiObj = FfiConverterTypeTunnelStatusListener.handleMap.get(uniffiHandle) - val makeCall = { -> - uniffiObj.`onNymVpnStatusChange`( - FfiConverterTypeNymVpnStatus.lift(`status`), - ) - } - val writeReturn = { _: Unit -> Unit } - uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) - } - } - internal object `onExitStatusChange`: UniffiCallbackInterfaceTunnelStatusListenerMethod4 { - override fun callback(`uniffiHandle`: Long,`status`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + internal object `onEvent`: UniffiCallbackInterfaceTunnelStatusListenerMethod0 { + override fun callback(`uniffiHandle`: Long,`event`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { val uniffiObj = FfiConverterTypeTunnelStatusListener.handleMap.get(uniffiHandle) val makeCall = { -> - uniffiObj.`onExitStatusChange`( - FfiConverterTypeExitStatus.lift(`status`), + uniffiObj.`onEvent`( + FfiConverterTypeTunnelEvent.lift(`event`), ) } val writeReturn = { _: Unit -> Unit } @@ -2024,11 +1833,7 @@ internal object uniffiCallbackInterfaceTunnelStatusListener { } internal var vtable = UniffiVTableCallbackInterfaceTunnelStatusListener.UniffiByValue( - `onTunStatusChange`, - `onBandwidthStatusChange`, - `onConnectionStatusChange`, - `onNymVpnStatusChange`, - `onExitStatusChange`, + `onEvent`, uniffiFree, ) @@ -2067,6 +1872,55 @@ public object FfiConverterTypeTunnelStatusListener: FfiConverter { + override fun read(buf: ByteBuffer): ConnectionData { + return ConnectionData( + FfiConverterTypeBoxedNodeIdentity.read(buf), + FfiConverterTypeBoxedNodeIdentity.read(buf), + FfiConverterTypeOffsetDateTime.read(buf), + FfiConverterTypeTunnelConnectionData.read(buf), + ) + } + + override fun allocationSize(value: ConnectionData) = ( + FfiConverterTypeBoxedNodeIdentity.allocationSize(value.`entryGateway`) + + FfiConverterTypeBoxedNodeIdentity.allocationSize(value.`exitGateway`) + + FfiConverterTypeOffsetDateTime.allocationSize(value.`connectedAt`) + + FfiConverterTypeTunnelConnectionData.allocationSize(value.`tunnel`) + ) + + override fun write(value: ConnectionData, buf: ByteBuffer) { + FfiConverterTypeBoxedNodeIdentity.write(value.`entryGateway`, buf) + FfiConverterTypeBoxedNodeIdentity.write(value.`exitGateway`, buf) + FfiConverterTypeOffsetDateTime.write(value.`connectedAt`, buf) + FfiConverterTypeTunnelConnectionData.write(value.`tunnel`, buf) + } +} + + + data class DnsSettings ( /** * DNS IP addresses. @@ -2309,6 +2163,43 @@ public object FfiConverterTypeMixExitConnectionInfo: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): MixnetConnectionData { + return MixnetConnectionData( + FfiConverterTypeBoxedRecepient.read(buf), + FfiConverterTypeBoxedRecepient.read(buf), + FfiConverterTypeIpv4Addr.read(buf), + FfiConverterTypeIpv6Addr.read(buf), + ) + } + + override fun allocationSize(value: MixnetConnectionData) = ( + FfiConverterTypeBoxedRecepient.allocationSize(value.`nymAddress`) + + FfiConverterTypeBoxedRecepient.allocationSize(value.`exitIpr`) + + FfiConverterTypeIpv4Addr.allocationSize(value.`ipv4`) + + FfiConverterTypeIpv6Addr.allocationSize(value.`ipv6`) + ) + + override fun write(value: MixnetConnectionData, buf: ByteBuffer) { + FfiConverterTypeBoxedRecepient.write(value.`nymAddress`, buf) + FfiConverterTypeBoxedRecepient.write(value.`exitIpr`, buf) + FfiConverterTypeIpv4Addr.write(value.`ipv4`, buf) + FfiConverterTypeIpv6Addr.write(value.`ipv6`, buf) + } +} + + + /** * Tunnel + network settings */ @@ -2472,6 +2363,35 @@ public object FfiConverterTypeVPNConfig: FfiConverterRustBuffer { +data class WireguardConnectionData ( + var `entry`: WireguardNode, + var `exit`: WireguardNode +) { + + companion object +} + +public object FfiConverterTypeWireguardConnectionData: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): WireguardConnectionData { + return WireguardConnectionData( + FfiConverterTypeWireguardNode.read(buf), + FfiConverterTypeWireguardNode.read(buf), + ) + } + + override fun allocationSize(value: WireguardConnectionData) = ( + FfiConverterTypeWireguardNode.allocationSize(value.`entry`) + + FfiConverterTypeWireguardNode.allocationSize(value.`exit`) + ) + + override fun write(value: WireguardConnectionData, buf: ByteBuffer) { + FfiConverterTypeWireguardNode.write(value.`entry`, buf) + FfiConverterTypeWireguardNode.write(value.`exit`, buf) + } +} + + + data class WireguardConnectionInfo ( var `gatewayId`: NodeIdentity, var `publicKey`: kotlin.String, @@ -2505,13 +2425,49 @@ public object FfiConverterTypeWireguardConnectionInfo: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): WireguardNode { + return WireguardNode( + FfiConverterTypeSocketAddr.read(buf), + FfiConverterTypePublicKey.read(buf), + FfiConverterTypeIpv4Addr.read(buf), + ) + } + + override fun allocationSize(value: WireguardNode) = ( + FfiConverterTypeSocketAddr.allocationSize(value.`endpoint`) + + FfiConverterTypePublicKey.allocationSize(value.`publicKey`) + + FfiConverterTypeIpv4Addr.allocationSize(value.`privateIpv4`) + ) + + override fun write(value: WireguardNode, buf: ByteBuffer) { + FfiConverterTypeSocketAddr.write(value.`endpoint`, buf) + FfiConverterTypePublicKey.write(value.`publicKey`, buf) + FfiConverterTypeIpv4Addr.write(value.`privateIpv4`, buf) + } +} + + + +sealed class ActionAfterDisconnect { + object Nothing : ActionAfterDisconnect() - data class RemainingBandwidth( - val `bandwidth`: kotlin.Long) : BandwidthStatus() { + + object Reconnect : ActionAfterDisconnect() + + + data class Error( + val v1: ErrorStateReason) : ActionAfterDisconnect() { companion object } @@ -2520,42 +2476,53 @@ sealed class BandwidthStatus { companion object } -public object FfiConverterTypeBandwidthStatus : FfiConverterRustBuffer{ - override fun read(buf: ByteBuffer): BandwidthStatus { +public object FfiConverterTypeActionAfterDisconnect : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): ActionAfterDisconnect { return when(buf.getInt()) { - 1 -> BandwidthStatus.NoBandwidth - 2 -> BandwidthStatus.RemainingBandwidth( - FfiConverterLong.read(buf), + 1 -> ActionAfterDisconnect.Nothing + 2 -> ActionAfterDisconnect.Reconnect + 3 -> ActionAfterDisconnect.Error( + FfiConverterTypeErrorStateReason.read(buf), ) else -> throw RuntimeException("invalid enum value, something is very wrong!!") } } - override fun allocationSize(value: BandwidthStatus) = when(value) { - is BandwidthStatus.NoBandwidth -> { + override fun allocationSize(value: ActionAfterDisconnect) = when(value) { + is ActionAfterDisconnect.Nothing -> { // Add the size for the Int that specifies the variant plus the size needed for all fields ( 4UL ) } - is BandwidthStatus.RemainingBandwidth -> { + is ActionAfterDisconnect.Reconnect -> { // Add the size for the Int that specifies the variant plus the size needed for all fields ( 4UL - + FfiConverterLong.allocationSize(value.`bandwidth`) + ) + } + is ActionAfterDisconnect.Error -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeErrorStateReason.allocationSize(value.v1) ) } } - override fun write(value: BandwidthStatus, buf: ByteBuffer) { + override fun write(value: ActionAfterDisconnect, buf: ByteBuffer) { when(value) { - is BandwidthStatus.NoBandwidth -> { + is ActionAfterDisconnect.Nothing -> { buf.putInt(1) Unit } - is BandwidthStatus.RemainingBandwidth -> { + is ActionAfterDisconnect.Reconnect -> { buf.putInt(2) - FfiConverterLong.write(value.`bandwidth`, buf) + Unit + } + is ActionAfterDisconnect.Error -> { + buf.putInt(3) + FfiConverterTypeErrorStateReason.write(value.v1, buf) Unit } }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } @@ -2566,32 +2533,186 @@ public object FfiConverterTypeBandwidthStatus : FfiConverterRustBuffer { - override fun read(buf: ByteBuffer) = try { - ConnectionStatus.values()[buf.getInt() - 1] - } catch (e: IndexOutOfBoundsException) { - throw RuntimeException("invalid enum value, something is very wrong!!", e) +public object FfiConverterTypeBandwidthEvent : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): BandwidthEvent { + return when(buf.getInt()) { + 1 -> BandwidthEvent.NoBandwidth + 2 -> BandwidthEvent.RemainingBandwidth( + FfiConverterLong.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } } - override fun allocationSize(value: ConnectionStatus) = 4UL - - override fun write(value: ConnectionStatus, buf: ByteBuffer) { - buf.putInt(value.ordinal + 1) - } + override fun allocationSize(value: BandwidthEvent) = when(value) { + is BandwidthEvent.NoBandwidth -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + ) + } + is BandwidthEvent.RemainingBandwidth -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterLong.allocationSize(value.v1) + ) + } + } + + override fun write(value: BandwidthEvent, buf: ByteBuffer) { + when(value) { + is BandwidthEvent.NoBandwidth -> { + buf.putInt(1) + Unit + } + is BandwidthEvent.RemainingBandwidth -> { + buf.putInt(2) + FfiConverterLong.write(value.v1, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class BandwidthStatus { + + object NoBandwidth : BandwidthStatus() + + + data class RemainingBandwidth( + val `bandwidth`: kotlin.Long) : BandwidthStatus() { + companion object + } + + + + companion object +} + +public object FfiConverterTypeBandwidthStatus : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): BandwidthStatus { + return when(buf.getInt()) { + 1 -> BandwidthStatus.NoBandwidth + 2 -> BandwidthStatus.RemainingBandwidth( + FfiConverterLong.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: BandwidthStatus) = when(value) { + is BandwidthStatus.NoBandwidth -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + ) + } + is BandwidthStatus.RemainingBandwidth -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterLong.allocationSize(value.`bandwidth`) + ) + } + } + + override fun write(value: BandwidthStatus, buf: ByteBuffer) { + when(value) { + is BandwidthStatus.NoBandwidth -> { + buf.putInt(1) + Unit + } + is BandwidthStatus.RemainingBandwidth -> { + buf.putInt(2) + FfiConverterLong.write(value.`bandwidth`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + + +enum class ConnectionEvent { + + ENTRY_GATEWAY_DOWN, + EXIT_GATEWAY_DOWN_IPV4, + EXIT_GATEWAY_DOWN_IPV6, + EXIT_GATEWAY_ROUTING_ERROR_IPV4, + EXIT_GATEWAY_ROUTING_ERROR_IPV6, + CONNECTED_IPV4, + CONNECTED_IPV6; + companion object +} + + +public object FfiConverterTypeConnectionEvent: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + ConnectionEvent.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: ConnectionEvent) = 4UL + + override fun write(value: ConnectionEvent, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + +enum class ConnectionStatus { + + ENTRY_GATEWAY_DOWN, + EXIT_GATEWAY_DOWN_IPV4, + EXIT_GATEWAY_DOWN_IPV6, + EXIT_GATEWAY_ROUTING_ERROR_IPV4, + EXIT_GATEWAY_ROUTING_ERROR_IPV6, + CONNECTED_IPV4, + CONNECTED_IPV6; + companion object +} + + +public object FfiConverterTypeConnectionStatus: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + ConnectionStatus.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: ConnectionStatus) = 4UL + + override fun write(value: ConnectionStatus, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } } @@ -2693,6 +2814,67 @@ public object FfiConverterTypeEntryPoint : FfiConverterRustBuffer{ + +enum class ErrorStateReason { + + /** + * Issues related to firewall configuration. + */ + FIREWALL, + /** + * Failure to configure routing. + */ + ROUTING, + /** + * Failure to configure dns. + */ + DNS, + /** + * Failure to configure tunnel device. + */ + TUN_DEVICE, + /** + * Failure to configure packet tunnel provider. + */ + TUNNEL_PROVIDER, + /** + * Failure to establish mixnet connection. + */ + ESTABLISH_MIXNET_CONNECTION, + /** + * Failure to establish wireguard connection. + */ + ESTABLISH_WIREGUARD_CONNECTION, + /** + * Tunnel went down at runtime. + */ + TUNNEL_DOWN, + /** + * Program errors that must not happen. + */ + INTERNAL; + companion object +} + + +public object FfiConverterTypeErrorStateReason: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + ErrorStateReason.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: ErrorStateReason) = 4UL + + override fun write(value: ErrorStateReason, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + sealed class ExitPoint { data class Address( @@ -3019,6 +3201,73 @@ public object FfiConverterTypeIpv6Route : FfiConverterRustBuffer{ +sealed class MixnetEvent { + + data class Bandwidth( + val v1: BandwidthEvent) : MixnetEvent() { + companion object + } + + data class Connection( + val v1: ConnectionEvent) : MixnetEvent() { + companion object + } + + + + companion object +} + +public object FfiConverterTypeMixnetEvent : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): MixnetEvent { + return when(buf.getInt()) { + 1 -> MixnetEvent.Bandwidth( + FfiConverterTypeBandwidthEvent.read(buf), + ) + 2 -> MixnetEvent.Connection( + FfiConverterTypeConnectionEvent.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: MixnetEvent) = when(value) { + is MixnetEvent.Bandwidth -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeBandwidthEvent.allocationSize(value.v1) + ) + } + is MixnetEvent.Connection -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeConnectionEvent.allocationSize(value.v1) + ) + } + } + + override fun write(value: MixnetEvent, buf: ByteBuffer) { + when(value) { + is MixnetEvent.Bandwidth -> { + buf.putInt(1) + FfiConverterTypeBandwidthEvent.write(value.v1, buf) + Unit + } + is MixnetEvent.Connection -> { + buf.putInt(2) + FfiConverterTypeConnectionEvent.write(value.v1, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + sealed class NymVpnStatus { data class MixConnectInfo( @@ -3124,6 +3373,282 @@ public object FfiConverterTypeTunStatus: FfiConverterRustBuffer { +sealed class TunnelConnectionData { + + data class Mixnet( + val v1: MixnetConnectionData) : TunnelConnectionData() { + companion object + } + + data class Wireguard( + val v1: WireguardConnectionData) : TunnelConnectionData() { + companion object + } + + + + companion object +} + +public object FfiConverterTypeTunnelConnectionData : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): TunnelConnectionData { + return when(buf.getInt()) { + 1 -> TunnelConnectionData.Mixnet( + FfiConverterTypeMixnetConnectionData.read(buf), + ) + 2 -> TunnelConnectionData.Wireguard( + FfiConverterTypeWireguardConnectionData.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: TunnelConnectionData) = when(value) { + is TunnelConnectionData.Mixnet -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeMixnetConnectionData.allocationSize(value.v1) + ) + } + is TunnelConnectionData.Wireguard -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeWireguardConnectionData.allocationSize(value.v1) + ) + } + } + + override fun write(value: TunnelConnectionData, buf: ByteBuffer) { + when(value) { + is TunnelConnectionData.Mixnet -> { + buf.putInt(1) + FfiConverterTypeMixnetConnectionData.write(value.v1, buf) + Unit + } + is TunnelConnectionData.Wireguard -> { + buf.putInt(2) + FfiConverterTypeWireguardConnectionData.write(value.v1, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class TunnelEvent { + + data class NewState( + val v1: TunnelState) : TunnelEvent() { + companion object + } + + data class MixnetState( + val v1: MixnetEvent) : TunnelEvent() { + companion object + } + + + + companion object +} + +public object FfiConverterTypeTunnelEvent : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): TunnelEvent { + return when(buf.getInt()) { + 1 -> TunnelEvent.NewState( + FfiConverterTypeTunnelState.read(buf), + ) + 2 -> TunnelEvent.MixnetState( + FfiConverterTypeMixnetEvent.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: TunnelEvent) = when(value) { + is TunnelEvent.NewState -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeTunnelState.allocationSize(value.v1) + ) + } + is TunnelEvent.MixnetState -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeMixnetEvent.allocationSize(value.v1) + ) + } + } + + override fun write(value: TunnelEvent, buf: ByteBuffer) { + when(value) { + is TunnelEvent.NewState -> { + buf.putInt(1) + FfiConverterTypeTunnelState.write(value.v1, buf) + Unit + } + is TunnelEvent.MixnetState -> { + buf.putInt(2) + FfiConverterTypeMixnetEvent.write(value.v1, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +sealed class TunnelState { + + object Disconnected : TunnelState() + + + object Connecting : TunnelState() + + + data class Connected( + val `connectionData`: ConnectionData) : TunnelState() { + companion object + } + + data class Disconnecting( + val `afterDisconnect`: ActionAfterDisconnect) : TunnelState() { + companion object + } + + data class Error( + val v1: ErrorStateReason) : TunnelState() { + companion object + } + + + + companion object +} + +public object FfiConverterTypeTunnelState : FfiConverterRustBuffer{ + override fun read(buf: ByteBuffer): TunnelState { + return when(buf.getInt()) { + 1 -> TunnelState.Disconnected + 2 -> TunnelState.Connecting + 3 -> TunnelState.Connected( + FfiConverterTypeConnectionData.read(buf), + ) + 4 -> TunnelState.Disconnecting( + FfiConverterTypeActionAfterDisconnect.read(buf), + ) + 5 -> TunnelState.Error( + FfiConverterTypeErrorStateReason.read(buf), + ) + else -> throw RuntimeException("invalid enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: TunnelState) = when(value) { + is TunnelState.Disconnected -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + ) + } + is TunnelState.Connecting -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + ) + } + is TunnelState.Connected -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeConnectionData.allocationSize(value.`connectionData`) + ) + } + is TunnelState.Disconnecting -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeActionAfterDisconnect.allocationSize(value.`afterDisconnect`) + ) + } + is TunnelState.Error -> { + // Add the size for the Int that specifies the variant plus the size needed for all fields + ( + 4UL + + FfiConverterTypeErrorStateReason.allocationSize(value.v1) + ) + } + } + + override fun write(value: TunnelState, buf: ByteBuffer) { + when(value) { + is TunnelState.Disconnected -> { + buf.putInt(1) + Unit + } + is TunnelState.Connecting -> { + buf.putInt(2) + Unit + } + is TunnelState.Connected -> { + buf.putInt(3) + FfiConverterTypeConnectionData.write(value.`connectionData`, buf) + Unit + } + is TunnelState.Disconnecting -> { + buf.putInt(4) + FfiConverterTypeActionAfterDisconnect.write(value.`afterDisconnect`, buf) + Unit + } + is TunnelState.Error -> { + buf.putInt(5) + FfiConverterTypeErrorStateReason.write(value.v1, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + + +enum class TunnelType { + + MIXNET, + WIREGUARD; + companion object +} + + +public object FfiConverterTypeTunnelType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + TunnelType.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: TunnelType) = 4UL + + override fun write(value: TunnelType, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + sealed class VpnException: Exception() { @@ -3309,35 +3834,6 @@ public object FfiConverterOptionalULong: FfiConverterRustBuffer { -public object FfiConverterOptionalTimestamp: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): java.time.Instant? { - if (buf.get().toInt() == 0) { - return null - } - return FfiConverterTimestamp.read(buf) - } - - override fun allocationSize(value: java.time.Instant?): ULong { - if (value == null) { - return 1UL - } else { - return 1UL + FfiConverterTimestamp.allocationSize(value) - } - } - - override fun write(value: java.time.Instant?, buf: ByteBuffer) { - if (value == null) { - buf.put(0) - } else { - buf.put(1) - FfiConverterTimestamp.write(value, buf) - } - } -} - - - - public object FfiConverterOptionalTypeTunnelStatusListener: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): TunnelStatusListener? { if (buf.get().toInt() == 0) { @@ -3889,6 +4385,26 @@ public object FfiConverterSequenceTypeIpv6Network: FfiConverterRustBuffer { FfiConverterString.write(builtinValue, buf) } } - @Throws(VpnException::class) fun `checkCredential`(`credential`: kotlin.String): java.time.Instant? { - return FfiConverterOptionalTimestamp.lift( - uniffiRustCallWithError(VpnException) { _status -> - UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_func_checkcredential( - FfiConverterString.lower(`credential`),_status) -} - ) - } - - @Throws(VpnException::class) fun `getGatewayCountries`(`apiUrl`: Url, `nymVpnApiUrl`: Url?, `gwType`: GatewayType, `userAgent`: UserAgent?, `minGatewayPerformance`: GatewayMinPerformance?): List { return FfiConverterSequenceTypeLocation.lift( uniffiRustCallWithError(VpnException) { _status -> @@ -4045,16 +4581,6 @@ public object FfiConverterTypeUrl: FfiConverter { ) } - - @Throws(VpnException::class) fun `importCredential`(`credential`: kotlin.String, `path`: kotlin.String): java.time.Instant? { - return FfiConverterOptionalTimestamp.lift( - uniffiRustCallWithError(VpnException) { _status -> - UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_func_importcredential( - FfiConverterString.lower(`credential`),FfiConverterString.lower(`path`),_status) -} - ) - } - fun `initLogger`() = uniffiRustCall() { _status -> @@ -4064,6 +4590,26 @@ public object FfiConverterTypeUrl: FfiConverter { + @Throws(VpnException::class) fun `isAccountMnemonicStored`(`path`: kotlin.String): kotlin.Boolean { + return FfiConverterBoolean.lift( + uniffiRustCallWithError(VpnException) { _status -> + UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_func_isaccountmnemonicstored( + FfiConverterString.lower(`path`),_status) +} + ) + } + + + @Throws(VpnException::class) fun `removeAccountMnemonic`(`path`: kotlin.String): kotlin.Boolean { + return FfiConverterBoolean.lift( + uniffiRustCallWithError(VpnException) { _status -> + UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_func_removeaccountmnemonic( + FfiConverterString.lower(`path`),_status) +} + ) + } + + @Throws(VpnException::class) fun `startVpn`(`config`: VpnConfig) = uniffiRustCallWithError(VpnException) { _status -> @@ -4082,4 +4628,13 @@ public object FfiConverterTypeUrl: FfiConverter { + @Throws(VpnException::class) fun `storeAccountMnemonic`(`mnemonic`: kotlin.String, `path`: kotlin.String) + = + uniffiRustCallWithError(VpnException) { _status -> + UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_func_storeaccountmnemonic( + FfiConverterString.lower(`mnemonic`),FfiConverterString.lower(`path`),_status) +} + + + diff --git a/nym-vpn-core/crates/nym-vpn-lib/uniffi/nym_vpn_lib.swift b/nym-vpn-core/crates/nym-vpn-lib/uniffi/nym_vpn_lib.swift index c205916194..8540406626 100644 --- a/nym-vpn-core/crates/nym-vpn-lib/uniffi/nym_vpn_lib.swift +++ b/nym-vpn-core/crates/nym-vpn-lib/uniffi/nym_vpn_lib.swift @@ -885,16 +885,6 @@ public protocol TunnelStatusListener : AnyObject { func onEvent(event: TunnelEvent) - func onTunStatusChange(status: TunStatus) - - func onBandwidthStatusChange(status: BandwidthStatus) - - func onConnectionStatusChange(status: ConnectionStatus) - - func onNymVpnStatusChange(status: NymVpnStatus) - - func onExitStatusChange(status: ExitStatus) - } open class TunnelStatusListenerImpl: @@ -945,41 +935,6 @@ open func onEvent(event: TunnelEvent) {try! rustCall() { } } -open func onTunStatusChange(status: TunStatus) {try! rustCall() { - uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_tun_status_change(self.uniffiClonePointer(), - FfiConverterTypeTunStatus.lower(status),$0 - ) -} -} - -open func onBandwidthStatusChange(status: BandwidthStatus) {try! rustCall() { - uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_bandwidth_status_change(self.uniffiClonePointer(), - FfiConverterTypeBandwidthStatus.lower(status),$0 - ) -} -} - -open func onConnectionStatusChange(status: ConnectionStatus) {try! rustCall() { - uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_connection_status_change(self.uniffiClonePointer(), - FfiConverterTypeConnectionStatus.lower(status),$0 - ) -} -} - -open func onNymVpnStatusChange(status: NymVpnStatus) {try! rustCall() { - uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_nym_vpn_status_change(self.uniffiClonePointer(), - FfiConverterTypeNymVpnStatus.lower(status),$0 - ) -} -} - -open func onExitStatusChange(status: ExitStatus) {try! rustCall() { - uniffi_nym_vpn_lib_fn_method_tunnelstatuslistener_on_exit_status_change(self.uniffiClonePointer(), - FfiConverterTypeExitStatus.lower(status),$0 - ) -} -} - } @@ -1007,126 +962,6 @@ fileprivate struct UniffiCallbackInterfaceTunnelStatusListener { } - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - onTunStatusChange: { ( - uniffiHandle: UInt64, - status: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeTunnelStatusListener.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.onTunStatusChange( - status: try FfiConverterTypeTunStatus.lift(status) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - onBandwidthStatusChange: { ( - uniffiHandle: UInt64, - status: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeTunnelStatusListener.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.onBandwidthStatusChange( - status: try FfiConverterTypeBandwidthStatus.lift(status) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - onConnectionStatusChange: { ( - uniffiHandle: UInt64, - status: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeTunnelStatusListener.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.onConnectionStatusChange( - status: try FfiConverterTypeConnectionStatus.lift(status) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - onNymVpnStatusChange: { ( - uniffiHandle: UInt64, - status: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeTunnelStatusListener.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.onNymVpnStatusChange( - status: try FfiConverterTypeNymVpnStatus.lift(status) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - onExitStatusChange: { ( - uniffiHandle: UInt64, - status: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeTunnelStatusListener.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.onExitStatusChange( - status: try FfiConverterTypeExitStatus.lift(status) - ) - } - - let writeReturn = { () } uniffiTraitInterfaceCall( callStatus: uniffiCallStatus, @@ -5114,21 +4949,6 @@ private var initializationResult: InitializationResult { if (uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_event() != 60728) { return InitializationResult.apiChecksumMismatch } - if (uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_tun_status_change() != 40558) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_bandwidth_status_change() != 60451) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_connection_status_change() != 30665) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_nym_vpn_status_change() != 62947) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_nym_vpn_lib_checksum_method_tunnelstatuslistener_on_exit_status_change() != 50420) { - return InitializationResult.apiChecksumMismatch - } uniffiCallbackInitOSDefaultPathObserver() uniffiCallbackInitOSTunProvider() diff --git a/wireguard/libwg/go.mod b/wireguard/libwg/go.mod index 084355ff7e..1b0e3d3ae0 100644 --- a/wireguard/libwg/go.mod +++ b/wireguard/libwg/go.mod @@ -1,6 +1,6 @@ module github.com/nymtech/nym-vpn-client/wireguard/libwg -go 1.22 +go 1.22.0 require ( golang.org/x/sys v0.12.0