proxy

package
v0.34.8 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: GPL-3.0 Imports: 25 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.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrServerClosed = errors.New("server closed")

ErrServerClosed is returned by Bind and Start once the server was closed.

Functions

func AppendForwardedFor added in v0.34.8

func AppendForwardedFor(h http.Header, remoteAddr string)

AppendForwardedFor appends the client IP taken from remoteAddr to the X-Forwarded-For header of h, creating the header when it is absent.

func HandleTrans

func HandleTrans(c *conn.Conn, s *TunnelModeServer) error

HandleTrans forwards a connection redirected to the transparent proxy, by iptables REDIRECT or TPROXY on Linux or pf on macOS and FreeBSD, to its original destination.

func IsGlobalBlackIp

func IsGlobalBlackIp(ipPort string) bool

func KeepClientForwarding added in v0.34.8

func KeepClientForwarding(pr *httputil.ProxyRequest)

KeepClientForwarding undoes the clean-up ReverseProxy applies before Rewrite, so the client's request reaches the rewrite logic as sent: the forwarding headers come back unless the client listed them in Connection, and the query string keeps parameters ReverseProxy cannot parse.

func ProcessHttp

func ProcessHttp(c *conn.Conn, s *TunnelModeServer) error

ProcessHttp http proxy

func ProcessMix added in v0.29.0

func ProcessMix(c *conn.Conn, s *TunnelModeServer) error

func ProcessTunnel

func ProcessTunnel(c *conn.Conn, s *TunnelModeServer) error

ProcessTunnel tcp proxy

Types

type BaseServer

type BaseServer struct {
	Id              int
	Bridge          NetBridge
	Task            *file.Tunnel
	ErrorContent    []byte
	AllowLocalProxy bool
	sync.Mutex
	// contains filtered or unexported fields
}

BaseServer struct

func NewBaseServer

func NewBaseServer(bridge NetBridge, task *file.Tunnel, allowLocalProxy bool) *BaseServer

func (*BaseServer) Auth added in v0.30.0

func (s *BaseServer) Auth(r *http.Request, c *conn.Conn, u, p string, multiAccount, userAuth *file.MultiAccount) error

Auth check

func (*BaseServer) CheckFlowAndConnNum

func (s *BaseServer) CheckFlowAndConnNum(client *file.Client) error

CheckFlowAndConnNum check flow limit of the client ,and decrease the allowed num of client

func (*BaseServer) DealClient

func (s *BaseServer) DealClient(c *conn.Conn, client *file.Client, addr string,
	rb []byte, tp string, f func(), flows []*file.Flow, proxyProtocol int, localProxy bool, task *file.Tunnel) error

func (*BaseServer) FlowAdd

func (s *BaseServer) FlowAdd(in, out int64)

FlowAdd add the flow

func (*BaseServer) FlowAddHost

func (s *BaseServer) FlowAddHost(host *file.Host, in, out int64)

FlowAddHost change the flow

type Binder added in v0.34.8

type Binder interface {
	Bind() error
}

Binder is implemented by services that own a listening socket. Bind opens it synchronously so that the caller learns about address errors before the service is published, after which Start serves on it. Bind is idempotent and fails with ErrServerClosed once Close has been called, so a Close racing with Bind or Start never leaves a socket open.

type NetBridge

type NetBridge interface {
	SendLinkInfo(clientId int, link *conn.Link, t *file.Tunnel) (target net.Conn, err error)
	IsServer() bool
	CliProcess(c *conn.Conn, tunnelType string)
}

type SecretServer added in v0.30.4

type SecretServer struct {
	*BaseServer
	// contains filtered or unexported fields
}

func NewSecretServer added in v0.30.4

func NewSecretServer(bridge NetBridge, task *file.Tunnel, allowLocalProxy, allowSecretLink, allowSecretLocal bool) *SecretServer

func (*SecretServer) HandleSecret added in v0.30.4

func (s *SecretServer) HandleSecret(src net.Conn) error

type Service

type Service interface {
	Start() error
	Close() error
}

type TunnelModeServer

type TunnelModeServer struct {
	*BaseServer
	// contains filtered or unexported fields
}

func NewTunnelModeServer

func NewTunnelModeServer(process process, bridge NetBridge, task *file.Tunnel, allowLocalProxy bool) *TunnelModeServer

NewTunnelModeServer tcp|host|mixproxy

func (*TunnelModeServer) Bind added in v0.34.8

func (s *TunnelModeServer) Bind() error

Bind opens the TCP listener and, for SOCKS5, the UDP associate socket.

func (*TunnelModeServer) Close

func (s *TunnelModeServer) Close() error

func (*TunnelModeServer) DialVirtual added in v0.33.5

func (s *TunnelModeServer) DialVirtual(rAddr string) (net.Conn, error)

func (*TunnelModeServer) ServeVirtual added in v0.33.5

func (s *TunnelModeServer) ServeVirtual(c net.Conn)

func (*TunnelModeServer) SocksAuth added in v0.30.0

func (s *TunnelModeServer) SocksAuth(c net.Conn) error

SocksAuth reads the client's username/password request, checks it against the task's accounts and answers it. It returns socks5.ErrAuthFailed for rejected credentials.

func (*TunnelModeServer) Start

func (s *TunnelModeServer) Start() error

type UdpModeServer

type UdpModeServer struct {
	*BaseServer
	// contains filtered or unexported fields
}

func NewUdpModeServer

func NewUdpModeServer(bridge NetBridge, task *file.Tunnel, allowLocalProxy bool) *UdpModeServer

func (*UdpModeServer) Bind added in v0.34.8

func (s *UdpModeServer) Bind() error

Bind opens the UDP socket.

func (*UdpModeServer) Close

func (s *UdpModeServer) Close() error

func (*UdpModeServer) Start

func (s *UdpModeServer) Start() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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