protocol

package
v0.0.0-...-e5939fb Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: GPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQuotaReached = errors.New("turn allocation quota reached")

ErrQuotaReached indicates a TURN allocation quota has been exhausted

Handlers represents protocol Handler registry.

Functions

func HandlerExists

func HandlerExists(name string) bool

HandlerExists checks whether a protocol Handler with specified string ID exists.

func ListHandlers

func ListHandlers() []string

ListHandlers lists all protocol Handler string IDs.

Types

type DTLSHandler

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

DTLSHandler represents a DTLS session handler

func (*DTLSHandler) AcceptClients

func (D *DTLSHandler) AcceptClients(ctx context.Context) (<-chan ServerClient, error)

AcceptClients accepts new server clients

func (*DTLSHandler) Connect

func (D *DTLSHandler) Connect(ctx context.Context, dest net.Addr, relay RelayInfo, forceTURN bool) (net.Conn, error)

Connect connects to a remote server directly or via TURN

func (*DTLSHandler) ID

func (D *DTLSHandler) ID() string

ID returns the unique ID of this handler

func (*DTLSHandler) SetLogger

func (D *DTLSHandler) SetLogger(log *slog.Logger)

SetLogger changes the slog logger instance

func (*DTLSHandler) Start

func (D *DTLSHandler) Start(config config.ServerConfig) error

Start starts the server listener

func (*DTLSHandler) Stop

func (D *DTLSHandler) Stop() error

Stop stops the server listener

type Handler

type Handler interface {
	ID() string                                                                                   // Returns the unique ID of this handler
	Start(config config.ServerConfig) error                                                       // Starts the server listener
	Stop() error                                                                                  // Stops the server listener
	AcceptClients(ctx context.Context) (<-chan ServerClient, error)                               // Accepts new server clients
	Connect(ctx context.Context, dest net.Addr, turn RelayInfo, forceTURN bool) (net.Conn, error) // Connects to a remote server directly or via TURN
	SetLogger(log *slog.Logger)                                                                   // Changes the slog logger instance
}

Handler represents a protocol handler

func GetHandler

func GetHandler(name string) (Handler, error)

GetHandler fetches a protocol Handler by its string ID.

type NoneHandler

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

NoneHandler passes traffic as raw UDP without any encryption or framing

func (*NoneHandler) AcceptClients

func (N *NoneHandler) AcceptClients(_ context.Context) (<-chan ServerClient, error)

AcceptClients accepts new server clients

func (*NoneHandler) Connect

func (N *NoneHandler) Connect(ctx context.Context, dest net.Addr, relay RelayInfo, forceTURN bool) (net.Conn, error)

Connect connects to a remote server directly or via TURN

func (*NoneHandler) ID

func (N *NoneHandler) ID() string

ID returns the unique ID of this handler

func (*NoneHandler) SetLogger

func (N *NoneHandler) SetLogger(log *slog.Logger)

SetLogger changes the slog logger instance

func (*NoneHandler) Start

func (N *NoneHandler) Start(_ config.ServerConfig) error

Start starts the server listener

func (*NoneHandler) Stop

func (N *NoneHandler) Stop() error

Stop stops the server listener

type RelayInfo

type RelayInfo struct {
	Address   string   // TURN server address
	Addresses []string // All available TURN server addresses
	Username  string   // TURN username
	Password  string   // TURN password
}

RelayInfo describes the TURN server used to establish the packet underlay

type SRTPHandler

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

SRTPHandler disguises VPN traffic as WebRTC SRTP

func (*SRTPHandler) AcceptClients

func (S *SRTPHandler) AcceptClients(ctx context.Context) (<-chan ServerClient, error)

AcceptClients accepts new server clients

func (*SRTPHandler) Connect

func (S *SRTPHandler) Connect(ctx context.Context, dest net.Addr, relay RelayInfo, forceTURN bool) (net.Conn, error)

Connect connects to a remote server directly or via TURN

func (*SRTPHandler) ID

func (S *SRTPHandler) ID() string

ID returns the unique ID of this handler

func (*SRTPHandler) SetLogger

func (S *SRTPHandler) SetLogger(log *slog.Logger)

SetLogger changes the slog logger instance

func (*SRTPHandler) Start

func (S *SRTPHandler) Start(cfg config.ServerConfig) error

Start starts the server listener

func (*SRTPHandler) Stop

func (S *SRTPHandler) Stop() error

Stop stops the server listener

type ServerClient

type ServerClient struct {
	Address net.Addr // Client address
	Conn    net.Conn // Client connection
}

ServerClient represents an accepted client session

Jump to

Keyboard shortcuts

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