Documentation
¶
Index ¶
- Variables
- func AppendForwardedFor(h http.Header, remoteAddr string)
- func HandleTrans(c *conn.Conn, s *TunnelModeServer) error
- func IsGlobalBlackIp(ipPort string) bool
- func KeepClientForwarding(pr *httputil.ProxyRequest)
- func ProcessHttp(c *conn.Conn, s *TunnelModeServer) error
- func ProcessMix(c *conn.Conn, s *TunnelModeServer) error
- func ProcessTunnel(c *conn.Conn, s *TunnelModeServer) error
- type BaseServer
- func (s *BaseServer) Auth(r *http.Request, c *conn.Conn, u, p string, ...) error
- func (s *BaseServer) CheckFlowAndConnNum(client *file.Client) error
- func (s *BaseServer) DealClient(c *conn.Conn, client *file.Client, addr string, rb []byte, tp string, f func(), ...) error
- func (s *BaseServer) FlowAdd(in, out int64)
- func (s *BaseServer) FlowAddHost(host *file.Host, in, out int64)
- type Binder
- type NetBridge
- type SecretServer
- type Service
- type TunnelModeServer
- type UdpModeServer
Constants ¶
This section is empty.
Variables ¶
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
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 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 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 (*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 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 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