proxy

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const SO_ORIGINAL_DST = 80
View Source
const (
	UserPassAuth = uint8(2)
)

Variables

This section is empty.

Functions

func GetServerNameFromClientHello

func GetServerNameFromClientHello(c net.Conn) (string, []byte)

get server name from connection by read client hello bytes

func HandleTrans

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

func IsGlobalBlackIp

func IsGlobalBlackIp(ipPort string) bool

判断访问地址是否在全局黑名单内

func IsWebsocketRequest

func IsWebsocketRequest(req *http.Request) bool

func Join

func Join(c1 io.ReadWriteCloser, c2 io.ReadWriteCloser, host *file.Host) (inCount int64, outCount int64)

func NewHTTPError

func NewHTTPError(code int, errmsg string) error

func NewHttp

func NewHttp(bridge *bridge.Bridge, c *file.Tunnel, httpPort, httpsPort int, useCache bool, cacheLen int, addOrigin bool) *httpServer

func ProcessHttp

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

http proxy

func ProcessTunnel

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

tcp proxy

Types

type BaseServer

type BaseServer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

BaseServer struct

func NewBaseServer

func NewBaseServer(bridge *bridge.Bridge, task *file.Tunnel) *BaseServer

func (*BaseServer) CheckFlowAndConnNum

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

check flow limit of the client ,and decrease the allow num of client

func (*BaseServer) DealClient

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

create a new connection and start bytes copying

func (*BaseServer) FlowAdd

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

add the flow

func (*BaseServer) FlowAddHost

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

change the flow

type HTTPError

type HTTPError struct {
	HTTPCode int
	// contains filtered or unexported fields
}

type HttpReverseProxy

type HttpReverseProxy struct {
	// contains filtered or unexported fields
}

func NewHttpReverseProxy

func NewHttpReverseProxy(s *httpServer) *HttpReverseProxy

func (*HttpReverseProxy) ServeHTTP

func (rp *HttpReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type HttpsListener

type HttpsListener struct {
	// contains filtered or unexported fields
}

func NewHttpsListener

func NewHttpsListener(l net.Listener) *HttpsListener

https listener

func (*HttpsListener) Accept

func (httpsListener *HttpsListener) Accept() (net.Conn, error)

accept

func (*HttpsListener) Addr

func (httpsListener *HttpsListener) Addr() net.Addr

addr

func (*HttpsListener) Close

func (httpsListener *HttpsListener) Close() error

close

type HttpsServer

type HttpsServer struct {
	// contains filtered or unexported fields
}

func NewHttpsServer

func NewHttpsServer(l net.Listener, bridge NetBridge, useCache bool, cacheLen int) *HttpsServer

func (*HttpsServer) Close

func (https *HttpsServer) Close() error

close

func (*HttpsServer) NewHttps

func (https *HttpsServer) NewHttps(l net.Listener, certFile string, keyFile string)

new https server by cert and key file

func (*HttpsServer) NewServer

func (s *HttpsServer) NewServer(port int, scheme string) *http.Server

func (*HttpsServer) NewServerWithTls

func (s *HttpsServer) NewServerWithTls(port int, scheme string, l net.Listener, certFile string, keyFile string) error

func (*HttpsServer) Start

func (https *HttpsServer) Start() error

start https server

type NetBridge

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

type P2PServer

type P2PServer struct {
	BaseServer
	// contains filtered or unexported fields
}

func NewP2PServer

func NewP2PServer(p2pPort int) *P2PServer

func (*P2PServer) Start

func (s *P2PServer) Start() error

type ReverseProxy

type ReverseProxy struct {
	*httputil.ReverseProxy
	WebSocketDialContext func(ctx context.Context, network, addr string) (net.Conn, error)
}

func NewReverseProxy

func NewReverseProxy(orp *httputil.ReverseProxy) *ReverseProxy

func (*ReverseProxy) ServeHTTP

func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request, host *file.Host)

type Service

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

type Sock5ModeServer

type Sock5ModeServer struct {
	BaseServer
	// contains filtered or unexported fields
}

func NewSock5ModeServer

func NewSock5ModeServer(bridge NetBridge, task *file.Tunnel) *Sock5ModeServer

new

func (*Sock5ModeServer) Auth

func (s *Sock5ModeServer) Auth(c net.Conn) error

socks5 auth

func (*Sock5ModeServer) Close

func (s *Sock5ModeServer) Close() error

close

func (*Sock5ModeServer) Start

func (s *Sock5ModeServer) Start() error

start

type TunnelModeServer

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

func NewTunnelModeServer

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

tcp|http|host

func (*TunnelModeServer) Close

func (s *TunnelModeServer) Close() error

close

func (*TunnelModeServer) Start

func (s *TunnelModeServer) Start() error

开始

type UdpModeServer

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

func NewUdpModeServer

func NewUdpModeServer(bridge *bridge.Bridge, task *file.Tunnel) *UdpModeServer

func (*UdpModeServer) Close

func (s *UdpModeServer) Close() error

func (*UdpModeServer) Start

func (s *UdpModeServer) Start() error

开始

type WebServer

type WebServer struct {
	BaseServer
}

web管理方式

func NewWebServer

func NewWebServer(bridge *bridge.Bridge) *WebServer

new

func (*WebServer) Close

func (s *WebServer) Close() error

func (*WebServer) Start

func (s *WebServer) Start() error

开始

Jump to

Keyboard shortcuts

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