encryptconn

package
v3.0.0-rc49 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package encryptconn provides encrypted/decrypted net.Conn

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnNoder

type ConnNoder interface {
	net.Conn
	ReadWithNode(b []byte) (n int, nodename string, err error)
	MessageWithNode() (b []byte, nodename string, err error)
	Frame() (b []byte, err error)
	DecryptFrame(frame []byte) (b []byte, nodename string, err error)
}

type T

type T struct {
	net.Conn
	// contains filtered or unexported fields
}

T struct provides net.Conn over enc net.Conn

func New

func New(encConn net.Conn, ed encryptDecrypter) *T

New returns a new *T that will use encrypted net.Conn

The scanner buffer is owned by the returned *T for its whole lifetime: it is not pooled, so that a Close() concurrent with a reader can't hand the buffer to another connection while the scanner still points into it. It starts at the usual message size and is grown by the scanner, up to the max message size, when a bigger message is read.

func (*T) DecryptFrame

func (t *T) DecryptFrame(frame []byte) (b []byte, nodename string, err error)

DecryptFrame implement ConnNoder interface for T

decrypt a frame Frame returned, and return it with the nodename of its encrypter.

func (*T) Frame

func (t *T) Frame() (b []byte, err error)

Frame implement ConnNoder interface for T

read the next message from t.Conn, still encrypted. Callers wanting to decide on the frame before paying its decryption, like the heartbeat receivers dropping the frames another link already delivered, read it and hand it back to DecryptFrame.

func (*T) MessageWithNode

func (t *T) MessageWithNode() (b []byte, nodename string, err error)

MessageWithNode implement ConnNoder interface for T

read and decrypt the next message from t.Conn, and return it with the nodename of its encrypter. The returned slice is sized for the message and belongs to the caller: a connection reading nothing retains nothing.

func (*T) Read

func (t *T) Read(b []byte) (n int, err error)

Read implement Reader interface for T

read and decrypt data read from t.Conn

func (*T) ReadWithNode

func (t *T) ReadWithNode(b []byte) (n int, nodename string, err error)

ReadWithNode implement ConnNoder interface for T

read and decrypt data read from t.Conn

Prefer MessageWithNode when the message size is not known in advance: b has to be as large as the largest message to expect, where the slice MessageWithNode returns is as large as the message actually read.

func (*T) SrcNode

func (t *T) SrcNode() string

SrcNode returns the encrypter nodename

func (*T) Write

func (t *T) Write(b []byte) (n int, err error)

Write implement Writer interface for T

Write encrypted d to T.Conn

Jump to

Keyboard shortcuts

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