internal

import "github.com/go-i2p/go-noise/internal"

internal.svg

Usage

func RandomBytes

func RandomBytes(n int) ([]byte, error)

RandomBytes generates cryptographically secure random bytes

func SecureZero

func SecureZero(b []byte)

SecureZero securely zeroes out the given byte slice

func ValidateKeySize

func ValidateKeySize(key []byte, expectedSize int) bool

ValidateKeySize validates that a key has the expected size

type ConnState

type ConnState int

ConnState represents the internal state of a NoiseConn

const (
	// StateInit represents a newly created connection
	StateInit ConnState = iota
	// StateHandshaking represents a connection performing handshake
	StateHandshaking
	// StateEstablished represents a connection with completed handshake
	StateEstablished
	// StateClosed represents a closed connection
	StateClosed
)

func (ConnState) String

func (s ConnState) String() string

String returns the string representation of the connection state

type ConnectionMetrics

type ConnectionMetrics struct {
	HandshakeStarted time.Time
	HandshakeEnded   time.Time
	BytesRead        int64
	BytesWritten     int64
	Created          time.Time
}

ConnectionMetrics holds connection performance metrics

func NewConnectionMetrics

func NewConnectionMetrics() *ConnectionMetrics

NewConnectionMetrics creates a new ConnectionMetrics instance

func (*ConnectionMetrics) AddBytesRead

func (m *ConnectionMetrics) AddBytesRead(n int64)

AddBytesRead increments the bytes read counter

func (*ConnectionMetrics) AddBytesWritten

func (m *ConnectionMetrics) AddBytesWritten(n int64)

AddBytesWritten increments the bytes written counter

func (*ConnectionMetrics) GetStats

func (m *ConnectionMetrics) GetStats() (bytesRead, bytesWritten int64, duration time.Duration)

GetStats returns current connection statistics

func (*ConnectionMetrics) HandshakeDuration

func (m *ConnectionMetrics) HandshakeDuration() time.Duration

HandshakeDuration returns the duration of the handshake process

func (*ConnectionMetrics) SetHandshakeEnd

func (m *ConnectionMetrics) SetHandshakeEnd()

SetHandshakeEnd records the handshake completion time

func (*ConnectionMetrics) SetHandshakeStart

func (m *ConnectionMetrics) SetHandshakeStart()

SetHandshakeStart records the handshake start time

internal

github.com/go-i2p/go-noise/internal

go-i2p template file