wireguard

package module
v0.0.0-...-406a70e Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2016 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

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

An Interface communicates encrypted packets with peers.

func NewInterface

func NewInterface(c InterfaceConfig) (*Interface, error)

func (*Interface) AddPeer

func (f *Interface) AddPeer(p *Peer) error

AddPeer adds a peer to the interface configuration. If the peer, identified by its public key, already exists, then all configuration will be replaced with the new fields.

func (*Interface) Close

func (f *Interface) Close() error

Close shuts down the interface.

func (*Interface) GetPeers

func (f *Interface) GetPeers() []*Peer

GetPeers retrieves a list of all peers known to the interface.

func (*Interface) RemovePeer

func (f *Interface) RemovePeer(pubkey []byte) error

RemovePeer removes the peer identified with the public key pubkey from the interface configuration.

func (*Interface) Run

func (f *Interface) Run() error

Run starts the interface and blocks until it is closed.

func (*Interface) SetPeers

func (f *Interface) SetPeers(peers []*Peer) error

SetPeers replaces all of the peers that the interface is configured for with a new list.

func (*Interface) SetPresharedKey

func (f *Interface) SetPresharedKey(k []byte) error

SetPresharedKey changes the pre-shared key for the interface.

func (*Interface) SetPrivateKey

func (f *Interface) SetPrivateKey(k []byte) error

SetPrivateKey changes the private key for the interface. It is safe to call while the interface is running.

type InterfaceConfig

type InterfaceConfig struct {
	// Outside is the connection that will be used to send and receive encrypted
	// packets with peers. It will be closed if Close is called on the Interface.
	Outside UDPConn

	// Inside is the interface that will be used to read plaintext packets
	// destined for peers and write decrypted packets received from peers. Each
	// Read must return a single IP packet to send to a peer, and each Write
	// will provide a single received IP packet.
	Inside io.ReadWriter

	// PrivateKey holds the static Curve25519 private key for the interface. If
	// set, it must be exactly 32 random bytes.
	PrivateKey []byte

	// PresharedKey holds an optional pre-shared key to use during handshakes.
	// If set, it must be exactly 32 random bytes.
	PresharedKey []byte

	// Peers is the initial set of peers that the interface will communicate
	// with.
	Peers []*Peer
}

An InterfaceConfig is the configuration used to create an interface.

type Peer

type Peer struct {
	// PublicKey is the static Curve25519 public key of the peer. It must be
	// exactly 32 bytes.
	PublicKey []byte

	// AllowedIPs is the list of IP networks that will be routed to and accepted
	// from the peer.
	AllowedIPs []*net.IPNet

	// Endpoint is the network address that packets destined for the peer will
	// be sent to. If it is nil, packets destined for this peer will not be
	// routable until an incoming handshake is received.
	Endpoint *net.UDPAddr

	// PersistentKeepaliveInterval, if non-zero, is the number of seconds
	// between keep-alive packets sent to the peer.
	PersistentKeepaliveInterval int

	// LastHandshake is the timestamp of the last successful handshake with the
	// peer. This field is read-only.
	LastHandshake time.Time

	// RxBytes is the number of bytes received from the peer. This field is
	// read-only.
	RxBytes int64

	// TxBytes is the number of bytes transmitted to the peer. This field is
	// read-only.
	TxBytes int64
}

A Peer is a remote endpoint that can be communicated with via an Interface.

type UDPConn

type UDPConn interface {
	ReadFromUDP(b []byte) (int, *net.UDPAddr, error)
	WriteToUDP(b []byte, addr *net.UDPAddr) (int, error)
	Close() error
}

Directories

Path Synopsis
internal
skip32
Package skip32 implements the Skip32 blockcipher
Package skip32 implements the Skip32 blockcipher

Jump to

Keyboard shortcuts

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