diff options
| author | Linus Färnstrand <faern@faern.net> | 2022-09-20 16:50:39 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2022-10-03 09:00:30 +0200 |
| commit | fb3272bd82f281711db397539afb3da8f2636ee5 (patch) | |
| tree | 1bcbbb5cd31a07f1cf50fc41d7a88aedd73d0027 | |
| parent | de3ffb129d269265f86b38b0dcc7da6ebb49cd3a (diff) | |
| download | mullvadvpn-fb3272bd82f281711db397539afb3da8f2636ee5.tar.xz mullvadvpn-fb3272bd82f281711db397539afb3da8f2636ee5.zip | |
Change the psk-exchange example to take the server IP as argument
Allows running it towards different test servers without changing
the code
| -rw-r--r-- | talpid-tunnel-config-client/examples/psk-exchange.rs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/talpid-tunnel-config-client/examples/psk-exchange.rs b/talpid-tunnel-config-client/examples/psk-exchange.rs index b4607be950..4c6a7dfe66 100644 --- a/talpid-tunnel-config-client/examples/psk-exchange.rs +++ b/talpid-tunnel-config-client/examples/psk-exchange.rs @@ -1,24 +1,25 @@ -use std::{ - io, - net::{IpAddr, Ipv4Addr}, -}; +//! Example client implementing the quantum resistant tunnel PSK exchange. +//! Useful to test this crate's implementation. +use std::net::IpAddr; use talpid_types::net::wireguard::PublicKey; #[tokio::main] async fn main() { - println!("Make sure you're connected to a WireGuard peer and enter your public key: "); + let mut args = std::env::args().skip(1); + let tuncfg_server_ip: IpAddr = args + .next() + .expect("Give tuncfg server IP as first argument") + .parse() + .expect("tuncfg ip argument not a valid IP"); + let pubkey_string = args + .next() + .expect("Give WireGuard public key as second argument"); + let pubkey = PublicKey::from_base64(pubkey_string.trim()).expect("Invalid public key"); - let mut pubkey_s = String::new(); - io::stdin() - .read_line(&mut pubkey_s) - .expect("Failed to read from stdin"); - let pubkey = PublicKey::from_base64(pubkey_s.trim()).expect("Invalid public key"); - - let (private_key, psk) = - talpid_tunnel_config_client::push_pq_key(IpAddr::V4(Ipv4Addr::new(10, 64, 0, 1)), pubkey) - .await - .unwrap(); + let (private_key, psk) = talpid_tunnel_config_client::push_pq_key(tuncfg_server_ip, pubkey) + .await + .unwrap(); println!("private key: {:?}", private_key); println!("psk: {:?}", psk); |
