l4wireguard

package
v0.0.0-...-ce42594 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Poly1305TagSize int = 16

	MessageInitiationBytesTotal  int = 148
	MessageResponseBytesTotal    int = 92
	MessageCookieReplyBytesTotal int = 64
	MessageTransportBytesMin     int = 32

	MessageTypeInitiation  uint32 = 1
	MessageTypeResponse    uint32 = 2
	MessageTypeCookieReply uint32 = 3
	MessageTypeTransport   uint32 = 4

	ReservedZeroFilter = ^(uint32(0)) >> 8 << 8
)

Refs:

https://www.wireguard.com/protocol/
https://www.wireguard.com/papers/wireguard.pdf
https://github.com/pirate/wireguard-docs
https://github.com/WireGuard/wireguard-go/blob/master/device/noise-protocol.go

Variables

View Source
var (
	MessageBytesOrder = binary.LittleEndian
)

Functions

This section is empty.

Types

type MatchWireGuard

type MatchWireGuard struct {
	// Zero may be used to match reserved zero bytes of Type field when
	// they have non-zero values (e.g. for obfuscation purposes). E.g. it
	// may be set to 4,285,988,864 (0xFF770000) in order to match custom
	// handshake initiation messages starting with 0x010077FF byte sequence.
	// Note: any non-zero value is a violation of the WireGuard protocol.
	Zero uint32 `json:"zero,omitempty"`
}

MatchWireGuard is able to match WireGuard connections.

func (*MatchWireGuard) CaddyModule

func (m *MatchWireGuard) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*MatchWireGuard) Match

func (m *MatchWireGuard) Match(cx *layer4.Connection) (bool, error)

Match returns true if the connection looks like WireGuard.

func (*MatchWireGuard) Provision

func (m *MatchWireGuard) Provision(_ caddy.Context) error

Provision prepares m's internal structures.

func (*MatchWireGuard) UnmarshalCaddyfile

func (m *MatchWireGuard) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the MatchWireGuard from Caddyfile tokens. Syntax:

wireguard [<zero>]

type MessageInitiation

type MessageInitiation struct {
	Type      uint32
	Sender    uint32
	Ephemeral [32]uint8
	Static    [32 + Poly1305TagSize]uint8
	Timestamp [12 + Poly1305TagSize]uint8
	MAC1      [16]uint8
	MAC2      [16]uint8
}

MessageInitiation is the first message which the initiator sends to the responder.

func (*MessageInitiation) FromBytes

func (msg *MessageInitiation) FromBytes(src []byte) error

func (*MessageInitiation) ToBytes

func (msg *MessageInitiation) ToBytes() ([]byte, error)

type MessageTransport

type MessageTransport struct {
	Type     uint32
	Receiver uint32
	Counter  uint64
	Content  []uint8
}

MessageTransport is the message which the initiator and the responder exchange after a successful handshake.

func (*MessageTransport) FromBytes

func (msg *MessageTransport) FromBytes(src []byte) error

func (*MessageTransport) ToBytes

func (msg *MessageTransport) ToBytes() ([]byte, error)

Jump to

Keyboard shortcuts

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