diff options
| -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); |
