WireDialer
A usermode WireGuard client in an idiomatic Golang Dialer style, by Botanica Software Labs
WireDialer provides an adapter between WireGuard configuration files and Go's standard Dial and DialContext functions, enabling per-connection VPN routing without modifying system network configuration.
Features
- No root privileges required - runs entirely in userspace
- Works with standard WireGuard configuration files
- Integrates with Go's
net.Dialer interface
- Per-connection routing without system-wide changes
- Compatible with any Go application accepting custom dialers
Installation
go get github.com/botanica-consulting/wiredialer
Usage
WireDialer implements the standard Go dialer interface, making it compatible with any library that accepts a custom dialer. Simply create a WireDialer from your WireGuard config and use it wherever you'd use a standard net.Dialer.
Examples
HTTP Client
package main
import (
"fmt"
"io"
"net/http"
"os"
"github.com/botanica-consulting/wiredialer"
)
func main() {
// Create a WireDialer from your WireGuard configuration
dialer, err := wiredialer.NewDialerFromFile("wg0.conf")
if err != nil {
fmt.Printf("Failed to create dialer: %v\n", err)
os.Exit(1)
}
// Create HTTP client using the WireGuard tunnel
client := &http.Client{
Transport: &http.Transport{
DialContext: dialer.DialContext,
},
}
// Make requests through the tunnel
resp, err := client.Get("https://cloudflare.com/cdn-cgi/trace")
if err != nil {
fmt.Printf("Request failed: %v\n", err)
os.Exit(1)
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
}
For more examples, see the examples directory.
Disclaimer: This library is not an official product, use freely at your own risk.