Help us shape the future of Go! Take the 2026 Go Developer Survey

proxyfront

package
v1.3.104-alpha1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package proxyfront pkg/proxyfront/proxyfront.go

One listener, two proxy protocols. The resolving proxies speak SOCKS5; this lets the same port also answer HTTP proxy requests (CONNECT and absolute-URL requests), which is what an OS-level HTTP proxy setting — Android's VpnService.Builder.setHttpProxy, a browser's "HTTP proxy" field — speaks. A connection whose first byte is the SOCKS5 version goes to the SOCKS5 server; anything else is handled as HTTP through the same dial path, so .dmsg, .skynet, the status pages and the upstream rules behave identically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeConn added in v1.3.99

func ServeConn(c net.Conn, serveSOCKS5, serveHTTP func(net.Conn))

ServeConn applies the same protocol split to one already-accepted connection, for a caller with no listener to wrap: the resolvers' in-process local-service path, where a conn arrives over net.Pipe rather than from Accept. The conn is handed to serveSOCKS5 or serveHTTP, and closed here only when its first byte never arrives.

func ServeHTTP

func ServeHTTP(ctx context.Context, c net.Conn, dial DialFunc)

ServeHTTP answers one HTTP proxy connection: a CONNECT becomes a tunnel, an absolute-URL request is forwarded and its response relayed. The connection is closed when it returns.

func Split

func Split(lis net.Listener, serveHTTP func(net.Conn)) net.Listener

Split wraps lis so that Accept returns only SOCKS5 connections; every other connection is handed to serveHTTP on its own goroutine.

Types

type DialFunc

type DialFunc func(ctx context.Context, host, port string) (net.Conn, error)

DialFunc opens a connection to host:port the way the proxy's SOCKS5 server would for a CONNECT to that name.

func SOCKSDial

func SOCKSDial(resolver socks5.NameResolver, dial func(ctx context.Context, network, addr string) (net.Conn, error)) DialFunc

SOCKSDial builds a DialFunc from a SOCKS5 server's resolver and dial callback, taking the steps go-socks5 takes for a CONNECT: resolve a name (which is where the resolving proxies record the original hostname), then dial the resolved address.

Jump to

Keyboard shortcuts

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