Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddonNotifier ¶
type AddonNotifier interface {
NotifyClientDisconnected(*ClientConn)
NotifyServerDisconnected(*Context)
}
AddonNotifier defines callbacks for addon notifications.
type ClientConn ¶
type ClientConn struct {
ID uuid.UUID
Conn net.Conn
TLS bool
NegotiatedProtocol string
UpstreamCert bool // Connect to upstream server to look up certificate details. Default: True
ClientHello *tls.ClientHelloInfo
CloseChan chan struct{} // Channel that is closed when the connection is closed
}
ClientConn represents a client connection.
func NewClientConn ¶
func NewClientConn(c net.Conn) *ClientConn
NewClientConn creates a new ClientConn instance.
func (*ClientConn) MarshalJSON ¶
func (c *ClientConn) MarshalJSON() ([]byte, error)
type Context ¶
type Context struct {
ClientConn *ClientConn `json:"clientConn"`
ServerConn *ServerConn `json:"serverConn"`
Intercept bool `json:"intercept"` // Indicates whether to parse HTTPS
FlowCount atomic.Uint32 `json:"-"` // Number of HTTP requests made on the same connection
CloseAfterResponse bool // after http response, http server will close the connection
DialFn func(context.Context) error `json:"-"` // when begin request, if there no ServerConn, use this func to dial
}
Context represents the connection context for a proxy connection.
func NewContext ¶
func NewContext(clientConn *ClientConn) *Context
NewContext creates a new connection context.
type ServerConn ¶
type ServerConn struct {
ID uuid.UUID
Address string
Conn net.Conn
Client *http.Client
TLSConn *tls.Conn
TLSState *tls.ConnectionState
}
ServerConn represents a server connection.
func NewServerConn ¶
func NewServerConn() *ServerConn
NewServerConn creates a new ServerConn instance.
func (*ServerConn) GetTLSState ¶
func (c *ServerConn) GetTLSState() *tls.ConnectionState
GetTLSState returns the TLS connection state.
func (*ServerConn) MarshalJSON ¶
func (c *ServerConn) MarshalJSON() ([]byte, error)
type WrapClientConn ¶
type WrapClientConn struct {
net.Conn
ConnCtx *Context
CloseChan chan struct{}
// contains filtered or unexported fields
}
WrapClientConn wraps a net.Conn for remote client connections.
func NewWrapClientConn ¶
func NewWrapClientConn(c net.Conn, addonNotifier AddonNotifier) *WrapClientConn
NewWrapClientConn creates a new wrapped client connection.
func (*WrapClientConn) Close ¶
func (c *WrapClientConn) Close() error
Close closes the connection and notifies addons.
type WrapServerConn ¶
WrapServerConn wraps a net.Conn for remote server connections.
func NewWrapServerConn ¶
func NewWrapServerConn(c net.Conn, connCtx *Context, addonNotifier AddonNotifier) *WrapServerConn
NewWrapServerConn creates a new wrapped server connection.
func (*WrapServerConn) Close ¶
func (c *WrapServerConn) Close() error
Close closes the connection and notifies addons.