Documentation
¶
Index ¶
- func ClearVirtualHost(name string) string
- func FindRoute(pattern string, routes ...config.Route) (host string, route *config.Route)
- func FindRouteWithGroups(pattern string, routes ...config.Route) (host string, route *config.Route, groups []string)
- func Forward(dialTimeout time.Duration, routes []config.Route, log logr.Logger, ...)
- func IsConnectionRefused(err error) bool
- func IsTCPShieldRealIP(addr string) bool
- func ResetPingCache()
- func ResolveStatusResponse(dialTimeout time.Duration, routes []config.Route, log logr.Logger, ...) (logr.Logger, *packet.StatusResponse, error)
- func TCPShieldRealIP(addr string, clientAddr net.Addr) string
- type Lite
- type StrategyManager
- func (sm *StrategyManager) GetNextBackend(log logr.Logger, route *config.Route, routeHost string, backends []string) (string, logr.Logger, bool)
- func (sm *StrategyManager) GetOrCreateCounter(backend string) *atomic.Uint32
- func (sm *StrategyManager) IncrementConnection(backend string) func()
- func (sm *StrategyManager) RecordLatency(backend string, latency time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearVirtualHost ¶
ClearVirtualHost cleans the given virtual host.
func FindRoute ¶
FindRoute returns the first route that matches the given wildcard supporting pattern.
func FindRouteWithGroups ¶ added in v0.59.0
func FindRouteWithGroups(pattern string, routes ...config.Route) (host string, route *config.Route, groups []string)
FindRouteWithGroups returns the first route that matches the given wildcard supporting pattern, along with the captured groups from wildcards.
func Forward ¶ added in v0.26.0
func Forward( dialTimeout time.Duration, routes []config.Route, log logr.Logger, client netmc.MinecraftConn, handshake *packet.Handshake, pc *proto.PacketContext, strategyManager *StrategyManager, )
Forward forwards a client connection to a matching backend route.
func IsConnectionRefused ¶ added in v0.56.0
IsConnectionRefused returns true if err indicates a connection refused error. These errors are common when backends are down and should use debug logging.
func IsTCPShieldRealIP ¶ added in v0.36.2
IsTCPShieldRealIP returns true if the given virtual host uses TCPShieldRealIP protocol.
func ResolveStatusResponse ¶ added in v0.26.0
func ResolveStatusResponse( dialTimeout time.Duration, routes []config.Route, log logr.Logger, client netmc.MinecraftConn, handshake *packet.Handshake, handshakeCtx *proto.PacketContext, statusRequestCtx *proto.PacketContext, strategyManager *StrategyManager, ) (logr.Logger, *packet.StatusResponse, error)
ResolveStatusResponse resolves the status response for the matching route and caches it for a short time.
Types ¶
type Lite ¶ added in v0.55.0
type Lite struct {
// contains filtered or unexported fields
}
Lite encapsulates all lite mode functionality for a Gate proxy instance. This provides a clean abstraction for lite mode features and avoids global state.
func NewLite ¶ added in v0.55.0
func NewLite() *Lite
NewLite creates a new Lite instance for a Gate proxy.
func (*Lite) StrategyManager ¶ added in v0.55.0
func (l *Lite) StrategyManager() *StrategyManager
StrategyManager returns the strategy manager for load balancing.
type StrategyManager ¶ added in v0.55.0
type StrategyManager struct {
// contains filtered or unexported fields
}
StrategyManager manages state for load balancing strategies across a single Gate instance. This eliminates global state and allows multiple Gate instances in the same process.
func NewStrategyManager ¶ added in v0.55.0
func NewStrategyManager() *StrategyManager
NewStrategyManager creates a new strategy manager for a Gate instance.
func (*StrategyManager) GetNextBackend ¶ added in v0.55.0
func (sm *StrategyManager) GetNextBackend(log logr.Logger, route *config.Route, routeHost string, backends []string) (string, logr.Logger, bool)
GetNextBackend returns the next backend using the specified strategy.
func (*StrategyManager) GetOrCreateCounter ¶ added in v0.55.0
func (sm *StrategyManager) GetOrCreateCounter(backend string) *atomic.Uint32
GetOrCreateCounter returns the connection counter for a backend (exposed for testing).
func (*StrategyManager) IncrementConnection ¶ added in v0.55.0
func (sm *StrategyManager) IncrementConnection(backend string) func()
IncrementConnection increments the connection counter for a backend (used with least-connections).
func (*StrategyManager) RecordLatency ¶ added in v0.55.0
func (sm *StrategyManager) RecordLatency(backend string, latency time.Duration)
RecordLatency records the latency for a backend (used with lowest-latency).