Documentation
¶
Overview ¶
Package front shares one TCP port between services by the SNI of the first ClientHello. It reads the hello without answering, picks a route by the exact name (the default route for anything it does not know) and hands the connection, with the bytes already read put back in front, to the route's net.Listener. It sends nothing itself and keeps no per-source limits: behind a relay, a bridge or CGNAT many clients share an address.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Front ¶
type Front struct {
// contains filtered or unexported fields
}
Front is the listener of a shared port.
func (*Front) Close ¶
Close stops accepting, closes the connections that have no route yet and ends every route's Accept. Connections already handed over are the engines'.
func (*Front) Listener ¶
Listener returns the listener of route id, nil if there is no such route. Closing it ends one engine's Accept; the route stays, and Listener gives the next engine a new one.
func (*Front) SetDown ¶
SetDown says whether the service of route id is not running (it failed, or never started). Its names then go to the default route at once, as a stranger's do, instead of waiting for an Accept that will not come. A route that is up but does not Accept in time (an engine restarting) sends the connection to the default route too, after routeWait. The default route itself has nowhere to fall back to.
type Route ¶
type Route struct {
ID string // the inbound's id
Names []string // exact SNI names, lower case, no trailing dot, ASCII; a name another route holds already is ignored
// KeepAlive is set on a connection when this route is chosen, so each service keeps the keepalive it has when it
// listens alone. nil leaves what the listener set.
KeepAlive *net.KeepAliveConfig
}
Route is one service on the port.
type Stats ¶
type Stats struct {
Accepted uint64
Delivered map[string]uint64 // by route id: handed to the route's Accept
NoSNI uint64
UnknownName uint64
NotTLS uint64
BadHello uint64
HelloTooLarge uint64
Timeouts uint64 // closed: no complete hello in time
Evicted uint64 // closed: more than maxPending unfinished, this was the oldest
RouteDown uint64 // went to the default route: the route's service is not running (SetDown), or did not Accept in time
Refused uint64 // closed: nobody Accepted it in time (the default route too), or the route went away
NoRoute uint64 // closed: nowhere to send it
Panics uint64
// Unknown is the most frequent names no route holds, most frequent first. A name that came in after the list was
// full takes over the least frequent entry and its count, so counts may be too high after churn.
Unknown []NameCount
}
Stats counts since New. The Default* fields say why a connection went to the default route; they count even when there is none, and then NoRoute counts too.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package fronttest puts a real front on loopback in front of an engine under test: the engine's tests then show what reaches it through the shared port, not what a stand-in would.
|
Package fronttest puts a real front on loopback in front of an engine under test: the engine's tests then show what reaches it through the shared port, not what a stand-in would. |