haugene / vpn-configs-contrib

A collection of configs for various VPN providers
GNU General Public License v3.0
174 stars 739 forks source link

Update Mullvad configs and use UDP port 53 #200

Closed eiqnepm closed 1 year ago

eiqnepm commented 1 year ago

Breaking change

All Mullvad configs will now be configured to use port 53. By default Mullvad uses some ports that are seemly random however allows users to explicitly choose UDP 53, TCP 80 or TCP 443. Given all servers support all of these ports, it makes sense to choose one of these for all configs. Given the only UDP port choice is 53, it seems logical to pick that. It also has the added benefit of bypassing basic port blocking rules that don't inspect packets as UDP port 53 is very rarely blocked as it is primarily used for DNS.

I couldn't imagine anyone will be affected by this as port 53 is rarely blocked, if it is I'd imagine you already have difficulty connecting to a VPN as it is.

Proposed change

Change all Mullvad configs to UDP port 53. I've also regenerated all configs using this Python script.

```py import requests import os request = requests.get("https://api-www.mullvad.net/www/relays/all") data = request.json() template = """client dev tun resolv-retry infinite nobind persist-key persist-tun verb 3 remote-cert-tls server ping 10 ping-restart 60 sndbuf 524288 rcvbuf 524288 cipher AES-256-CBC tls-cipher TLS-DHE-RSA-WITH-AES-256-GCM-SHA384:TLS-DHE-RSA-WITH-AES-256-CBC-SHA proto udp auth-user-pass mullvad_userpass.txt ca mullvad_ca.crt tun-ipv6 script-security 2 fast-io remote-random""" servers = dict() for server in data: if not server["type"] == "openvpn": continue country_code = server["country_code"] city_code = server["city_code"] if not f"{country_code}_all" in servers: servers[f"{country_code}_all"] = list() if not f"{country_code}_{city_code}" in servers: servers[f"{country_code}_{city_code}"] = list() hostname = f"""{server["hostname"]}.relays.mullvad.net""" servers[f"{country_code}_all"].append(hostname) servers[f"{country_code}_{city_code}"].append(hostname) directory = "output" if not os.path.isdir(directory): os.mkdir(directory) for file in os.listdir(directory): if not os.path.isfile(os.path.join(directory, file)): continue if file.removesuffix(".ovpn") in servers: continue os.remove(os.path.join(directory, file)) for config in servers: with open(os.path.join("output", f"{config}.ovpn"), "w", newline="\n") as file: remotes = list() output = template for url in servers[config]: output = f"{output}\nremote {url} 53" file.write(output) ```

I've noticed the default config for Mullvad has some domains which are no longer listed on their official status API, I'm going to leave the domains as is and just change the port, if they were working before, they will continue to work, this change won't affect that. I also noticed that tun-ipv6 was removed from the default config, I'm not sure why this was because all OpenVPN servers listed on the API support IPv6, however I'm going to also leave this as is for now.

Type of change

Additional information

Checklist

If user exposed functionality or configuration variables are added/changed:

pkishino commented 1 year ago

interesting idea, I will leave this up for a while to have other people comment. But please rebase this towards dev branch for now

eiqnepm commented 1 year ago

But please rebase this towards dev branch for now

I'm only able to see the main branch

pkishino commented 1 year ago

Sorry, my bad, was thinking about the container repo..

alexandre-abrioux commented 1 year ago

@Eiqnepm Thank you for this! I've browsed your PR because some configurations on Mullvad are currently broken, and it would help a lot if this could get merged. Scripting it looks like a great idea!

I want to ask: could re-run the script before this PR gets merged? Mullvad is currently updating its hostnames to use a new naming scheme, and it would help a lot to fetch the latest data. Thank you again 🙂

Jonas-Meyer97 commented 1 year ago

For nl_all and nl_ams nl-ams-001.relays.mullvad.net should be nl-ams-ovpn-001.relays.mullvad.net EDIT: If the script is re-run the correct server is used. I also like the script. Would be nice if the script would be added to the repository. Similar to the updateConfigs.sh shell scripts.

pkishino commented 1 year ago

Any more progress here in fixing the conflicts?

eiqnepm commented 1 year ago

could re-run the script before this PR gets merged?

Any more progress here in fixing the conflicts?

Accidentally opened a new pull request, however I have fixed the conflicts and updated the profiles