GoGuard is a Go-based VPN client that interfaces with Mullvad's WireGuard servers. It allows users to connect to the best available server based on latency, country, or a specific server. The client also supports custom DNS settings and includes monitoring to ensure continuous connectivity.
- Server Selection: Automatically selects the best server based on latency, country, or a specific server.
- DNS Configuration: Ability to customize DNS servers.
- Key Management: Generates or uses existing WireGuard private keys.
- Pre/Post Commands: Ability to specify custom commands to run before and after the VPN connection is established or terminated.
- Connection Monitoring: Monitors VPN connection and switch servers if a lapse in connection is detected.
- Configuration Management: Uses Viper for flexible configuration management with support for environment variables and YAML configuration files.
- Go 1.16 or later
- WireGuard tools (
wg
,wg-quick
) sudo
privileges for network configuration- A Mullvad account and account #
-
Clone the repository:
git clone https://github.com/rawcsav/GoGuard.git cd GoGuard
-
Build the project:
go build -o gogguard cmd/goguard/main.go
-
Ensure
wg
andwg-quick
are installed and accessible in your PATH.
GoGuard uses a YAML configuration file for its settings. Below is an example configuration file (config.yaml
):
mullvad_account_number: "your mullvad account number"
interface_name: "wg0"
server_name: ""
country_code: "us"
use_latency_based_selection: true
dns:
- "10.64.0.1"
pre_up: []
post_up: []
pre_down: []
post_down: []
These will override the config.yaml settings:
-config
: Path to the configuration file (default:config.yaml
)-server
: WireGuard server to connect to (e.g.,se-mma-wg-001
)-country
: Country code for server selection-dns
: DNS server to use (comma-separated)-latency
: Use latency-based server selection
-
Run GoGuard with the desired configuration:
./goguard
-
To specify command-line flags:
./goguard -server=se-mma-wg-001 -dns=1.1.1.1,8.8.8.8 -latency
Note: GoGuard is currently in active development. While it is functional, it is not yet considered stable for production use. I will be continuously working on improving the core functionality/adding new features. However, this is my first Go project, and I am certainly learning as I go. Contributions and feedback are highly appreciated.
The following are the next steps for the GoGuard project, as outlined in the recent commit message:
-
More Customization:
- Implement additional features such as multihop, SOCKS5 proxy, and other Mullvad options.
-
Project Structure and Organization:
- Flesh out the project structure and organization to ensure maintainability and scalability.
- Improve logging to provide better insights and debugging information.
-
Network Settings:
- Revisit network settings to ensure that the current functions for route and DNS tunneling are necessary for Linux runtimes.
- Determine if
wg-quick
makes some of these settings trivial and adjust accordingly.
-
Robustness:
- Ensure the robustness of the application to allow it to sit in front of the WireGuard connection and adapt the connection in case of unexpected downtime.
- Implement mechanisms to handle connection lapses and automatically switch to the best available server.
-
Go Optimization:
- Ensure that Go is used properly and optimized throughout the project.
- Capitalize on the language's strengths, such as concurrency and per
GoGuard is licensed under the Attribution-ShareAlike 4.0 International License. See the LICENSE file for more information.
- Mullvad VPN for their excellent VPN service and API.
- WireGuard for the VPN protocol.