Documentation
¶
Index ¶
- Variables
- func AddRouteInfo(httpId string, domain string, paths []string, fun ProxyConnectionFunction)
- func RouteClean()
- type Conn
- func (h *Conn) Close() error
- func (h *Conn) LocalAddr() net.Addr
- func (h *Conn) OnData(b []byte)
- func (h *Conn) Read(b []byte) (n int, err error)
- func (h *Conn) RemoteAddr() net.Addr
- func (h *Conn) SetDeadline(t time.Time) error
- func (h *Conn) SetReadDeadline(t time.Time) error
- func (h *Conn) SetWriteDeadline(t time.Time) error
- func (h *Conn) Write(b []byte) (n int, err error)
- type Future
- type Proxy
- type ProxyConnection
- type ProxyConnectionFunction
- type ResponseFuture
- type RouteFunction
- type RouteInfo
- type Tracker
- type TunnelHttpServer
- func (htl *TunnelHttpServer) Open(ch Channel, tb srv.TraverseBy) error
- func (htl *TunnelHttpServer) OpenWorker(ch Channel, request *exchange.ClientWorkConnReq) error
- func (htl *TunnelHttpServer) Reader(ch Channel, tb srv.TraverseBy) error
- func (htl *TunnelHttpServer) RegisterConn(ch Channel, request exchange.TRegister) (serverId string, err error)
- type WebsocketConnection
- type WebsocketProxy
- type WsFuture
Constants ¶
This section is empty.
Variables ¶
var ( PHttpErr = errors.New("the server requested http, but the request was https") PHttpsErr = errors.New("the server requested https, but the request was http") PTimeout = errors.New("read client timeout, connect close") )
var ( RouteInfoKey = "routeInfo" RequestInfoKey = "httpRequestId" RequestHttpIdKey = "br_httpId" RequestDomainKey = "br_domain" ProxyKey = "httpProxy" ForwardedKey = "X-Forwarded-For" )
Functions ¶
func AddRouteInfo ¶
func AddRouteInfo(httpId string, domain string, paths []string, fun ProxyConnectionFunction)
AddRouteInfo adds a route to the routes slice
func RouteClean ¶
func RouteClean()
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) OnData ¶
OnData handles incoming data for the HTTP connection It writes the data to an internal buffer and signals that new data is available
func (*Conn) Read ¶
Read implements the io.Reader interface for HttpConn. It reads data from the connection buffer with proper synchronization and protocol validation.
func (*Conn) RemoteAddr ¶
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
func NewHttpProxy ¶
func NewHttpProxy(fun RouteFunction, proxyId string) *Proxy
type ProxyConnection ¶
func NewProxyConnection ¶
func NewProxyConnection(conn net.Conn, tracker *Tracker) *ProxyConnection
func (*ProxyConnection) Close ¶
func (proxy *ProxyConnection) Close() error
func (*ProxyConnection) Read ¶
func (proxy *ProxyConnection) Read(p []byte) (n int, err error)
Read implements the io.Reader interface for ProxyConnection It reads data from the connection, first checking any cached data, then waiting for new data if necessary
func (*ProxyConnection) Write ¶
func (proxy *ProxyConnection) Write(b []byte) (n int, err error)
Write implements the io.Writer interface for ProxyConnection. It encodes the provided byte slice into a tunnel protocol format and writes it to the connection. The encoding method differs based on whether the connection is a WebSocket or regular connection.
type ProxyConnectionFunction ¶
ProxyConnectionFunction is a function that returns a net.Conn
type ResponseFuture ¶
type ResponseFuture struct {
// contains filtered or unexported fields
}
func (*ResponseFuture) Close ¶
func (f *ResponseFuture) Close()
func (*ResponseFuture) Done ¶
func (f *ResponseFuture) Done(data []byte)
func (*ResponseFuture) Error ¶
func (f *ResponseFuture) Error(err error)
func (*ResponseFuture) ReqId ¶
func (f *ResponseFuture) ReqId() int64
func (*ResponseFuture) Wait ¶
func (f *ResponseFuture) Wait() ([]byte, error)
func (*ResponseFuture) WaitTimeout ¶
func (f *ResponseFuture) WaitTimeout(d time.Duration) ([]byte, error)
WaitTimeout waits with timeout
type RouteFunction ¶
RouteFunction is a function that returns a RouteInfo
type RouteInfo ¶
type RouteInfo struct {
// contains filtered or unexported fields
}
RouteInfo is a struct that holds information about a route
func GetRouteInfo ¶
GetRouteInfo returns the RouteInfo for a given path
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker HttpTracker httpx tracker
func NewHttpTracker ¶
func (*Tracker) PutRequest ¶
type TunnelHttpServer ¶
type TunnelHttpServer struct {
*tunnel.BaseTunnelServer
// contains filtered or unexported fields
}
TunnelHttpServer is a struct that represents a HTTP tunnel server.
func NewHttpTunnelServer ¶
func NewHttpTunnelServer(server *tunnel.BaseTunnelServer) (*TunnelHttpServer, error)
NewHttpTunnelServer is a constructor function for HttpTunnelServer. It takes a pointer to BaseTunnelServer as input and returns a pointer to HttpTunnelServer. The constructor sets the NewDupServer field of BaseTunnelServer to the startAfter method of HttpTunnelServer, which is used to perform cleanup or subsequent processing operations startAfter the server processes the request. The constructor also returns a pointer to HttpTunnelServer.
func (*TunnelHttpServer) Open ¶
func (htl *TunnelHttpServer) Open(ch Channel, tb srv.TraverseBy) error
func (*TunnelHttpServer) OpenWorker ¶
func (htl *TunnelHttpServer) OpenWorker(ch Channel, request *exchange.ClientWorkConnReq) error
func (*TunnelHttpServer) Reader ¶
func (htl *TunnelHttpServer) Reader(ch Channel, tb srv.TraverseBy) error
Reader is a method of HttpTunnelServer, which is used to process incoming requests. It
func (*TunnelHttpServer) RegisterConn ¶
func (htl *TunnelHttpServer) RegisterConn(ch Channel, request exchange.TRegister) (serverId string, err error)
RegisterConn is a method of HttpTunnelServer, which is used to register a connection.
type WebsocketConnection ¶
func (*WebsocketConnection) Close ¶
func (wc *WebsocketConnection) Close() error
type WebsocketProxy ¶
type WebsocketProxy struct {
// contains filtered or unexported fields
}
func NewWebsocketProxy ¶
func NewWebsocketProxy(route func(req *http.Request) (*RouteInfo, error)) *WebsocketProxy
func (*WebsocketProxy) ServeHTTP ¶
func (h *WebsocketProxy) ServeHTTP(writer http.ResponseWriter, request *http.Request)