conn

package
v0.0.0-...-3df9379 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package conn implements WireGuard's network connections.

Index

Constants

View Source
const (
	FD_ERR = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bind

type Bind interface {
	// LastMark reports the last mark set for this Bind.
	LastMark() uint32

	// SetMark sets the mark for each packet sent through this Bind.
	// This mark is passed to the kernel as the socket option SO_MARK.
	SetMark(mark uint32) error

	// ReceiveIPv6 reads an IPv6 UDP packet into b.
	//
	// It reports the number of bytes read, n,
	// the packet source address ep,
	// and any error.
	ReceiveIPv6(buff []byte) (n int, ep Endpoint, err error)

	// ReceiveIPv4 reads an IPv4 UDP packet into b.
	//
	// It reports the number of bytes read, n,
	// the packet source address ep,
	// and any error.
	ReceiveIPv4(b []byte) (n int, ep Endpoint, err error)

	// Send writes a packet b to address ep.
	Send(b []byte, ep Endpoint) error

	// Close closes the Bind connection.
	Close() error
}

A Bind listens on a port for both IPv6 and IPv4 UDP traffic.

A Bind interface may also be a PeekLookAtSocketFd or BindSocketToInterface, depending on the platform-specific implementation.

func CreateBind

func CreateBind(port uint16) (b Bind, actualPort uint16, err error)

CreateBind creates a Bind bound to a port.

The value actualPort reports the actual port number the Bind object gets bound to.

type BindSocketToInterface

type BindSocketToInterface interface {
	BindSocketToInterface4(interfaceIndex uint32, blackhole bool) error
	BindSocketToInterface6(interfaceIndex uint32, blackhole bool) error
}

BindSocketToInterface is implemented by Bind objects that support being tied to a single network interface. Used by wireguard-windows.

type Endpoint

type Endpoint interface {
	ClearSrc()           // clears the source address
	SrcToString() string // returns the local source address (ip:port)
	DstToString() string // returns the destination address (ip:port)
	DstToBytes() []byte  // used for mac2 cookie calculations
	DstIP() net.IP
	SrcIP() net.IP
}

An Endpoint maintains the source/destination caching for a peer.

dst : the remote address of a peer ("endpoint" in uapi terminology)
src : the local address from which datagrams originate going to the peer

func CreateEndpoint

func CreateEndpoint(s string) (Endpoint, error)

type IPv4Source

type IPv4Source struct {
	Src     [4]byte
	Ifindex int32
}

type IPv6Source

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

type NativeEndpoint

type NativeEndpoint struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*NativeEndpoint) ClearDst

func (end *NativeEndpoint) ClearDst()

func (*NativeEndpoint) ClearSrc

func (end *NativeEndpoint) ClearSrc()

func (*NativeEndpoint) Dst4

func (endpoint *NativeEndpoint) Dst4() *unix.SockaddrInet4

func (*NativeEndpoint) DstIP

func (end *NativeEndpoint) DstIP() net.IP

func (*NativeEndpoint) DstToBytes

func (end *NativeEndpoint) DstToBytes() []byte

func (*NativeEndpoint) DstToString

func (end *NativeEndpoint) DstToString() string

func (*NativeEndpoint) IsV6

func (endpoint *NativeEndpoint) IsV6() bool

func (*NativeEndpoint) Src4

func (endpoint *NativeEndpoint) Src4() *IPv4Source

func (*NativeEndpoint) SrcIP

func (end *NativeEndpoint) SrcIP() net.IP

func (*NativeEndpoint) SrcToString

func (end *NativeEndpoint) SrcToString() string

type PeekLookAtSocketFd

type PeekLookAtSocketFd interface {
	PeekLookAtSocketFd4() (fd int, err error)
	PeekLookAtSocketFd6() (fd int, err error)
}

PeekLookAtSocketFd is implemented by Bind objects that support having their file descriptor peeked at. Used by wireguard-android.

Jump to

Keyboard shortcuts

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