eyedeekay b550471a50 makefile
2025-05-26 21:24:19 -04:00
fmt
2025-05-26 21:23:08 -04:00
2025-05-01 00:51:51 +00:00
fmt
2025-05-26 21:23:08 -04:00
2025-04-30 22:02:58 -04:00
2025-04-30 22:09:31 -04:00
2025-04-30 22:40:57 -04:00
2025-04-30 22:40:57 -04:00
2025-05-01 00:51:51 +00:00
2025-05-26 21:24:19 -04:00
2025-04-30 22:08:07 -04:00

go-meta-dialer

A dialer which will reach clearnet, onion, and I2P sites, and an HTTP Client which has specific TLS behavior for Onion and I2P domains.

Installation

go get github.com/go-i2p/go-meta-dialer

Features

  • Multi-network dialer supporting regular internet, Tor (.onion), and I2P (.i2p) connections
  • Automatic routing based on destination address
  • Optional anonymity mode to route all non-I2P connections through Tor
  • HTTP client with special TLS handling for darknet services

Usage

Basic Dialer

package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
    
    metadialer "github.com/go-i2p/go-meta-dialer"
)

func main() {
    // IMPORTANT: Close the dialers when done to prevent SAM/Tor session leaks
    defer metadialer.Garlic.Close()
    defer metadialer.Onion.Close()
    
    // Use the dialer directly
    conn, err := metadialer.Dial("tcp", "example.i2p:80")
    if err != nil {
        panic(err)
    }
    defer conn.Close()
    
    // Do something with the connection...
}

HTTP Client

package main

import (
    "fmt"
    "io/ioutil"
    
    metadialer "github.com/go-i2p/go-meta-dialer"
)

func main() {
    // IMPORTANT: Close the dialers when done
    defer metadialer.Garlic.Close()
    defer metadialer.Onion.Close()
    
    // Create a new HTTP client
    client := metadialer.NewMetaHTTPClient(nil)
    
    // Make requests to any network
    resp, err := client.Get("https://example.com")           // Normal website
    // resp, err := client.Get("http://example.onion")       // Tor onion service
    // resp, err := client.Get("http://example.i2p")         // I2P site
    
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    
    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }
    
    fmt.Println(string(body))
}

Make it the Default HTTP Client

// Set the MetaHTTPClient as the default for all HTTP requests
client := metadialer.NewMetaHTTPClient(nil)
http.DefaultClient = client.HTTPClient()

Configuration

  • metadialer.ANON = true: (Default) Routes all non-I2P connections through Tor
  • metadialer.ANON = false: Only routes .onion domains through Tor, direct connection for regular domains

Notes

  • TLS verification is skipped for .i2p and .onion domains but performs standard verification for all other domains
  • The dialer automatically routes traffic to the appropriate network based on the TLD
  • Requires a running SAM bridge (default: 127.0.0.1:7656) for I2P connections
  • Requires a running Tor SOCKS proxy for .onion connections
Description
A dialer which will reach clearnet, onion, and I2P sites, and an HTTP Client which has specific TLS behavior for Onion and I2P domains.
Readme MIT 120 KiB
Languages
Go 99.3%
Makefile 0.7%