Skip to content

Commit

Permalink
Fix Mullvad Wireguard configs with new naming
Browse files Browse the repository at this point in the history
- Stops configs for same cities being overwritten due to the new naming
  convention
- Server listing is now sorted
- Added some documentation for OpenVPN DNS issues
  • Loading branch information
jamesmcm committed Jan 6, 2023
1 parent 292a8a8 commit 29af9f8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
16 changes: 16 additions & 0 deletions USERGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ API access in [the client area webpage](https://airvpn.org/apisettings/) when ru
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/).

#### Connection / hostname resolution issues

If you face issues with OpenVPN resolving the remote host, try generating the VPN provider config files with IP addresses instead.

e.g. the error may appear as follows:

```
2023-01-06 13:19:18 RESOLVE: Cannot resolve host address: ro-buh-ovpn-002.mullvad.net:1197 (Name or service not known)
```

#### TCP support and custom ports

By default vopono uses the UDP configuration of the VPN providers.
Expand Down Expand Up @@ -525,3 +535,9 @@ sudo ip netns exec ping 8.8.8.8
```

See issues #40, #24, #2, and #1 for previous troubleshooting of issues.

### DNS / name resolution issues

When encountering issues in name resolution (e.g. with OpenVPN resolving remote host names), please
first try generating the VPN provider config files with IP addresses instead to see whether the issue
is connection/firewall related or solely a DNS / hostname resolution issue.
8 changes: 6 additions & 2 deletions src/list_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ pub fn print_configs(cmd: ServersCommand) -> anyhow::Result<()> {
if (cmd.protocol.is_none() && provider.get_dyn_openvpn_provider().is_ok())
|| cmd.protocol.clone().map(|x| x.to_variant()) == Some(Protocol::OpenVpn)
{
let openvpn_configs = get_configs_from_alias(
let mut openvpn_configs = get_configs_from_alias(
&provider.get_dyn_openvpn_provider()?.openvpn_dir()?,
&prefix,
);

openvpn_configs.sort_by_key(|c| c.file_name().unwrap().to_str().unwrap().to_owned());

for config in openvpn_configs {
println!(
"{}\topenvpn\t{}",
Expand All @@ -55,11 +57,13 @@ pub fn print_configs(cmd: ServersCommand) -> anyhow::Result<()> {
if (cmd.protocol.is_none() && provider.get_dyn_wireguard_provider().is_ok())
|| cmd.protocol.map(|x| x.to_variant()) == Some(Protocol::Wireguard)
{
let wg_configs = get_configs_from_alias(
let mut wg_configs = get_configs_from_alias(
&provider.get_dyn_wireguard_provider()?.wireguard_dir()?,
&prefix,
);

wg_configs.sort_by_key(|c| c.file_name().unwrap().to_str().unwrap().to_owned());

for config in wg_configs {
println!(
"{}\twireguard\t{}",
Expand Down
19 changes: 14 additions & 5 deletions vopono_core/src/config/providers/mullvad/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,20 @@ impl WireguardProvider for Mullvad {
peer: wireguard_peer,
};

let host = relay
.hostname
.split('-')
.next()
.unwrap_or_else(|| panic!("Failed to split hostname: {}", relay.hostname));
let host = if relay.hostname.chars().filter(|c| *c == '-').count() > 1 {
// New naming convention - at-vie-wg-001
let substrings: Vec<&str> = relay.hostname.split('-').collect();

substrings[0].to_owned() + substrings[1] + substrings[3]
} else {
// Old naming convention - au10-wireguard
relay
.hostname
.split('-')
.next()
.unwrap_or_else(|| panic!("Failed to split hostname: {}", relay.hostname))
.to_owned()
};

let country = relay.country_name.to_lowercase().replace(' ', "_");
let path = wireguard_dir.join(format!("{country}-{host}.conf"));
Expand Down
7 changes: 5 additions & 2 deletions vopono_core/src/network/openvpn.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::firewall::Firewall;
use super::netns::NetworkNamespace;
use crate::config::vpn::OpenVpnProtocol;
use crate::util::{check_process_running, vopono_dir};
use crate::util::{check_process_running, set_config_permissions, vopono_dir};
use anyhow::{anyhow, Context};
use log::{debug, error, info};
use regex::Regex;
Expand Down Expand Up @@ -51,7 +51,7 @@ impl OpenVpn {
}

let config_file_path = config_file.canonicalize().context("Invalid path given")?;

set_config_permissions()?;
info!("Launching OpenVPN...");
let mut command_vec = ([
"openvpn",
Expand All @@ -78,6 +78,9 @@ impl OpenVpn {
debug!("Detected IPv6 enabled in /sys/module/ipv6/parameters/disable");
}

// Only try once for DNS resolution / remote host connection
command_vec.push("--connect-retry-max");
command_vec.push("1");
// Ignore Windows-specific command
command_vec.push("--pull-filter");
command_vec.push("ignore");
Expand Down

0 comments on commit 29af9f8

Please sign in to comment.