server

package
v0.0.0-...-0cae4bf Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: GPL-3.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	Authenticate(addr net.Addr, auth string, tx uint64) (ok bool, id string)
}

Authenticator is an interface that provides authentication logic.

type BandwidthConfig

type BandwidthConfig struct {
	MaxTx uint64
	MaxRx uint64
}

BandwidthConfig describes the maximum bandwidth that the server can use, in bytes per second.

type Config

type Config struct {
	TLSConfig             TLSConfig
	QUICConfig            QUICConfig
	Conn                  net.PacketConn
	Outbound              Outbound
	BandwidthConfig       BandwidthConfig
	IgnoreClientBandwidth bool
	DisableUDP            bool
	UDPIdleTimeout        time.Duration
	Authenticator         Authenticator
	EventLogger           EventLogger
	TrafficLogger         TrafficLogger
	MasqHandler           http.Handler
}

type EventLogger

type EventLogger interface {
	Connect(addr net.Addr, id string, tx uint64)
	Disconnect(addr net.Addr, id string, err error)
	TCPRequest(addr net.Addr, id, reqAddr string)
	TCPError(addr net.Addr, id, reqAddr string, err error)
	UDPRequest(addr net.Addr, id string, sessionID uint32, reqAddr string)
	UDPError(addr net.Addr, id string, sessionID uint32, err error)
}

EventLogger is an interface that provides logging logic.

type Outbound

type Outbound interface {
	TCP(reqAddr string) (net.Conn, error)
	UDP(reqAddr string) (UDPConn, error)
}

Outbound provides the implementation of how the server should connect to remote servers. Although UDP includes a reqAddr, the implementation does not necessarily have to use it to make a "connected" UDP connection that does not accept packets from other addresses. In fact, the default implementation simply uses net.ListenUDP for a "full-cone" behavior.

type QUICConfig

type QUICConfig struct {
	InitialStreamReceiveWindow     uint64
	MaxStreamReceiveWindow         uint64
	InitialConnectionReceiveWindow uint64
	MaxConnectionReceiveWindow     uint64
	MaxIdleTimeout                 time.Duration
	MaxIncomingStreams             int64
	DisablePathMTUDiscovery        bool // The server may still override this to true on unsupported platforms.
}

QUICConfig contains the QUIC configuration fields that we want to expose to the user.

type Server

type Server interface {
	Serve() error
	Close() error
}

func NewServer

func NewServer(config *Config) (Server, error)

type TLSConfig

type TLSConfig struct {
	Certificates   []tls.Certificate
	GetCertificate func(info *tls.ClientHelloInfo) (*tls.Certificate, error)
}

TLSConfig contains the TLS configuration fields that we want to expose to the user.

type TrafficLogger

type TrafficLogger interface {
	Log(id string, tx, rx uint64) (ok bool)
}

TrafficLogger is an interface that provides traffic logging logic. Tx/Rx in this context refers to the server-remote (proxy target) perspective. Tx is the bytes sent from the server to the remote. Rx is the bytes received by the server from the remote. Apart from logging, the Log function can also return false to signal that the client should be disconnected. This can be used to implement bandwidth limits or post-connection authentication, for example. The implementation of this interface must be thread-safe.

type UDPConn

type UDPConn interface {
	ReadFrom(b []byte) (int, string, error)
	WriteTo(b []byte, addr string) (int, error)
	Close() error
}

UDPConn is like net.PacketConn, but uses string for addresses.

Jump to

Keyboard shortcuts

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