protocol

package
v0.0.0-...-c7b9b92 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: GPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTURNRejected = errors.New("turn server rejected request")

ErrTURNRejected indicates a TURN server rejected a request, so its credentials must be replaced

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

func WithMasking

func WithMasking(ctx context.Context) context.Context

WithMasking asks Connect to negotiate masking instead of record encryption; only for payloads already encrypted and authenticated

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 TURNInfo, 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(listenAddr string) 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(listenAddr string) 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 TURNInfo, 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 MaskState

type MaskState interface {
	Masked() bool
}

MaskState reports whether a conn negotiated masking; implemented by protocol conns

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 TURNInfo, 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(_ string) error

Start starts the server listener

func (*NoneHandler) Stop

func (N *NoneHandler) Stop() error

Stop stops the server listener

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 TURNInfo, 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(listenAddr string) 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

type TURNInfo

type TURNInfo struct {
	Address  string // TURN server address
	Username string // TURN username
	Password string // TURN password
}

TURNInfo describes the TURN server used to establish the packet underlay

Jump to

Keyboard shortcuts

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