Documentation
¶
Overview ¶
Package l4 implements the L4 server: every client conn becomes a flow to an endpoint of the server's clusters. Flows are client-initiated only.
Index ¶
- Variables
- type EventHandler
- type Flow
- type FlowEvent
- type Server
- func (s *Server) Close(_ bool) error
- func (s *Server) GetConfig() stnrv2.Config
- func (s *Server) Reconcile(conf stnrv2.Config) error
- func (s *Server) Serve(c api.Conn) (api.Conn, api.Verdict, error)
- func (s *Server) Sessions() int
- func (s *Server) Start() error
- func (s *Server) Status() stnrv2.Status
Constants ¶
This section is empty.
Variables ¶
var FlowTimeout = 5 * time.Minute
FlowTimeout is the idle timeout of a flow.
Functions ¶
This section is empty.
Types ¶
type EventHandler ¶
type EventHandler struct {
// OnFlowCreated is called after a flow has been admitted, wired, and registered.
OnFlowCreated func(ev FlowEvent)
// OnFlowDeleted is called when a flow is being torn down, before its legs close.
OnFlowDeleted func(ev FlowEvent)
// OnFlowError is called when a pump exits on a write error.
OnFlowError func(srcAddr net.Addr, protocol stnrv2.Protocol, message string)
}
EventHandler is the set of callbacks the L4 server calls on flow lifecycle events, the L4 analog of the TURN server's allocation event handlers. A flow collapses the TURN allocation/permission/channel lifecycle into a single event pair: flow setup is the allocation, the endpoint choice is the permission, and the fixed client-to-peer binding is the channel.
func NewEventHandler ¶
func NewEventHandler(rt *objruntime.Runtime, log logging.LeveledLogger, q *turnsrv.Quota) EventHandler
NewEventHandler returns the default flow event wiring: logging and quota accounting through the shared Quota machinery of the TURN server.
type FlowEvent ¶
type FlowEvent struct {
// SrcAddr and DstAddr are the client's source address and the listener-side address
// serving it.
SrcAddr, DstAddr net.Addr
// Protocol is the client-side transport, the listener protocol.
Protocol stnrv2.Protocol
// Peer is the endpoint the flow was forwarded to and PeerProtocol the protocol of the leg
// towards it, its tag's.
Peer net.Addr
PeerProtocol stnrv2.Protocol
// Cluster is the cluster the flow was forwarded through.
Cluster string
// Username and Realm are the flow's quota identity, as minted by the quota gate.
Username, Realm string
}
FlowEvent carries the context of a flow lifecycle event. It is pure data (addresses, names): safe to serialize or ship across a process boundary.
type Server ¶
Server is an L4 server object.
func New ¶
func New(conf *stnrv2.ServerConfig, rt *objruntime.Runtime) (*Server, error)
New creates the L4 server of a validated config.