tun

package
v0.0.0-...-9fce2f1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSessExists   = errors.New("session already exists")
	ErrSessNotFound = errors.New("session not found")
	ErrMessageType  = errors.New("message type is not binary")
	ErrConnNotFound = errors.New("connection not found")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	Listen(context.Context) (net.Listener, error)
}

func Dial

func Dial(addr string) (Client, error)

func DialContext

func DialContext(ctx context.Context, addr string) (Client, error)

type Codec

type Codec interface {
	Encode(w io.Writer, m *Message) (int, error)
	Decode(r io.Reader) (*Message, error)
}

type Dialer

type Dialer func(context.Context, string) (net.Conn, error)

type Message

type Message struct {
	Type    MessageType
	ConnID  uint32
	Addr    string
	Payload []byte
}

func (*Message) ReadFrom

func (m *Message) ReadFrom(r io.Reader) (int64, error)

func (*Message) WriteTo

func (m *Message) WriteTo(w io.Writer) (int64, error)

type MessageType

type MessageType int16
const (
	Connect MessageType = iota
	Data
)

type Server

type Server interface {
	http.Handler
	Dialer(string) (Dialer, error)
}

func NewServer

func NewServer(opts ...ServerOption) Server

type ServerOption

type ServerOption func(*ServerOptions)

func Authorizer

func Authorizer(a func(*http.Request) (string, error)) ServerOption

type ServerOptions

type ServerOptions struct {
	Authorize func(*http.Request) (string, error)
}

Jump to

Keyboard shortcuts

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