8000 Add PIA Wireguard support by mobad · Pull Request #183 · jamesmcm/vopono · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add PIA Wireguard support #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8000
Merged
merged 2 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vopono_core/src/config/providers/azirevpn/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl WireguardProvider for AzireVPN {
public_key: wg_peer.public_key.clone(),
allowed_ips: allowed_ips.clone(),
endpoint: wg_peer.endpoint,
keepalive: None,
};

let wireguard_conf = WireguardConfig {
Expand Down
1 change: 1 addition & 0 deletions vopono_core/src/config/providers/ivpn/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ impl WireguardProvider for IVPN {
public_key: relay.pubkey.clone(),
allowed_ips: allowed_ips.clone(),
endpoint: SocketAddr::new(relay.ip, port),
keepalive: None,
};

let wireguard_conf = WireguardConfig {
Expand Down
7 changes: 6 additions & 1 deletion vopono_core/src/config/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use crate::config::vpn::Protocol;
use crate::util::vopono_dir;
use anyhow::anyhow;
use serde::{Deserialize, Serialize};
use std::net::IpAddr;
use std::path::PathBuf;
use std::{net::IpAddr, path::Path};
use strum_macros::{Display, EnumIter};

// Command-line arguments use VpnProvider enum
Expand Down Expand Up @@ -78,6 +78,7 @@ impl VpnProvider {

pub fn get_dyn_wireguard_provider(&self) -> anyhow::Result<Box<dyn WireguardProvider>> {
match self {
Self::PrivateInternetAccess => Ok(Box::new(pia::PrivateInternetAccess {})),
Self::Mullvad => Ok(Box::new(mullvad::Mullvad {})),
Self::MozillaVPN => Ok(Box::new(mozilla::MozillaVPN {})),
Self::AzireVPN => Ok(Box::new(azirevpn::AzireVPN {})),
Expand Down Expand Up @@ -115,6 +116,10 @@ pub trait WireguardProvider: Provider {
fn wireguard_dir(&self) -> anyhow::Result<PathBuf> {
Ok(self.provider_dir()?.join("wireguard"))
}

fn wireguard_preup(&self, _config_file: &Path) -> anyhow::Result<()> {
Ok(())
}
}

/// This trait is implemented if the VPN provider has OpenVPN support
Expand Down
1 change: 1 addition & 0 deletions vopono_core/src/config/providers/mozilla/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ impl WireguardProvider for MozillaVPN {
public_key: relay.pubkey.clone(),
allowed_ips: allowed_ips.clone(),
endpoint: SocketAddr::new(IpAddr::from(relay.ipv4_addr_in), port),
keepalive: None,
};

let wireguard_conf = WireguardConfig {
Expand Down
1 change: 1 addition & 0 deletions vopono_core/src/config/providers/mullvad/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl WireguardProvider for Mullvad {
public_key: relay.pubkey.clone(),
allowed_ips: allowed_ips.clone(),
endpoint: SocketAddr::new(IpAddr::from(relay.ipv4_addr_in), port),
keepalive: None,
};

let wireguard_conf = WireguardConfig {
Expand Down
43 changes: 43 additions & 0 deletions vopono_core/src/config/providers/pia/ca.rsa.4096.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
-----BEGIN CERTIFICATE-----
MIIHqzCCBZOgAwIBAgIJAJ0u+vODZJntMA0GCSqGSIb3DQEBDQUAMIHoMQswCQYD
VQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNVBAcTCkxvc0FuZ2VsZXMxIDAeBgNV
BAoTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMSAwHgYDVQQLExdQcml2YXRlIElu
dGVybmV0IEFjY2VzczEgMB4GA1UEAxMXUHJpdm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j3
5xN2cUppg74nG3YVav/38P48T56hG1NHbYF5uOCske19F6wi9maUoto/3vEr0rnX
JUp2KODmKdvBI7co245lHBABWikk8VfejQSlCtDBXn644ZMtAdoxKNfR2WTFVEwJ
iyd1Fzx0yujuiXDROLhISLQDRjVVAvawrAtLZWYK31bY7KlezPlQnl/D9Asxe85l
8jO5+0LdJ6VyOs/Hd4w52alDW/MFySDZSfQHMTIc30hLBJ8OnCEIvluVQQ2UQvoW
+no177N9L2Y+M9TcTA62ZyMXShHQGeh20rb4kK8f+iFX8NxtdHVSkxMEFSfDDyQ=
-----END CERTIFICATE-----
20 changes: 19 additions & 1 deletion vopono_core/src/config/providers/pia/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
mod openvpn;
mod wireguard;

use super::{ConfigurationChoice, OpenVpnProvider, Provider};
use super::{
ConfigurationChoice, Input, OpenVpnProvider, Password, Provider, UiClient, WireguardProvider,
};
use crate::config::vpn::Protocol;

pub struct PrivateInternetAccess {}
Expand All @@ -14,3 +17,18 @@ impl Provider for PrivateInternetAccess {
Protocol::OpenVpn
}
}

impl PrivateInternetAccess {
fn prompt_for_auth(&self, uiclient: &dyn UiClient) -> anyhow::Result<(String, String)> {
let username = uiclient.get_input(Input {
prompt: "PrivateInternetAccess username".to_string(),
validator: None,
})?;
let password = uiclient.get_password(Password {
prompt: "Password".to_string(),
confirm: true,
})?;

Ok((username, password))
}
}
17 changes: 4 additions & 13 deletions vopono_core/src/config/providers/pia/openvpn.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::PrivateInternetAccess;
use super::{ConfigurationChoice, OpenVpnProvider};
use crate::config::providers::{Input, Password, UiClient};
use crate::config::providers::UiClient;
use crate::util::delete_all_files_in_dir;
use log::debug;
use reqwest::Url;
Expand All @@ -23,16 +23,7 @@ impl OpenVpnProvider for PrivateInternetAccess {
}

fn prompt_for_auth(&self, uiclient: &dyn UiClient) -> anyhow::Result<(String, String)> {
let username = uiclient.get_input(Input {
prompt: "PrivateInternetAccess username".to_string(),
validator: None,
})?;
let password = uiclient.get_password(Password {
prompt: "Password".to_string(),
confirm: true,
})?;

Ok((username, password))
self.prompt_for_auth(uiclient)
}

fn auth_file_path(&self) -> anyhow::Result<Option<PathBuf>> {
Expand Down Expand Up @@ -93,8 +84,8 @@ impl OpenVpnProvider for PrivateInternetAccess {
// Write OpenVPN credentials file
let (user, pass) = self.prompt_for_auth(uiclient)?;
let auth_file = self.auth_file_path()?;
if auth_file.is_some() {
let mut outfile = File::create(auth_file.unwrap())?;
if let Some(auth_file) = auth_file {
let mut outfile = File::create(auth_file)?;
write!(outfile, "{}\n{}", user, pass)?;
}
Ok(())
Expand Down
Loading
0