boxstream

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package boxstream implements npm:pull-box-stream in Go (without the pull)

https://github.com/dominictarr/pull-box-stream

Index

Constants

View Source
const (
	// HeaderLength defines the length of the header packet before the body
	HeaderLength = 2 + 16 + 16

	// MaxSegmentSize is the maximum body size for boxstream packets
	MaxSegmentSize = 4 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Boxer

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

Boxer encrypts everything that is written to it

func NewBoxer

func NewBoxer(w io.Writer, nonce *[24]byte, secret *[32]byte) *Boxer

NewBoxer returns a Boxer that writes encrypted messages to w.

func (*Boxer) WriteGoodbye added in v1.2.1

func (b *Boxer) WriteGoodbye() error

WriteGoodbye writes the 'goodbye' protocol message to the underlying writer.

func (*Boxer) WriteMessage added in v1.2.1

func (b *Boxer) WriteMessage(msg []byte) error

WriteMessage writes a boxstream packet to the underlying writer. len(msg) must not exceed MaxSegmentSize.

type Unboxer

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

Unboxer decrypts everything that is read from it

func NewUnboxer

func NewUnboxer(r io.Reader, nonce *[24]byte, secret *[32]byte) *Unboxer

NewUnboxer wraps the passed Reader into an Unboxer.

func (*Unboxer) ReadMessage added in v1.2.1

func (u *Unboxer) ReadMessage() ([]byte, error)

ReadMessage reads the next message from the underlying stream. If the next message was a 'goodbye', it returns io.EOF.

Jump to

Keyboard shortcuts

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