diff --git a/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainScreen.kt b/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainScreen.kt index f0c9199..8253d26 100644 --- a/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainScreen.kt +++ b/app/src/main/java/net/nymtech/nymvpn/ui/screens/main/MainScreen.kt @@ -14,7 +14,6 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.material.ripple.rememberRipple diff --git a/nym_vpn_client/src/main/java/net/nymtech/vpn/nym_vpn_lib/nym_vpn_lib.kt b/nym_vpn_client/src/main/java/net/nymtech/vpn/nym_vpn_lib/nym_vpn_lib.kt index 94b8934..584f438 100644 --- a/nym_vpn_client/src/main/java/net/nymtech/vpn/nym_vpn_lib/nym_vpn_lib.kt +++ b/nym_vpn_client/src/main/java/net/nymtech/vpn/nym_vpn_lib/nym_vpn_lib.kt @@ -18,17 +18,20 @@ package nym_vpn_lib; // helpers directly inline like we're doing here. import com.sun.jna.Library +import com.sun.jna.IntegerType import com.sun.jna.Native import com.sun.jna.Pointer import com.sun.jna.Structure +import com.sun.jna.Callback import com.sun.jna.ptr.* -import java.net.URI -import java.net.URL import java.nio.ByteBuffer import java.nio.ByteOrder import java.nio.CharBuffer import java.nio.charset.CodingErrorAction +import java.util.concurrent.atomic.AtomicLong import java.util.concurrent.ConcurrentHashMap +import java.net.URI +import java.net.URL // This is a helper for safely working with byte buffers returned from the Rust code. // A rust-owned buffer is represented by its capacity, its current length, and a @@ -709,24 +712,24 @@ internal interface UniffiLib : Library { uniffiCheckApiChecksums(lib) } } - + } - fun uniffi_nym_vpn_lib_fn_func_getgatewaycountries(`apiUrl`: RustBuffer.ByValue,`explorerUrl`: RustBuffer.ByValue,`exitOnly`: Byte,uniffi_out_err: UniffiRustCallStatus, + fun uniffi_nym_vpn_lib_fn_func_getgatewaycountries(`apiUrl`: RustBuffer.ByValue,`explorerUrl`: RustBuffer.ByValue,`exitOnly`: Byte,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue - fun uniffi_nym_vpn_lib_fn_func_getlowlatencyentrycountry(`apiUrl`: RustBuffer.ByValue,`explorerUrl`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + fun uniffi_nym_vpn_lib_fn_func_getlowlatencyentrycountry(`apiUrl`: RustBuffer.ByValue,`explorerUrl`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue - fun uniffi_nym_vpn_lib_fn_func_runvpn(`config`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + fun uniffi_nym_vpn_lib_fn_func_runvpn(`config`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Unit - fun uniffi_nym_vpn_lib_fn_func_stopvpn(uniffi_out_err: UniffiRustCallStatus, + fun uniffi_nym_vpn_lib_fn_func_stopvpn(uniffi_out_err: UniffiRustCallStatus, ): Unit - fun ffi_nym_vpn_lib_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus, + 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, + fun ffi_nym_vpn_lib_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue - fun ffi_nym_vpn_lib_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Unit - fun ffi_nym_vpn_lib_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue fun ffi_nym_vpn_lib_rust_future_poll_u8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -734,7 +737,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_u8(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Byte fun ffi_nym_vpn_lib_rust_future_poll_i8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -742,7 +745,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_i8(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Byte fun ffi_nym_vpn_lib_rust_future_poll_u16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -750,7 +753,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_u16(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Short fun ffi_nym_vpn_lib_rust_future_poll_i16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -758,7 +761,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_i16(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Short fun ffi_nym_vpn_lib_rust_future_poll_u32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -766,7 +769,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_u32(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Int fun ffi_nym_vpn_lib_rust_future_poll_i32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -774,7 +777,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_i32(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Int fun ffi_nym_vpn_lib_rust_future_poll_u64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -782,7 +785,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_u64(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Long fun ffi_nym_vpn_lib_rust_future_poll_i64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -790,7 +793,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_i64(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Long fun ffi_nym_vpn_lib_rust_future_poll_f32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -798,7 +801,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_f32(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Float fun ffi_nym_vpn_lib_rust_future_poll_f64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -806,7 +809,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_f64(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Double fun ffi_nym_vpn_lib_rust_future_poll_pointer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -814,7 +817,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_pointer(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_pointer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_pointer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun ffi_nym_vpn_lib_rust_future_poll_rust_buffer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -822,7 +825,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_rust_buffer(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue fun ffi_nym_vpn_lib_rust_future_poll_void(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, ): Unit @@ -830,7 +833,7 @@ internal interface UniffiLib : Library { ): Unit fun ffi_nym_vpn_lib_rust_future_free_void(`handle`: Long, ): Unit - fun ffi_nym_vpn_lib_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + fun ffi_nym_vpn_lib_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, ): Unit fun uniffi_nym_vpn_lib_checksum_func_getgatewaycountries( ): Short @@ -842,7 +845,7 @@ internal interface UniffiLib : Library { ): Short fun ffi_nym_vpn_lib_uniffi_contract_version( ): Int - + } private fun uniffiCheckContractApiVersion(lib: UniffiLib) { @@ -1006,13 +1009,13 @@ public object FfiConverterString: FfiConverter { data class Location ( - var `twoLetterIsoCountryCode`: kotlin.String, - var `threeLetterIsoCountryCode`: kotlin.String, - var `countryName`: kotlin.String, - var `latitude`: kotlin.Double?, + var `twoLetterIsoCountryCode`: kotlin.String, + var `threeLetterIsoCountryCode`: kotlin.String, + var `countryName`: kotlin.String, + var `latitude`: kotlin.Double?, var `longitude`: kotlin.Double? ) { - + companion object } @@ -1047,13 +1050,13 @@ public object FfiConverterTypeLocation: FfiConverterRustBuffer { data class VpnConfig ( - var `apiUrl`: Url, - var `explorerUrl`: Url, - var `entryGateway`: EntryPoint, - var `exitRouter`: ExitPoint, + var `apiUrl`: Url, + var `explorerUrl`: Url, + var `entryGateway`: EntryPoint, + var `exitRouter`: ExitPoint, var `enableTwoHop`: kotlin.Boolean ) { - + companion object } @@ -1088,25 +1091,25 @@ public object FfiConverterTypeVPNConfig: FfiConverterRustBuffer { sealed class EntryPoint { - + data class Gateway( val `identity`: NodeIdentity) : EntryPoint() { companion object } - + data class Location( val `location`: kotlin.String) : EntryPoint() { companion object } - + object RandomLowLatency : EntryPoint() - - + + object Random : EntryPoint() + + - - - + companion object } @@ -1183,24 +1186,24 @@ public object FfiConverterTypeEntryPoint : FfiConverterRustBuffer{ sealed class ExitPoint { - + data class Address( val `address`: Recipient) : ExitPoint() { companion object } - + data class Gateway( val `identity`: NodeIdentity) : ExitPoint() { companion object } - + data class Location( val `location`: kotlin.String) : ExitPoint() { companion object } + - - + companion object } @@ -1272,76 +1275,76 @@ public object FfiConverterTypeExitPoint : FfiConverterRustBuffer{ sealed class FfiException: Exception() { - + class InvalidValueUniffi( ) : FfiException() { override val message get() = "" } - + class FdNotFound( ) : FfiException() { override val message get() = "" } - + class VpnNotStopped( ) : FfiException() { override val message get() = "" } - + class VpnNotStarted( ) : FfiException() { override val message get() = "" } - + class VpnAlreadyRunning( ) : FfiException() { override val message get() = "" } - + class VpnNotRunning( ) : FfiException() { override val message get() = "" } - + class NoContext( ) : FfiException() { override val message get() = "" } - + class LibException( - + val `inner`: kotlin.String ) : FfiException() { override val message get() = "inner=${ `inner` }" } - + class GatewayDirectoryException( - + val `inner`: kotlin.String ) : FfiException() { override val message get() = "inner=${ `inner` }" } - + companion object ErrorHandler : UniffiRustCallStatusErrorHandler { override fun lift(error_buf: RustBuffer.ByValue): FfiException = FfiConverterTypeFFIError.lift(error_buf) } - + } public object FfiConverterTypeFFIError : FfiConverterRustBuffer { override fun read(buf: ByteBuffer): FfiException { - + return when(buf.getInt()) { 1 -> FfiException.InvalidValueUniffi() @@ -1570,7 +1573,7 @@ public object FfiConverterTypeUrl: FfiConverter { } ) } - + @Throws(FfiException::class) fun `getLowLatencyEntryCountry`(`apiUrl`: Url, `explorerUrl`: Url): Location { return FfiConverterTypeLocation.lift( @@ -1580,24 +1583,24 @@ public object FfiConverterTypeUrl: FfiConverter { } ) } - + @Throws(FfiException::class) fun `runVpn`(`config`: VpnConfig) - = + = uniffiRustCallWithError(FfiException) { _status -> UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_func_runvpn( FfiConverterTypeVPNConfig.lower(`config`),_status) } - - + + @Throws(FfiException::class) fun `stopVpn`() - = + = uniffiRustCallWithError(FfiException) { _status -> UniffiLib.INSTANCE.uniffi_nym_vpn_lib_fn_func_stopvpn( _status) } - - + + diff --git a/nym_vpn_client/src/tools/nym-vpn-client b/nym_vpn_client/src/tools/nym-vpn-client index 1554821..ef128cd 160000 --- a/nym_vpn_client/src/tools/nym-vpn-client +++ b/nym_vpn_client/src/tools/nym-vpn-client @@ -1 +1 @@ -Subproject commit 15548216a87d8ca81268aedd7a17fc9ff6a85d9a +Subproject commit ef128cd23f9eaef10cee7ed345b4ee51e334bfd1