server

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIP

func ClientIP(r *http.Request, trustProxy bool) string

func NewLogger

func NewLogger() *slog.Logger

Types

type Config

type Config struct {
	PublicTunnelDomain              string
	TunnelEndpointHost              string
	ServerPort                      string
	MaxBodyBytes                    int64
	RequestTimeoutSeconds           int
	MaxConcurrentRequestsPerTunnel  int
	MaxTunnelsPerIP                 int
	MaxRegistrationsPerIPPerMinute  int
	MaxPublicRequestsPerIPPerMinute int
	SubdomainHoldSeconds            int
	PublicURLScheme                 string
	TrustProxyHeaders               bool
	BlockedIPs                      map[string]struct{}
}

func LoadConfig

func LoadConfig() Config

func (Config) PublicURL

func (c Config) PublicURL(subdomain string) string

type Limits

type Limits struct {
	// contains filtered or unexported fields
}

func NewLimits

func NewLimits(cfg Config) *Limits

func (*Limits) AllowPublicRequest

func (l *Limits) AllowPublicRequest(ip string) bool

func (*Limits) AllowRegistrationRate

func (l *Limits) AllowRegistrationRate(ip string) bool

func (*Limits) IsIPBlocked

func (l *Limits) IsIPBlocked(ip string) bool

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry(holdSeconds int) *Registry

func (*Registry) AssignSubdomain

func (r *Registry) AssignSubdomain(requested, clientIP string) (string, error)

func (*Registry) CleanupExpiredHolds

func (r *Registry) CleanupExpiredHolds()

func (*Registry) GetBySubdomain

func (r *Registry) GetBySubdomain(subdomain string) (*Tunnel, bool)

func (*Registry) IsAvailable

func (r *Registry) IsAvailable(subdomain string) bool

func (*Registry) IsAvailableFor

func (r *Registry) IsAvailableFor(subdomain, clientIP string) bool

func (*Registry) Register

func (r *Registry) Register(t *Tunnel) error

func (*Registry) RegisterWithIPLimit

func (r *Registry) RegisterWithIPLimit(t *Tunnel, maxPerIP int) error

func (*Registry) Unregister

func (r *Registry) Unregister(subdomain string)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config, log *slog.Logger) *Server

func (*Server) Handler

func (s *Server) Handler() http.Handler

type Tunnel

type Tunnel struct {
	ID        string
	Subdomain string
	Conn      *websocket.Conn
	ClientIP  string
	CreatedAt time.Time
	Pending   map[string]chan tunnelResponse
	// contains filtered or unexported fields
}

func (*Tunnel) WriteMessage

func (t *Tunnel) WriteMessage(v any) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL