tunnel

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

README

tunnel

a multiplexier

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = &logger{}

Functions

This section is empty.

Types

type Connection

type Connection struct {
	RX <-chan *DataFrame
	TX chan<- *DataFrame
	ID ID
	// contains filtered or unexported fields
}

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) Read

func (c *Connection) Read(p []byte) (int, error)

func (*Connection) SetLogger added in v0.0.3

func (c *Connection) SetLogger(logger Logger)

func (*Connection) Write

func (c *Connection) Write(p []byte) (int, error)

type DataFrame

type DataFrame struct {
	ID      ID
	Type    Type
	Payload []byte
}

func (*DataFrame) Decode

func (d *DataFrame) Decode(r io.Reader) error

func (*DataFrame) Encode

func (d *DataFrame) Encode(w io.Writer) error

func (*DataFrame) Read

func (d *DataFrame) Read(p []byte) (int, error)

func (*DataFrame) Write

func (d *DataFrame) Write(p []byte) (int, error)

type ID

type ID string

func NewID

func NewID() ID

type Logger added in v0.0.3

type Logger interface {
	Trace(args ...interface{})
	Tracef(format string, args ...interface{})

	Debug(args ...interface{})
	Debugf(format string, args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})

	Error(args ...interface{})
	Errorf(format string, args ...interface{})

	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})

	Panic(args ...interface{})
	Panicf(format string, args ...interface{})
}

type Manager

type Manager struct {
	Tunnel      io.ReadWriter
	Connections map[ID]*Connection
	// contains filtered or unexported fields
}

func NewManager

func NewManager(tun io.ReadWriter) *Manager

func (*Manager) Accept

func (m *Manager) Accept() (*Connection, error)

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) Connect

func (m *Manager) Connect() (*Connection, error)

func (*Manager) Run

func (m *Manager) Run()

func (*Manager) SetLogger added in v0.0.3

func (m *Manager) SetLogger(logger Logger)

type Type

type Type uint8
const (
	TypeNormal Type = iota
	TypeRequest
	TypeConnected
	TypeClosed
	TypeInvalid Type = 0xff
)

func (Type) String added in v0.0.2

func (t Type) String() string

type WrongDataFrameTypeError added in v0.0.2

type WrongDataFrameTypeError struct {
	ShouldBe Type
}

func (WrongDataFrameTypeError) Error added in v0.0.2

func (w WrongDataFrameTypeError) Error() string

Jump to

Keyboard shortcuts

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