udp-test: determine current executable path better

This commit is contained in:
Travis Burtrum 2019-12-22 01:45:01 -05:00
parent 7be828efdf
commit efc858f852
2 changed files with 6 additions and 8 deletions

View File

@ -148,8 +148,12 @@ fn main() {
let tcp_host = "127.0.0.1:5555";
let sleep = Duration::from_secs(5);
let udp_test = args.get_str_idx(0, "udp-test");
let proxy = udp_test.clone().replace("udp-test", "wireguard-proxy");
let udp_test = std::env::current_exe().expect("cannot get path to current executable");
let proxy = udp_test.clone().with_file_name("wireguard-proxy")
.with_extension(udp_test.extension().unwrap_or_else(|| "".as_ref()));
let udp_test = udp_test.to_str().expect("non-utf8 executable path?");
let proxy = proxy.to_str().expect("non-utf8 executable path?");
let mut proxyd_args = vec!["-th", tcp_host, "-ut", host];

View File

@ -97,12 +97,6 @@ impl<'a> Args<'a> {
None => def,
}
}
pub fn get_str_idx(&self, index: usize, def: &'a str) -> &'a str {
match self.args.get(index) {
Some(ret) => ret,
None => def,
}
}
}
pub struct TcpUdpPipe<T: Write + Read + TryClone<T> + Send + 'static> {