client-chaining

command
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: CC0-1.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

SOCKS Proxy Chaining Example

A client example demonstrating how to chain multiple SOCKS proxies together. The outer proxy uses the inner proxy as its dialer, creating a proxy chain.

Usage

go run . [options]
Options
  • -proxy1: First (inner) SOCKS proxy URL (default: socks5://127.0.0.1:1080)
  • -proxy2: Second (outer) SOCKS proxy URL (default: socks5://127.0.0.1:1090)
  • -url: Target URL to fetch (default: http://example.com)
  • -timeout: Request timeout (default: 30s)

How It Works

The client chaining works by setting the Dialer field of the outer proxy client to use the inner proxy's Dial method:

proxy2.Dialer = func(ctx context.Context, network, address string) (net.Conn, error) {
    return proxy1.Dial(ctx, network, address)
}

When proxy2.Dial() is called:

  1. proxy2 uses its Dialer (which calls proxy1.Dial)
  2. proxy1 establishes connection to its ProxyAddr (proxy2)
  3. proxy1 sends SOCKS CONNECT to proxy2 for the target
  4. proxy2 connects to the target
  5. Data flows: client → proxy1 → proxy2 → target

Examples

Basic Two-Proxy Chain
go run . -proxy1 socks5://localhost:1080 -proxy2 socks5://localhost:1081 -url http://example.com
Chain with Authentication
go run . -proxy1 socks5://user1:pass1@localhost:1080 -proxy2 socks5://user2:pass2@localhost:1081 -url http://httpbin.org/ip
Three-Proxy Chain

You can chain more proxies by extending the pattern:

proxy1 := ClientFromURL("socks5://proxy1:1080")
proxy2 := ClientFromURL("socks5://proxy2:1081")
proxy2.Dialer = proxy1.Dial

proxy3 := ClientFromURL("socks5://proxy3:1082")
proxy3.Dialer = proxy2.Dial

conn, err := proxy3.Dial(ctx, "tcp", target)

Documentation

Overview

nolint

Jump to

Keyboard shortcuts

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