{"id":13548459,"url":"https://github.com/bastiandoetsch/mullvad-best-server","last_synced_at":"2025-10-25T01:11:06.426Z","repository":{"id":42386327,"uuid":"466777162","full_name":"bastiandoetsch/mullvad-best-server","owner":"bastiandoetsch","description":"Determines the Mullvad server with the lowest latency","archived":false,"fork":false,"pushed_at":"2023-10-10T06:05:01.000Z","size":50,"stargazers_count":50,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-08T13:14:41.348Z","etag":null,"topics":["go","latency","mullvad","vpn"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bastiandoetsch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-03-06T15:28:41.000Z","updated_at":"2024-09-08T12:17:01.000Z","dependencies_parsed_at":"2023-01-18T11:46:07.150Z","dependency_job_id":null,"html_url":"https://github.com/bastiandoetsch/mullvad-best-server","commit_stats":{"total_commits":39,"total_committers":2,"mean_commits":19.5,"dds":0.05128205128205132,"last_synced_commit":"ab734897c6ea2394afaf0fe8714d775c14d656a3"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bastiandoetsch%2Fmullvad-best-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bastiandoetsch%2Fmullvad-best-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bastiandoetsch%2Fmullvad-best-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bastiandoetsch%2Fmullvad-best-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bastiandoetsch","download_url":"https://codeload.github.com/bastiandoetsch/mullvad-best-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221695598,"owners_count":16865252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","latency","mullvad","vpn"],"created_at":"2024-08-01T12:01:10.663Z","updated_at":"2025-10-25T01:11:01.394Z","avatar_url":"https://github.com/bastiandoetsch.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# mullvad-best-server\n![Build](https://github.com/bastiandoetsch/mullvad-best-server/actions/workflows/go.yml/badge.svg)\n\nDetermines the mullvad.net server with the lowest latency on macOS and Linux. On Windows, it can only check if the server is up.\nThe reason lies with the golang network libraries, according to the `go-ping` library, that is used under the hood for pinging: \n\n```\nPlease note that accessing packet TTL values is not supported due to limitations in the Go x/net/ipv4 and x/net/ipv6 packages.\n```\n\n## Installation\n\nDownload binary from releases for your platform and unpack.\n\n## Usage\n### Default usage\nExecute `mullvad-best-server`. It outputs the code, e.g. `de05`. You can then connect to it with e.g. wireguard using the normal shell scripts.\n\n### Command line parameters\n\n```angular2html\nUsage of ./mullvad-best-server:\n  -c string\n    \tServer country code, e.g. ch for Switzerland (default \"ch\")\n  -l string\n    \tLog level. Allowed values: trace, debug, info, warn, error, fatal, panic (default \"info\")\n  -o string\n    \tOutput format. 'json' outputs server json\n  -p string\n    \tfilter by provider, e.g. 31173 for mullvad-owned\n  -t string\n    \tServer type, e.g. wireguard (default \"wireguard\")\n  -timeout duration\n    \tTimeout for network calls as duration, e.g. 60s (default 5s)\n```\n\nIf you want the full server information, execute `mullvad-best-server -o json`. It returns the full json output  of the server information.\nThe `-c` flag allows to give a country code. Else `ch` will be used.\n\n\n## Background\nThe program uses `https://api.mullvad.net/www/relays/\u003cSERVER_TYPE\u003e/` to get the current server list, pings the ones with the right country\nand outputs the server with the lowest ping.\n\n## Integration into a script\nI use it on my router like this (yes, I know I could have done the whole thing with jq and shell scripting, but wanted to use go for maintainability).\n```\n#!/bin/sh\nset -e\nLATEST_RELEASE=$(curl -sSL https://api.github.com/repos/bastiandoetsch/mullvad-best-server/releases/latest | jq -r '.assets[]| .browser_download_url' | grep Linux_arm64)\ncurl -sSL $LATEST_RELEASE \u003e /root/mullvad-best-server\nchmod +x /root/mullvad-best-server\n/usr/bin/wg-quick down $(wg show|grep interface | cut -d: -f2)  || echo \"nothing to shut down\"\n/usr/bin/wg-quick up \"mullvad-$(/root/mullvad-best-server -c de)\"\n```\n\n## Troubleshooting\nYou may have to update your `/usr/bin/wg-quick` script for the new mullvad servers, as they have names longer than 15 chars. Replace `[[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,15} ]]$` with `[[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,25}$ ]]` and `[[ $CONFIG_FILE =~ (^|/)([a-zA-Z0-9_=+.-]{1,15})\\.conf$ ]]` with `[[ $CONFIG_FILE =~ (^|/)([a-zA-Z0-9_=+.-]{1,25})\\.conf$ ]]`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbastiandoetsch%2Fmullvad-best-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbastiandoetsch%2Fmullvad-best-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbastiandoetsch%2Fmullvad-best-server/lists"}