Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain is a chain for TCP handlers. Chain acts as a list of tcp.Handler constructors. Chain is effectively immutable: once created, it will always hold the same set of constructors in the same order.
func NewChain ¶
func NewChain(constructors ...Constructor) Chain
NewChain creates a new TCP chain, memorizing the given list of TCP middleware constructors. New serves no other function, constructors are only called upon a call to Then().
func (Chain) Append ¶
func (c Chain) Append(constructors ...Constructor) Chain
Append extends a chain, adding the specified constructors as the last ones in the request flow.
Append returns a new chain, leaving the original one untouched.
stdChain := tcp.NewChain(m1, m2) extChain := stdChain.Append(m3, m4) // requests in stdChain go m1 -> m2 // requests in extChain go m1 -> m2 -> m3 -> m4
func (Chain) Extend ¶
Extend extends a chain by adding the specified chain as the last one in the request flow.
Extend returns a new chain, leaving the original one untouched.
stdChain := tcp.NewChain(m1, m2) ext1Chain := tcp.NewChain(m3, m4) ext2Chain := stdChain.Extend(ext1Chain) // requests in stdChain go m1 -> m2 // requests in ext1Chain go m3 -> m4 // requests in ext2Chain go m1 -> m2 -> m3 -> m4
Another example:
aHtmlAfterNosurf := tcp.NewChain(m2)
aHtml := tcp.NewChain(m1, func(h tcp.Handler) tcp.Handler {
csrf := nosurf.New(h)
csrf.SetFailureHandler(aHtmlAfterNosurf.ThenFunc(csrfFail))
return csrf
}).Extend(aHtmlAfterNosurf)
// requests to aHtml hitting nosurfs success handler go m1 -> nosurf -> m2 -> target-handler
// requests to aHtml hitting nosurfs failure handler go m1 -> nosurf -> m2 -> csrfFail
type ClientConn ¶
type ClientConn interface {
// LocalAddr returns the local network address, if known.
LocalAddr() net.Addr
// RemoteAddr returns the remote network address, if known.
RemoteAddr() net.Addr
}
ClientConn is the interface that provides information about the client connection.
type Constructor ¶
Constructor A constructor for a piece of TCP middleware. Some TCP middleware use this constructor out of the box, so in most cases you can just pass somepackage.New.
type Dialer ¶
type Dialer interface {
Dial(network, addr string, clientConn ClientConn) (c net.Conn, err error)
DialContext(ctx context.Context, network, addr string, clientConn ClientConn) (c net.Conn, err error)
TerminationDelay() time.Duration
}
Dialer is an interface to dial a network connection, with support for PROXY protocol and termination delay.
type DialerManager ¶
type DialerManager struct {
// contains filtered or unexported fields
}
DialerManager handles dialer for the reverse proxy.
func NewDialerManager ¶
func NewDialerManager(spiffeX509Source SpiffeX509Source) *DialerManager
NewDialerManager creates a new DialerManager.
func (*DialerManager) Build ¶
func (d *DialerManager) Build(config *dynamic.TCPServersLoadBalancer, isTLS bool) (Dialer, error)
Build builds a dialer by name.
func (*DialerManager) Update ¶
func (d *DialerManager) Update(configs map[string]*dynamic.TCPServersTransport)
Update updates the TCP serversTransport configurations.
type Handler ¶
type Handler interface {
ServeTCP(conn WriteCloser)
}
Handler is the TCP Handlers interface.
type HandlerFunc ¶
type HandlerFunc func(conn WriteCloser)
The HandlerFunc type is an adapter to allow the use of ordinary functions as handlers.
type HandlerSwitcher ¶
type HandlerSwitcher struct {
// contains filtered or unexported fields
}
HandlerSwitcher is a TCP handler switcher.
func (*HandlerSwitcher) ServeTCP ¶
func (s *HandlerSwitcher) ServeTCP(conn WriteCloser)
ServeTCP forwards the TCP connection to the current active handler.
func (*HandlerSwitcher) Switch ¶
func (s *HandlerSwitcher) Switch(handler Handler)
Switch sets the new TCP handler to use for new connections.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy forwards a TCP request to a TCP service.
func (*Proxy) ServeTCP ¶
func (p *Proxy) ServeTCP(conn WriteCloser)
ServeTCP forwards the connection to a service.
type SpiffeX509Source ¶
type SpiffeX509Source interface {
x509svid.Source
x509bundle.Source
}
SpiffeX509Source allows retrieving a x509 SVID and bundle.
type TLSHandler ¶
TLSHandler handles TLS connections.
func (*TLSHandler) ServeTCP ¶
func (t *TLSHandler) ServeTCP(conn WriteCloser)
ServeTCP terminates the TLS connection.
type WRRLoadBalancer ¶
type WRRLoadBalancer struct {
// contains filtered or unexported fields
}
WRRLoadBalancer is a naive RoundRobin load balancer for TCP services.
func NewWRRLoadBalancer ¶
func NewWRRLoadBalancer(wantsHealthCheck bool) *WRRLoadBalancer
NewWRRLoadBalancer creates a new WRRLoadBalancer.
func (*WRRLoadBalancer) Add ¶
func (b *WRRLoadBalancer) Add(name string, handler Handler, weight *int)
Add appends a server to the existing list with a name and weight.
func (*WRRLoadBalancer) RegisterStatusUpdater ¶
func (b *WRRLoadBalancer) RegisterStatusUpdater(fn func(up bool)) error
func (*WRRLoadBalancer) ServeTCP ¶
func (b *WRRLoadBalancer) ServeTCP(conn WriteCloser)
ServeTCP forwards the connection to the right service.
type WriteCloser ¶
type WriteCloser interface {
net.Conn
// CloseWrite on a network connection, indicates that the issuer of the call
// has terminated sending on that connection.
// It corresponds to sending a FIN packet.
CloseWrite() error
}
WriteCloser describes a net.Conn with a CloseWrite method.