udptunnel

package module
v0.0.0-...-8400403 Latest Latest
Warning

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

Go to latest
Published: May 1, 2018 License: MIT Imports: 13 Imported by: 0

README

udptunnel

golang implement udp tunnel

Documentation

Index

Constants

View Source
const (
	KeepAlive = "/udptnnel/keepalive/0.0.1"
)

Builtin method

Variables

View Source
var (
	ErrPeerTimeout   = errors.New("Peer keep-alive timeout")
	ErrListen        = errors.New("Tunnel already listen or connect")
	ErrMessageLength = errors.New("message length error")
)

udp tunnel defined errors

View Source
var (
	KeepAliveID = IDFromString(KeepAlive)
)

id

Functions

func IDFromString

func IDFromString(id string) (result [4]byte)

IDFromString .

Types

type Client

type Client interface {
	Close()
	Connect(raddr string) (Tunnel, error)
}

Client tunnel client endpoint

func NewClient

func NewClient(ctx context.Context, conf *config.Config) (Client, error)

NewClient .

type Message

type Message struct {
	ID   [4]byte
	Body []byte
}

Message .

func (*Message) IDFromString

func (message *Message) IDFromString(id string)

IDFromString .

func (*Message) Marshal

func (message *Message) Marshal(writer io.Writer) error

Marshal .

func (*Message) Unmarshal

func (message *Message) Unmarshal(reader io.Reader) error

Unmarshal .

type Server

type Server interface {
	Close()
	Accept() <-chan Tunnel
}

Server Tunnel server endpoint

func ListenAndServe

func ListenAndServe(ctx context.Context, conf *config.Config) (Server, error)

ListenAndServe create new server

type Tunnel

type Tunnel interface {
	Remote() *net.UDPAddr
	Context() context.Context
	Send(message *Message) error
	Recv() <-chan *Message
}

Tunnel udp tunnel interface

Jump to

Keyboard shortcuts

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