udp

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTunnelNotReady = errors.New("tunnel is not yet established")

ErrTunnelNotReady is returned when an application tries to send data through a session that does not have an established tunnel connection yet.

View Source
var ErrUnauthorizedKey = errors.New("unauthorized key")

ErrUnauthorizedKey is returned when a key is not authorized.

View Source
var ErrUnauthorizedPort = errors.New("unauthorized port")

ErrUnauthorizedPort is returned when a key is not allowed to bind to a requested port.

Functions

This section is empty.

Types

type Binder

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

Binder implements service.Binder for UDP tunneling service.

func (Binder) Start

func (binder Binder) Start(ws *websocket.Conn, store *service.SessionStore) error

Start binds to a UDP port and routes incoming packets to udp.Session objects.

type Service

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

Service implements service.Service for UDP tunneling service.

func NewService

func NewService(conf config.Server) Service

NewService creates a udp.Service with given server configuration.

func (Service) GetBinder

func (serv Service) GetBinder(key string, port int) (service.Binder, error)

GetBinder returns a udp.Binder for an agent with given authorization key and given UDP port.

type Session

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

Session implements service.Session for UDP tunneling.

func NewSession

func NewSession(conn *net.UDPConn, peer *net.UDPAddr) *Session

NewSession creates a Session for tunneling UDP packets from/to given peer.

func (Session) Close

func (sess Session) Close() error

Close does nothing because UDP has no real connection.

func (*Session) PeerAddr

func (sess *Session) PeerAddr() net.Addr

PeerAddr returns the address of the connected client.

func (*Session) SendToAgent

func (sess *Session) SendToAgent(msg []byte) error

SendToAgent sends msg to the other end of the tunnel if tunnel is ready. Calling this function resets internal idle counter.

func (*Session) SendToClient

func (sess *Session) SendToClient(msg []byte) error

SendToClient sends msg to UDP client. Calling this function resets internal idle counter.

func (*Session) Start

func (sess *Session) Start(ws *websocket.Conn) error

Start starts downlink tunneling. Uplink needs to be handled in the listener loop due to the connection-less nature of UDP.

Jump to

Keyboard shortcuts

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