114d92f93f
* changed NymConfigTemplate trait to call 'template' by reference * network requester lib * introduced generic parameter to 'MixTrafficController' to allow non-remote gateways * allowing for custom gateway sender * types cleanup * minor gateway cmds refactor + initial NR work * wip * running a NR inside gateway note: this NR isnt tied to the gateway yet * rebase fixes * propagating same shutdown handle * wip * starting NR with appropriate local transceiver * fixed premature shutdown * wiring up PacketRouter * both ends wired together * actually working so much cleanup to do now * started removing dead code * wip * temp: hardcode gateway * further cleanup * fixed build of other binaries * setup-network-requester subcmd * overriding NR config in gateway init/run * wip making it wasm-compatible [again] * refactored 'GatewaySetup' * clippy and friends * removed debug code * rust 1.72 lints * ensuring local gateway is available + some comments * correctly putting network requester data in the same underlying details struct * improved gateway errors * changed 'network_requester_config' deserialization * missing clap annotation for 'enabled' flag in 'setup-network-requester' command * saving config file after 'setup-network-requester' * removed dead code * review comments * make embedded NR wait for gateway to come online (for at most 70min) * fixed shutdown on successful gateway wait * updated NR config override
43 lines
1.4 KiB
Rust
43 lines
1.4 KiB
Rust
use nym_sdk::mixnet;
|
|
use nym_sdk::mixnet::MixnetMessageSender;
|
|
use std::path::PathBuf;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
nym_bin_common::logging::setup_logging();
|
|
|
|
// Specify some config options
|
|
let config_dir = PathBuf::from("/tmp/mixnet-client");
|
|
let storage_paths = mixnet::StoragePaths::new_from_dir(&config_dir).unwrap();
|
|
|
|
// Create the client with a storage backend, and enable it by giving it some paths. If keys
|
|
// exists at these paths, they will be loaded, otherwise they will be generated.
|
|
let client = mixnet::MixnetClientBuilder::new_with_default_storage(storage_paths)
|
|
.await
|
|
.unwrap()
|
|
.build()
|
|
.unwrap();
|
|
|
|
// Now we connect to the mixnet, using keys now stored in the paths provided.
|
|
let mut client = client.connect_to_mixnet().await.unwrap();
|
|
|
|
// Be able to get our client address
|
|
let our_address = client.nym_address();
|
|
println!("Our client nym address is: {our_address}");
|
|
|
|
// Send a message throught the mixnet to ourselves
|
|
client
|
|
.send_plain_message(*our_address, "hello there")
|
|
.await
|
|
.unwrap();
|
|
|
|
println!("Waiting for message");
|
|
if let Some(received) = client.wait_for_messages().await {
|
|
for r in received {
|
|
println!("Received: {}", String::from_utf8_lossy(&r.message));
|
|
}
|
|
}
|
|
|
|
client.disconnect().await;
|
|
}
|