Compare commits

..

15 Commits

Author SHA1 Message Date
durch da3b4d7991 Final cleanup 2023-05-27 11:11:55 +02:00
durch 2c95a1086d Fix lock files 2023-05-27 11:02:15 +02:00
durch b7ca9381f3 Happy clippy 2023-05-27 11:02:01 +02:00
durch 73d9d3fc6a Wrap up rebase 2023-05-27 11:02:01 +02:00
durch 2577235a3d Cleanup and fmt 2023-05-27 11:02:00 +02:00
durch 19c4b3255c More work on the reciever end, and outfox format 2023-05-27 11:01:25 +02:00
durch 4d837a0402 SurbAcks 2023-05-27 10:59:50 +02:00
durch 149c1d40a0 Speed up from_plaintext 2023-05-27 10:59:15 +02:00
durch 7228a95b19 Client tweaks 2023-05-27 10:59:14 +02:00
durch 4490f15fcd Rebase on develop
commit 342883fcbe
Author: durch <durch@users.noreply.github.com>
Date:   Thu Apr 27 09:17:18 2023 +0200

    Put back PacketType 1

commit 61a0ee5a19
Author: Tommy Verrall <tommyvez@protonmail.com>
Date:   Wed Apr 26 16:37:29 2023 +0100

    change output for cpu-cycle management logs

commit 3956109c7e
Author: Tommy Verrall <tommy@nymtech.net>
Date:   Wed Apr 26 12:13:22 2023 +0100

    change the workflow file to build with cpucycles

commit 8d725b13c5
Author: durch <durch@users.noreply.github.com>
Date:   Mon Apr 24 13:14:58 2023 +0200

    Outfox client compat

commit 4d166c389b
Author: durch <durch@users.noreply.github.com>
Date:   Fri Apr 21 00:30:46 2023 +0200

    Address PR comments

commit 145c3c1223
Author: durch <durch@users.noreply.github.com>
Date:   Fri Apr 21 00:12:35 2023 +0200

    Rename PacketMode

commit cbd654d6fd
Author: Drazen Urch <drazen@urch.eu>
Date:   Thu Apr 20 23:59:40 2023 +0200

    Outfox rest compat (#3333)

    * Outfox forwarding compat

    * Tidy up interface

    * PacketSize compat

commit e7be91a94c
Author: durch <durch@users.noreply.github.com>
Date:   Wed Apr 19 16:36:48 2023 +0200

    Remove serde cruft

commit 582e7d566a
Author: durch <durch@users.noreply.github.com>
Date:   Wed Apr 19 16:24:09 2023 +0200

    Outfox framing

commit 6464da5f01
Author: durch <durch@users.noreply.github.com>
Date:   Tue Apr 18 22:23:02 2023 +0200

    Framing compat

commit d5e77e499b
Author: durch <durch@users.noreply.github.com>
Date:   Tue Apr 18 18:18:54 2023 +0200

    Framed encoding serde POC

commit f086f9c35a
Author: durch <durch@users.noreply.github.com>
Date:   Tue Apr 18 16:54:21 2023 +0200

    Experiment with serde
2023-05-27 10:58:29 +02:00
durch 1029590f97 Address PR comments 2023-05-27 10:57:50 +02:00
Drazen Urch a985136dfa Outfox rest compat (#3333)
* Outfox forwarding compat

* Tidy up interface

* PacketSize compat
2023-05-27 10:57:50 +02:00
durch 7e78733866 Outfox framing 2023-05-27 10:57:50 +02:00
durch 6acce42a5e Framed encoding serde POC 2023-05-27 10:57:50 +02:00
durch 8ab4988c40 Experiment with serde 2023-05-27 10:57:50 +02:00
11 changed files with 34 additions and 94 deletions
Generated
-1
View File
@@ -4149,7 +4149,6 @@ dependencies = [
"jni",
"lazy_static",
"log",
"nym-bin-common",
"nym-client-core",
"nym-config",
"nym-credential-storage",
+1 -1
View File
@@ -31,7 +31,7 @@ mod v1 {
pub const GATEWAY_CONFIG: &str = "gateway_config";
pub const ED25519_IDENTITY_KEYPAIR: &str = "ed25519_identity_keypair";
pub const X25519_ENCRYPTION_KEYPAIR: &str = "x25519_encryption_keypair";
pub const X25519_ENCRYPTION_KEYPAIR: &str = "x25519_encryption_key";
// TODO: for those we could actually use the subtle crypto storage
pub const AES128CTR_ACK_KEY: &str = "aes128ctr_ack_key";
+14 -14
View File
@@ -15,7 +15,7 @@
"json-stringify-safe": "5.0.1",
"tslog": "3.3.3",
"uuid": "8.3.2",
"yaml": "^2.2.2"
"yaml": "^2.1.1"
},
"devDependencies": {
"@types/jest": "28.1.6",
@@ -27,7 +27,7 @@
"eslint-plugin-prettier": "^4.0.0",
"jest": "^28.1.3",
"jest-junit": "^14.0.0",
"prettier": "^2.8.7",
"prettier": "2.7.1",
"process": "0.11.10",
"ts-jest": "28.0.7",
"typescript": "^4.7.4",
@@ -4038,9 +4038,9 @@
}
},
"node_modules/prettier": {
"version": "2.8.8",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
@@ -4822,9 +4822,9 @@
"dev": true
},
"node_modules/yaml": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz",
"integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz",
"integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==",
"engines": {
"node": ">= 14"
}
@@ -7840,9 +7840,9 @@
"integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g=="
},
"prettier": {
"version": "2.8.8",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true
},
"prettier-linter-helpers": {
@@ -8367,9 +8367,9 @@
"dev": true
},
"yaml": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz",
"integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA=="
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz",
"integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw=="
},
"yargs": {
"version": "17.5.1",
+1 -1
View File
@@ -30,7 +30,7 @@
"json-stringify-safe": "5.0.1",
"tslog": "3.3.3",
"uuid": "8.3.2",
"yaml": "^2.2.2"
"yaml": "^2.1.1"
},
"devDependencies": {
"@types/jest": "28.1.6",
+4 -4
View File
@@ -2907,10 +2907,10 @@ yallist@^4.0.0:
resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
yaml@^2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.2.2.tgz#ec551ef37326e6d42872dad1970300f8eb83a073"
integrity sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==
yaml@^2.1.1:
version "2.1.1"
resolved "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz"
integrity sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==
yargs-parser@^21.0.0, yargs-parser@^21.0.1:
version "21.1.1"
@@ -7,7 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
D62D0ADE2A25EA2100B1F688 /* libnym_socks5_listener.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D62D0ADD2A25EA1400B1F688 /* libnym_socks5_listener.a */; };
D66856512A126105006A8693 /* ClientState+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66856502A126105006A8693 /* ClientState+String.swift */; };
D67035A42A0E75500060A6F0 /* Socks5App.swift in Sources */ = {isa = PBXBuildFile; fileRef = D67035A32A0E75500060A6F0 /* Socks5App.swift */; };
D67035A62A0E75500060A6F0 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D67035A52A0E75500060A6F0 /* ContentView.swift */; };
@@ -15,10 +14,10 @@
D67035AB2A0E75510060A6F0 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D67035AA2A0E75510060A6F0 /* Preview Assets.xcassets */; };
D67035B62A0E76E60060A6F0 /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D67035B52A0E76E20060A6F0 /* libresolv.tbd */; };
D67035BA2A0E794F0060A6F0 /* RustSocks5.swift in Sources */ = {isa = PBXBuildFile; fileRef = D67035B92A0E794F0060A6F0 /* RustSocks5.swift */; };
D6B668A32A15042F002E778E /* libnym_socks5_listener.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D6B668A22A15041D002E778E /* libnym_socks5_listener.a */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
D62D0ADD2A25EA1400B1F688 /* libnym_socks5_listener.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libnym_socks5_listener.a; path = ../../../../target/universal/release/libnym_socks5_listener.a; sourceTree = "<group>"; };
D66856502A126105006A8693 /* ClientState+String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ClientState+String.swift"; sourceTree = "<group>"; };
D67035A02A0E75500060A6F0 /* Socks5.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Socks5.app; sourceTree = BUILT_PRODUCTS_DIR; };
D67035A32A0E75500060A6F0 /* Socks5App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Socks5App.swift; sourceTree = "<group>"; };
@@ -39,7 +38,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D62D0ADE2A25EA2100B1F688 /* libnym_socks5_listener.a in Frameworks */,
D6B668A32A15042F002E778E /* libnym_socks5_listener.a in Frameworks */,
D67035B62A0E76E60060A6F0 /* libresolv.tbd in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -99,7 +98,6 @@
isa = PBXGroup;
children = (
D6B668A22A15041D002E778E /* libnym_socks5_listener.a */,
D62D0ADD2A25EA1400B1F688 /* libnym_socks5_listener.a */,
D67035B52A0E76E20060A6F0 /* libresolv.tbd */,
D67035B32A0E76CF0060A6F0 /* libsocks5_c.a */,
D67035B22A0E76110060A6F0 /* cargo */,
@@ -321,7 +319,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/../../../../target/universal/release";
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/../../../../sdk/lib/socks5-listener/target/universal/release";
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = nym.Socks5;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -352,7 +350,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/../../../../target/universal/release";
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/../../../../sdk/lib/socks5-listener/target/universal/release";
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = nym.Socks5;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -8,8 +8,8 @@
extension ClientState: CustomStringConvertible {
public var description: String {
switch self {
case CLIENT_STATE_UNINITIALISED:
return "uninitialised"
case CLIENT_STATE_UNKNOWN:
return "unknown"
case CLIENT_STATE_CONNECTED:
return "connected"
case CLIENT_STATE_DISCONNECTED:
@@ -12,12 +12,10 @@ class RustSocks5: ObservableObject {
@Published var operationInProgress = false
@Published var clientAddress = ""
@Published var connected = false
@Published var status: ClientState = CLIENT_STATE_UNINITIALISED
@Published var status: ClientState = CLIENT_STATE_UNKNOWN
@Published var serviceProvider: String?;
init() {
initialise_logger()
let client_store_dir = clientStoreDirectory()
let existingProvider = existingProvider(storageDirectory: client_store_dir)
if let some = existingProvider {
@@ -55,13 +53,13 @@ class RustSocks5: ObservableObject {
func startClient(storageDirectory: String, serviceProvider: String?) {
self.serviceProvider = serviceProvider
let this1 = UnsafeMutableRawPointer(Unmanaged.passRetained(self).toOpaque())
let startCb: @convention(c) (UnsafeMutableRawPointer?, UnsafeMutablePointer<CChar>?) -> Void = {
let socks: RustSocks5 = Unmanaged.fromOpaque($0!).takeRetainedValue()
socks.onConnect(clientAddress: $1)
}
let this2 = UnsafeMutableRawPointer(Unmanaged.passRetained(self).toOpaque())
let shutdownCb: @convention(c) (UnsafeMutableRawPointer?) -> Void = {
let socks: RustSocks5 = Unmanaged.fromOpaque($0!).takeRetainedValue()
@@ -70,8 +68,8 @@ class RustSocks5: ObservableObject {
let fn_start = RefDynFnMut1_void_char_ptr(env_ptr: this1, call: startCb)
let fn_shutdown = RefDynFnMut0_void(env_ptr: this2, call: shutdownCb)
start_client(storageDirectory, serviceProvider, fn_start, fn_shutdown)
}
-1
View File
@@ -19,7 +19,6 @@ strip = true
anyhow = "1.0"
futures = "0.3"
lazy_static = "1.4.0"
nym-bin-common = { path = "../../../common/bin-common"}
nym-client-core = { path = "../../../common/client-core", default-features = false }
nym-config-common = { path = "../../../common/config", package = "nym-config" }
nym-credential-storage = { path = "../../../common/credential-storage" }
+1 -9
View File
@@ -24,7 +24,7 @@ typedef
#endif
enum ClientState {
/** <No documentation available> */
CLIENT_STATE_UNINITIALISED,
CLIENT_STATE_UNKNOWN,
/** <No documentation available> */
CLIENT_STATE_CONNECTED,
/** <No documentation available> */
@@ -70,14 +70,6 @@ char *
existing_service_provider (
char const * storage_directory);
/** <No documentation available> */
ClientState_t
get_client_state (void);
/** <No documentation available> */
void
initialise_logger (void);
/** <No documentation available> */
void
reset_client_data (
+2 -48
View File
@@ -5,8 +5,6 @@ use crate::persistence::MobileClientStorage;
use ::safer_ffi::prelude::*;
use anyhow::{anyhow, Result};
use lazy_static::lazy_static;
use log::{info, warn};
use nym_bin_common::logging::setup_logging;
use nym_config_common::defaults::setup_env;
use nym_config_common::NymConfig;
use nym_socks5_client_core::config::Config as Socks5Config;
@@ -61,10 +59,6 @@ async fn stop_and_reset_shutdown_handle() {
*guard = None
}
async fn is_shutdown_handle_set() -> bool {
CLIENT_SHUTDOWN_HANDLE.lock().await.is_some()
}
fn set_default_env() {
if !ENV_SET.swap(true, Ordering::SeqCst) {
setup_env(None);
@@ -73,40 +67,19 @@ fn set_default_env() {
// to be used with the on startup callback which returns the address
#[ffi_export]
pub fn rust_free_string(string: char_p::Box) {
fn rust_free_string(string: char_p::Box) {
drop(string)
}
#[ffi_export]
pub fn initialise_logger() {
setup_logging();
info!("logger initialised");
}
#[derive_ReprC]
#[ffi_export]
#[repr(u8)]
#[derive(Eq, PartialEq)]
pub enum ClientState {
Uninitialised,
Unknown,
Connected,
Disconnected,
}
#[ffi_export]
pub fn get_client_state() -> ClientState {
// if the environment is not set, we never called start before
// if the shutdown was never set, the client can't possibly be running
// and similarly if it's set, it's most likely running
if !ENV_SET.load(Ordering::Relaxed) {
ClientState::Uninitialised
} else if RUNTIME.block_on(is_shutdown_handle_set()) {
ClientState::Connected
} else {
ClientState::Disconnected
}
}
#[ffi_export]
pub fn start_client(
storage_directory: Option<char_p::Ref<'_>>,
@@ -114,11 +87,6 @@ pub fn start_client(
on_start_callback: StartupCallback<'static>,
on_shutdown_callback: ShutdownCallback<'static>,
) {
if get_client_state() == ClientState::Connected {
warn!("could not start the client as it's already running");
return;
}
let storage_dir = storage_directory.map(|s| s.to_string());
let service_provider = service_provider.map(|s| s.to_string());
RUNTIME.spawn(async move {
@@ -135,11 +103,6 @@ pub fn start_client(
#[ffi_export]
pub fn stop_client() {
if get_client_state() == ClientState::Disconnected {
warn!("could not stop the client as it's not running ");
return;
}
RUNTIME.block_on(async move { stop_and_reset_shutdown_handle().await })
}
@@ -150,11 +113,6 @@ pub fn blocking_run_client(
on_start_callback: StartupCallback<'_>,
on_shutdown_callback: ShutdownCallback<'_>,
) {
if get_client_state() == ClientState::Connected {
warn!("could not start the client as it's already running");
return;
}
let storage_dir = storage_directory.map(|s| s.to_string());
let service_provider = service_provider.map(|s| s.to_string());
RUNTIME
@@ -173,10 +131,6 @@ pub fn blocking_run_client(
#[ffi_export]
pub fn reset_client_data(root_directory: char_p::Ref<'_>) {
if get_client_state() == ClientState::Connected {
return;
}
let root_dir = root_directory.to_string();
_reset_client_data(root_dir)
}