wiredialer

package module
v0.0.0-...-7022955 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2026 License: Unlicense Imports: 10 Imported by: 2

README

image 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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WireDialer

type WireDialer struct {
	// contains filtered or unexported fields
}

func NewDialerFromConfiguration

func NewDialerFromConfiguration(config_reader io.Reader) (*WireDialer, error)

func NewDialerFromFile

func NewDialerFromFile(path string) (*WireDialer, error)

func (*WireDialer) Dial

func (d *WireDialer) Dial(network, address string) (net.Conn, error)

func (*WireDialer) DialContext

func (d *WireDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL