networkio

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package networkio implements raw packets network I/O.

Index

Constants

This section is empty.

Variables

View Source
var ErrPacketTooLarge = errors.New("openvpn: packet too large")

ErrPacketTooLarge means that a packet is larger than math.MaxUint16.

Functions

This section is empty.

Types

type Dialer

type Dialer struct {
	// contains filtered or unexported fields
}

Dialer dials network connections. The zero value of this structure is invalid; please, use the NewDialer constructor.

func NewDialer

func NewDialer(logger model.Logger, dialer model.Dialer) *Dialer

NewDialer creates a new Dialer instance.

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network, address string) (FramingConn, error)

DialContext establishes a connection and, on success, automatically wraps the returned connection to implement OpenVPN framing when not using UDP.

type FramingConn

type FramingConn interface {
	// ReadRawPacket reads and return a raw OpenVPN packet.
	ReadRawPacket() ([]byte, error)

	// WriteRawPacket writes a raw OpenVPN packet.
	WriteRawPacket(pkt []byte) error

	// SetReadDeadline is like net.Conn.SetReadDeadline.
	SetReadDeadline(t time.Time) error

	// SetWriteDeadline is like net.Conn.SetWriteDeadline.
	SetWriteDeadline(t time.Time) error

	// LocalAddr is like net.Conn.LocalAddr.
	LocalAddr() net.Addr

	// RemoteAddr is like net.Conn.RemoteAddr.
	RemoteAddr() net.Addr

	// Close is like net.Conn.Close.
	Close() error
}

FramingConn is an OpenVPN network connection that knows about the framing used by OpenVPN to read and write raw packets.

type Service

type Service struct {
	// MuxerToNetwork moves bytes down from the muxer to the network IO layer
	MuxerToNetwork chan []byte

	// NetworkToMuxer moves bytes up from the network IO layer to the muxer
	NetworkToMuxer *chan []byte
}

Service is the network I/O service. Make sure you initialize the channels before invoking Service.StartWorkers.

func (*Service) StartWorkers

func (svc *Service) StartWorkers(
	config *config.Config,
	manager *workers.Manager,
	conn FramingConn,
)

StartWorkers starts the network I/O workers. See the ARCHITECTURE file for more information about the network I/O workers.

Jump to

Keyboard shortcuts

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