core

package
v0.0.0-...-8e6527b Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPacketSize = 0x3FFF // 16k - 1

MaxPacketSize is ... the maximum size of payload

Variables

View Source
var ErrShortPacket = errors.New("short packet")

ErrShortPacket is ...

View Source
var Pool = sync.Pool{
	New: func() interface{} {
		b := make([]byte, MaxPacketSize)

		return &b
	},
}

Pool is ...

Functions

func Get

func Get() (lazySlice, []byte)

Get is ...

func NewConn

func NewConn(conn net.Conn, cipher *Cipher) net.Conn

NewConn is ...

func NewPacketConn

func NewPacketConn(pc net.PacketConn, cipher *Cipher) net.PacketConn

NewPacketConn is ...

func Pack

func Pack(dst, pkt []byte, cipher *Cipher) ([]byte, error)

Pack is ...

func Put

func Put(s lazySlice)

Put is ...

func Unpack

func Unpack(dst, pkt []byte, cipher *Cipher) ([]byte, error)

Unpack is ...

Types

type Cipher

type Cipher struct {
	// KeySize is ...
	KeySize int
	// SaltSize is ...
	SaltSize int
	// NewAEAD is ...
	NewAEAD func([]byte) (cipher.AEAD, error)
}

Cipher is ...

func NewCipher

func NewCipher(method, password string) (*Cipher, error)

NewCipher is ...

func NewCipherFromKey

func NewCipherFromKey(method, password string, key []byte) (*Cipher, error)

NewCipherFromKey is ...

type CloseReader

type CloseReader interface {
	CloseRead() error
}

CloseReader is ...

type CloseWriter

type CloseWriter interface {
	CloseWrite() error
}

CloseWriter is ...

type Conn

type Conn struct {

	// Reader is ...
	Reader
	// Writer is ...
	Writer
	// contains filtered or unexported fields
}

Conn is ...

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

type Key

type Key []byte

Key is ...

func (Key) AES256GCM

func (k Key) AES256GCM(salt []byte) (cipher.AEAD, error)

AES256GCM is ... generate AES-256-GCM cipher

func (Key) Chacha20Poly1305

func (k Key) Chacha20Poly1305(salt []byte) (cipher.AEAD, error)

Chacha20Poly1305 is ... generate Chacha20-IETF-Poly1305 cipher

type PacketConn

type PacketConn struct {
	net.PacketConn
	Cipher *Cipher
}

PacketConn is ...

func (*PacketConn) ReadFrom

func (pc *PacketConn) ReadFrom(b []byte) (int, net.Addr, error)

ReadFrom is ...

func (*PacketConn) WriteTo

func (pc *PacketConn) WriteTo(b []byte, addr net.Addr) (int, error)

WriteTo is ...

type Reader

type Reader struct {
	// Reader is ...
	Reader io.ReadCloser
	// Cipher is ...
	Cipher *Cipher
	// AEAD is ...
	AEAD cipher.AEAD
	// contains filtered or unexported fields
}

Reader is ...

func NewReader

func NewReader(r io.ReadCloser, cipher *Cipher) *Reader

NewReader is ...

func (*Reader) Close

func (r *Reader) Close() error

Close is ...

func (*Reader) CloseRead

func (r *Reader) CloseRead() error

CloseRead is ...

func (*Reader) Read

func (r *Reader) Read(b []byte) (int, error)

Read is ...

func (*Reader) WriteTo

func (r *Reader) WriteTo(w io.Writer) (n int64, err error)

WriteTo is ...

type Writer

type Writer struct {
	// Writer is ...
	Writer io.WriteCloser
	// Cipehr is ...
	Cipher *Cipher
	// AEAD is ...
	AEAD cipher.AEAD
	// contains filtered or unexported fields
}

Writer is ...

func NewWriter

func NewWriter(w io.WriteCloser, cipher *Cipher) *Writer

NewWriter is ...

func (*Writer) Close

func (w *Writer) Close() error

Close is ...

func (*Writer) CloseWrite

func (w *Writer) CloseWrite() error

CloseWrite is ...

func (*Writer) ReadFrom

func (w *Writer) ReadFrom(r io.Reader) (int64, error)

ReadFrom is ...

func (*Writer) Write

func (w *Writer) Write(b []byte) (int, error)

Write is ...

Jump to

Keyboard shortcuts

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