tcpsession

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPayloadSize is the maximum size of a single TCP payload
	// before encryption. It may include a padding inside.
	MaxPayloadSize = 1024 * 16

	// PayloadOverhead is the overhead of decrypted payload.
	// This overhead contains 2 bytes of useful payload length and 2 bytes of
	// useful + padding payload length.
	PayloadOverhead = 4
)

Variables

View Source
var (
	// Number of TCP receive errors.
	TCPReceiveErrors = metrics.RegisterMetric("errors", "TCPReceiveErrors")

	// Number of TCP send errors.
	TCPSendErrors = metrics.RegisterMetric("errors", "TCPSendErrors")
)

Functions

func DialWithOptionsReturnConn

func DialWithOptionsReturnConn(ctx context.Context, network, laddr, raddr string, block cipher.BlockCipher) (net.Conn, error)

DialWithOptionsReturnConn calls DialWithOptions and returns a generic net.Conn.

Types

type TCPSession

type TCPSession struct {
	net.Conn // the network connection associated to the TCPSession
	// contains filtered or unexported fields
}

TCPSession defines a TCP session.

func DialWithOptions

func DialWithOptions(ctx context.Context, network, laddr, raddr string, block cipher.BlockCipher) (*TCPSession, error)

DialWithOptions connects to the remote address "raddr" on the network "tcp" with packet encryption. If "laddr" is empty, an automatic address is used. "block" is the block encryption algorithm to encrypt packets.

func (*TCPSession) Close

func (s *TCPSession) Close() error

Close overrides the Close() method in the net.Conn interface.

func (*TCPSession) Read

func (s *TCPSession) Read(b []byte) (n int, err error)

Read overrides the Read() method in the net.Conn interface.

func (*TCPSession) Write

func (s *TCPSession) Write(b []byte) (n int, err error)

Write overrides the Write() method in the net.Conn interface.

type TCPSessionListener

type TCPSessionListener struct {
	net.Listener
	// contains filtered or unexported fields
}

func ListenWithOptions

func ListenWithOptions(laddr string, users map[string]*appctlpb.User) (*TCPSessionListener, error)

ListenWithOptions creates a new TCPSession listener.

func (*TCPSessionListener) Accept

func (l *TCPSessionListener) Accept() (net.Conn, error)

Accept implements the Accept() method in the net.Listener interface.

func (*TCPSessionListener) Addr

func (l *TCPSessionListener) Addr() net.Addr

Addr returns the listener's network address.

func (*TCPSessionListener) Close

func (l *TCPSessionListener) Close() error

Close closes the session manager.

func (*TCPSessionListener) Start

func (l *TCPSessionListener) Start()

Start starts to accept incoming TCP connections.

func (*TCPSessionListener) WrapConn

func (l *TCPSessionListener) WrapConn(conn net.Conn) net.Conn

WrapConn adds TCPSession into a raw network connection.

Jump to

Keyboard shortcuts

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