conn

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MESSAGE_SIZE_LIMIT_BYTES = math.MaxInt64 - 1

impose no message size limit

Variables

This section is empty.

Functions

func Middleware

func Middleware() func(http.Handler) http.Handler

func NewCrypt

func NewCrypt(sessionkey []byte, salt []byte) crypt

NewCrypt returns a new crypt object, with a sha256 cryptographic key derived from specified,

sessionkey and the specified salt.

func WithConn

func WithConn(ctx context.Context, conn Conn) context.Context

Types

type Conn

type Conn interface {
	Read(context.Context) ([]byte, error)
	Write(context.Context, []byte) error
}

Conn is an interface that wraps a network connection.

func FromContext

func FromContext(ctx context.Context) (Conn, error)

type Rendezvous

type Rendezvous struct {
	Conn Conn
}

Rendezvous specifies a connection to the rendezvous server.

func (Rendezvous) ReadMsg

func (r Rendezvous) ReadMsg(ctx context.Context, expected ...rendezvous.MsgType) (rendezvous.Msg, error)

ReadMsg reads a rendezvous message from the underlying connection.

func (Rendezvous) ReadRaw added in v1.1.0

func (r Rendezvous) ReadRaw(ctx context.Context) ([]byte, error)

ReadRaw reads raw bytes from the underlying connection.

func (Rendezvous) WriteMsg

func (r Rendezvous) WriteMsg(ctx context.Context, msg rendezvous.Msg) error

WriteMsg writes a rendezvous message to the underlying connection.

func (Rendezvous) WriteRaw added in v1.1.0

func (r Rendezvous) WriteRaw(ctx context.Context, b []byte) error

WriteRaw writes raw bytes to the underlying connection.

type Transfer

type Transfer struct {
	Conn Conn
	// contains filtered or unexported fields
}

Transfer specifies a encrypted connection safe to transfer files over.

func TransferFromKey

func TransferFromKey(conn Conn, key []byte) Transfer

TransferFromKey returns a secure connection using the provided cryptographic key.

func TransferFromSession

func TransferFromSession(conn Conn, sessionkey, salt []byte) Transfer

TransferFromSession returns a secure connection using the provided session key and salt.

func (Transfer) Key

func (tc Transfer) Key() []byte

Key returns the cryptographic key associated with this connection.

func (Transfer) ReadMsg

func (t Transfer) ReadMsg(ctx context.Context, expected ...transfer.MsgType) (transfer.Msg, error)

ReadMsg reads and decrypts the specified transfer message from the underlying connection.

func (Transfer) ReadRaw added in v1.1.0

func (t Transfer) ReadRaw(ctx context.Context) ([]byte, error)

ReadRaw reads and decrypts raw bytes from the underlying connection.

func (Transfer) WriteMsg

func (t Transfer) WriteMsg(ctx context.Context, msg transfer.Msg) error

WriteMsg encrypts and writes the specified transfer message to the underlying connection.

func (Transfer) WriteRaw added in v1.1.0

func (t Transfer) WriteRaw(ctx context.Context, b []byte) error

WriteRaw encrypts and writes the raw bytes to the underlying connection.

type WS

type WS struct {
	Conn *websocket.Conn
}

WS is a wrapper around a websocket connection.

func (*WS) Read

func (ws *WS) Read(ctx context.Context) ([]byte, error)

func (*WS) Write

func (ws *WS) Write(ctx context.Context, payload []byte) error

Jump to

Keyboard shortcuts

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