From 8218e342fc12148319133966e5edb18f8c410c34 Mon Sep 17 00:00:00 2001 From: James McMurray Date: Fri, 3 Mar 2023 19:19:02 +0100 Subject: [PATCH] vopono v0.10.5 - fix error handling in basic_tcp_proxy --- Cargo.toml | 4 ++-- vopono_core/Cargo.toml | 8 ++++---- vopono_core/src/util/wireguard.rs | 15 +++++++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b02baac..58a7f3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "vopono" description = "Launch applications via VPN tunnels using temporary network namespaces" -version = "0.10.4" +version = "0.10.5" authors = ["James McMurray "] edition = "2021" license = "GPL-3.0-or-later" @@ -28,7 +28,7 @@ chrono = "0.4" bs58 = "0.4" nix = "0.26" config = "0.13" -basic_tcp_proxy = "0.3" +basic_tcp_proxy = "0.3.1" strum = "0.24" strum_macros = "0.24" diff --git a/vopono_core/Cargo.toml b/vopono_core/Cargo.toml index b8ecc21..01c9eec 100644 --- a/vopono_core/Cargo.toml +++ b/vopono_core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "vopono_core" description = "Library code for running VPN connections in network namespaces" -version = "0.1.4" +version = "0.1.5" edition = "2021" authors = ["James McMurray "] license = "GPL-3.0-or-later" @@ -24,15 +24,15 @@ ron = "0.8" walkdir = "2" # Must use rand 0.7 for compatibility with x25519-dalek for now rand = "0.7" -toml = "0.5" +toml = "0.7" ipnet = { version = "2", features = ["serde"] } reqwest = { default-features = false, version = "0.11", features = [ "blocking", "json", "rustls-tls", ] } # TODO: Can we remove Tokio dependency? -sysinfo = "0.27" -base64 = "0.20" +sysinfo = "0.28" +base64 = "0.21" x25519-dalek = "1" strum = "0.24" strum_macros = "0.24" diff --git a/vopono_core/src/util/wireguard.rs b/vopono_core/src/util/wireguard.rs index ffac077..d36e276 100644 --- a/vopono_core/src/util/wireguard.rs +++ b/vopono_core/src/util/wireguard.rs @@ -1,8 +1,15 @@ +use base64::{ + engine::{general_purpose, GeneralPurpose}, + Engine as _, +}; + use rand::rngs::OsRng; use serde::Deserialize; use std::fmt::Display; use x25519_dalek::{PublicKey, StaticSecret}; +const B64_ENGINE: GeneralPurpose = general_purpose::STANDARD; + #[derive(Deserialize, Debug, Clone)] pub struct WgKey { pub public: String, @@ -29,8 +36,8 @@ pub fn generate_keypair() -> anyhow::Result { // Generate new keypair let private = StaticSecret::new(OsRng); let public = PublicKey::from(&private); - let public_key = base64::encode(public.as_bytes()); - let private_key = base64::encode(private.to_bytes()); + let public_key = B64_ENGINE.encode(public.as_bytes()); + let private_key = B64_ENGINE.encode(private.to_bytes()); let keypair = WgKey { public: public_key, @@ -40,12 +47,12 @@ pub fn generate_keypair() -> anyhow::Result { } pub fn generate_public_key(private_key: &str) -> anyhow::Result { - let private_bytes = base64::decode(private_key)?; + let private_bytes = B64_ENGINE.decode(private_key)?; let mut byte_array = [0; 32]; byte_array.copy_from_slice(&private_bytes); let private = StaticSecret::from(byte_array); let public = PublicKey::from(&private); - let public_key = base64::encode(public.as_bytes()); + let public_key = B64_ENGINE.encode(public.as_bytes()); Ok(public_key) }