From 5692e48b5a940cea2d5857f100a845aa99eb9efb Mon Sep 17 00:00:00 2001 From: Jeff Hughes Date: Tue, 16 Feb 2021 17:25:52 -0500 Subject: [PATCH 1/2] Strip directory from NordVPN filenames --- src/providers/nordvpn/openvpn.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/providers/nordvpn/openvpn.rs b/src/providers/nordvpn/openvpn.rs index fbae252..764fb4e 100644 --- a/src/providers/nordvpn/openvpn.rs +++ b/src/providers/nordvpn/openvpn.rs @@ -70,7 +70,15 @@ impl OpenVpnProvider for NordVPN { .extension() .map(|x| x.to_str().expect("Could not convert OsStr")) { - let fname = file.name(); + let fname = file + .enclosed_name() + .and_then(|x| x.file_name()) + .and_then(|x| x.to_str()); + if fname.is_none() { + debug!("Could not parse filename: {}", file.name().to_string()); + continue; + } + let fname = fname.unwrap(); let server_name = fname.to_lowercase().replace(' ', "_"); let server_name = server_name.split('.').next().unwrap(); @@ -92,7 +100,7 @@ impl OpenVpnProvider for NordVPN { let country = country_map.get(code.as_str()); if country.is_none() { debug!("Could not map country code to name: {}", code.as_str()); - file.name().to_string() + fname.to_string() } else { let server_name = server_name.replace("-", "_"); format!("{}-{}.ovpn", country.unwrap(), server_name) @@ -100,16 +108,16 @@ impl OpenVpnProvider for NordVPN { } else { debug!( "Filename did not match established pattern: {}", - file.name().to_string() + fname.to_string() ); - file.name().to_string() + fname.to_string() } } else { debug!( "Filename did not match established pattern: {}", - file.name().to_string() + fname.to_string() ); - file.name().to_string() + fname.to_string() } } else { file.name().to_string() From eb3820a99cff5b9d1d36b1b058607479d8f35a43 Mon Sep 17 00:00:00 2001 From: James McMurray Date: Wed, 17 Feb 2021 11:13:04 +0100 Subject: [PATCH 2/2] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c6eca8d..467be93 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.6.6" +version = "0.6.7" authors = ["James McMurray "] edition = "2018" license = "GPL-3.0-or-later"