Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SplitListener ¶
type SplitListener struct {
// contains filtered or unexported fields
}
SplitListener takes in a base listener and sends incoming connections to one of two listeners: one that is used if the TLS connection negotiated to one of this package's standard ALPN proto values and one if not.
It is required that the base listener return *tls.Conn values on Accept.
This package can be useful for integration with systems that expect to do their own handling of connections off of a net.Listener. One such example is gRPC which expects to be handed a listener and has deprecated any ability to simply hand it a connection. The NodeEnrollmentListener can be given to the gRPC server and the OtherListener can be used for other purposes.
On receiving an error from the underlying Accept from the base listener that is not a Temporary error, the listener will stop listening.
func NewSplitListener ¶
func NewSplitListener(baseLn net.Listener) *SplitListener
NewSplitListener creates a new listener from a base. The base listener must return *tls.Conn connections (or a net.Conn that is type-assertable to *tls.Conn).
func (*SplitListener) NodeEnrollmentListener ¶
func (l *SplitListener) NodeEnrollmentListener() net.Listener
NodeEnrollmentListener returns the listener receiving connections related to this library
func (*SplitListener) OtherListener ¶
func (l *SplitListener) OtherListener() net.Listener
OtherListener returns the listener receving all other connections
func (*SplitListener) Start ¶
func (l *SplitListener) Start() error
Start starts the listener running. It will run until Stop is called, causing the base listener to Close and the Accept to return a non-temporary error.
Any temporary errors encountered will just cause that connection to be closed.
func (*SplitListener) Stop ¶
func (l *SplitListener) Stop() error
Stop stops the listener. If this is the first time it's called it will close the underlying listener (causing the Start function to exit) and return that error. On any future call it is a noop.