link

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2014 License: GPL-3.0-or-later Imports: 14 Imported by: 0

Documentation

Overview

Package link contains the encrypted network link implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {
	Send chan *proto.Message
	Recv chan *proto.Message
	// contains filtered or unexported fields
}

Accomplishes secure and authenticated full duplex communication. Note, only the headers are encrypted and decrypted. It is the responsibility of the caller to call proto.Message.Encrypt/Decrypt (link would bottleneck).

func New

func New(conn *stream.Stream, hkdf io.Reader, server bool) *Link

Creates a new, full-duplex encrypted link from the negotiated secret. The client is used to decide the key derivation order for the two half-duplex channels (server keys first, client key second).

func (*Link) Close

func (l *Link) Close() error

Terminates any live data transfer go routines and closes the underlying sock.

func (*Link) RecvDirect

func (l *Link) RecvDirect() (*proto.Message, error)

The actual message receiving logic. Reads a message from the stream, verifies its mac, decodes the headers and send it upwards. Direct receive is public for handshake simplifications, after which the link should switch to channel mode.

func (*Link) SendDirect

func (l *Link) SendDirect(msg *proto.Message) error

The actual message sending logic. Calculates the payload MAC, encrypts the headers and sends it down to the stream. Direct send is public for handshake simplifications. After that is done, the link should switch to channel mode.

func (*Link) Sock

func (l *Link) Sock() *net.TCPConn

Retrieves the raw connection object if special manipulations are needed.

func (*Link) Start

func (l *Link) Start(cap int)

Creates the buffer channels and starts the transfer processes.

Jump to

Keyboard shortcuts

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