From 74a17bbaebd407d99886c491fa16f0524175c575 Mon Sep 17 00:00:00 2001 From: James McMurray Date: Mon, 20 Dec 2021 16:56:24 +0100 Subject: [PATCH] Update docs for AirVPN support --- Cargo.toml | 6 +++--- README.md | 2 +- USERGUIDE.md | 9 +++++++++ src/providers/airvpn/mod.rs | 2 +- src/providers/airvpn/openvpn.rs | 15 ++++++++++----- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b4b3e19..04717ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "vopono" description = "Launch applications via VPN tunnels using temporary network namespaces" -version = "0.8.9" +version = "0.8.10" authors = ["James McMurray "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later" repository = "https://github.com/jamesmcm/vopono" homepage = "https://github.com/jamesmcm/vopono" @@ -45,7 +45,7 @@ webbrowser = "0.5" basic_tcp_proxy = "0.3" signal-hook = "0.3" config = "0.11" -serde_json = "1.0" +serde_json = "1" bs58 = "0.4" [package.metadata.rpm] diff --git a/README.md b/README.md index 8cd8ab0..a0bc4a1 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ lynx all running through different VPN connections: | MozillaVPN | ❌ | ✅ | | NordVPN | ✅ | ❌ | | HMA (HideMyAss) | ✅ | ❌ | -| airVPN | ✅ | ❌ | +| AirVPN | ✅ | ❌ | ## Usage diff --git a/USERGUIDE.md b/USERGUIDE.md index 535c9e6..12023b6 100644 --- a/USERGUIDE.md +++ b/USERGUIDE.md @@ -132,6 +132,12 @@ For Mullvad your OpenVPN credentials are your account code as your username, and For ProtonVPN you can view your OpenVPN credentials [online on your account dashboard](https://account.protonvpn.com/account#openvpn). The OpenVPN credentials are **not** the same as your ProtonVPN account credentials. +For AirVPN the OpenVPN connection uses a key embedded in the config +files, however you will need to provide your AirVPN API key and enable +API access in [the client area webpage](https://airvpn.org/apisettings/) when running `vopono sync`. +Note that ports for forwarding must also be added in [the client area webpage](https://airvpn.org/ports/), +and it is also possible to configure the VPN tunnel [DNS settings there](https://airvpn.org/dns/). + #### TCP support and custom ports By default vopono uses the UDP configuration of the VPN providers. @@ -386,6 +392,9 @@ supported for OpenVPN** on iVPN's side. So remember to pass `--protocol openvpn -o PORTNUMBER` when trying it! Enable port forwarding in the [Port Forwarding page in the iVPN client area](https://www.ivpn.net/clientarea/vpn/273887). +For AirVPN you must enable the port in [the client area webpage](https://airvpn.org/ports/), +and then use `--protocol openvpn -o PORTNUMBER` as for iVPN. + ## Dependencies At the moment, either iptables or nftables is required (the firewall diff --git a/src/providers/airvpn/mod.rs b/src/providers/airvpn/mod.rs index badafe5..e3a7d79 100644 --- a/src/providers/airvpn/mod.rs +++ b/src/providers/airvpn/mod.rs @@ -7,7 +7,7 @@ pub struct AirVPN {} impl Provider for AirVPN { fn alias(&self) -> String { - "AirVPN".to_string() + "air".to_string() } fn default_protocol(&self) -> Protocol { diff --git a/src/providers/airvpn/openvpn.rs b/src/providers/airvpn/openvpn.rs index a9a96f2..d4667aa 100644 --- a/src/providers/airvpn/openvpn.rs +++ b/src/providers/airvpn/openvpn.rs @@ -1,6 +1,7 @@ use super::AirVPN; use super::{ConfigurationChoice, OpenVpnProvider}; use crate::util::delete_all_files_in_dir; +use anyhow::anyhow; use log::debug; use serde_json::Value; use std::collections::HashMap; @@ -67,13 +68,17 @@ impl OpenVpnProvider for AirVPN { let generator_url = config_choice .url()? .replace("{servers}", request_server_names.as_str()); + + // TODO: Add validator that it is lower case, hexadecimal, 40-character string + let api_key = env::var("AIRVPN_API_KEY").or_else(|_| + dialoguer::Input::::new() + .with_prompt("Enter your AirVPN API key (see https://airvpn.org/apisettings/ )") + .interact() ).map_err(|_| { + anyhow!("Cannot generate AirVPN OpenVPN config files: AIRVPN_API_KEY is not defined in your environment variables. Get your key by activating API access in the Client Area at https://airvpn.org/apisettings/") + })?.trim().to_string(); let zipfile = client .get(generator_url) - .header( - "API-KEY", - env::var("AIRVPN_API_KEY") - .expect("AIRVPN_API_KEY is not defined in your environment variables"), - ) + .header("API-KEY", api_key) .send()?; let mut zip = ZipArchive::new(Cursor::new(zipfile.bytes()?))?; let openvpn_dir = self.openvpn_dir()?;