packet

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package packet provides implementations of packet handlers that transform WireGuard packets.

Index

Constants

View Source
const (
	WireGuardMessageTypeHandshakeInitiation  = 1
	WireGuardMessageTypeHandshakeResponse    = 2
	WireGuardMessageTypeHandshakeCookieReply = 3
	WireGuardMessageTypeData                 = 4

	WireGuardMessageLengthHandshakeInitiation  = 148
	WireGuardMessageLengthHandshakeResponse    = 92
	WireGuardMessageLengthHandshakeCookieReply = 64
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// Encrypt encrypts wgPacket and appends the result to dst, returning the updated slice.
	//
	// The remaining capacity of dst must not overlap wgPacket.
	Encrypt(dst, wgPacket []byte) ([]byte, error)

	// Decrypt decrypts swgpPacket and appends the result to dst, returning the updated slice.
	//
	// The remaining capacity of dst must not overlap swgpPacket.
	Decrypt(dst, swgpPacket []byte) ([]byte, error)

	// WithMaxPacketSize returns a new Handler with the given maximum packet size.
	WithMaxPacketSize(maxPacketSize int) Handler
}

Handler encrypts WireGuard packets and decrypts swgp packets.

func NewParanoidHandler

func NewParanoidHandler(psk []byte, maxPacketSize int) (Handler, error)

NewParanoidHandler creates a "paranoid" handler that uses the given PSK to encrypt and decrypt packets.

func NewZeroOverheadHandler

func NewZeroOverheadHandler(psk []byte, maxPacketSize int) (Handler, error)

NewZeroOverheadHandler creates a zero-overhead handler that uses the given PSK to encrypt and decrypt packets.

Jump to

Keyboard shortcuts

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