rait

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package rait provides the core logic of rait

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderTemplate added in v2.4.0

func RenderTemplate(in string, out string, ifnames []string) error

RenderTemplate gathers information about interfaces and renders the liquid template

Types

type Instance

type Instance struct {
	PrivateKey    string `validate:"required,base64"`          // required, the private key of current node
	AddressFamily string `validate:"required,oneof=ip4 ip6"`   // required, [ip4]/ip6, the address family of current node
	SendPort      int    `validate:"required,min=1,max=65535"` // required, the sending (destination) port of wireguard sockets
	BindAddress   string `validate:"omitempty,ip"`             // the local address for wireguard sockets to bind to

	InterfacePrefix   string `validate:"required"`                    // [rait], the common prefix to name the wireguard interfaces
	InterfaceGroup    int    `validate:"min=0,max=2147483647"`        // [54], the ifgroup for the wireguard interfaces
	MTU               int    `validate:"required,min=1280,max=65535"` // [1400], the MTU of the wireguard interfaces
	FwMark            int    `validate:"min=0,max=4294967295"`        // [0x36], the fwmark on packets sent by wireguard sockets
	DynamicListenPort bool   // false, use dynamic listen ports instead of pre-defined ones

	Isolation          string `validate:"required,oneof=netns vrf"` // [netns]/vrf, the isolation method to separate overlay from underlay
	InterfaceNamespace string // the netns or vrf to move wireguard interface into
	TransitNamespace   string // the netns or vrf to create wireguard sockets in

	Peers string // [/etc/rait/peers.conf], the url of the peer list
}

Instance is at the heart of rait it serves as the single source of truth for subsequent configuration of wireguard tunnels

func InstanceFromPath

func InstanceFromPath(path string) (*Instance, error)

func (*Instance) InterfaceConfig added in v2.4.0

func (instance *Instance) InterfaceConfig(peer *Peer) (*isolation.LinkAttrs, *wgtypes.Config, error)

func (*Instance) IsManagedInterface

func (instance *Instance) IsManagedInterface(attrs *isolation.LinkAttrs) bool

func (*Instance) ListInterfaceName added in v2.4.0

func (instance *Instance) ListInterfaceName() ([]string, error)

func (*Instance) LoadPeers

func (instance *Instance) LoadPeers() ([]*Peer, error)

func (*Instance) SyncInterfaces

func (instance *Instance) SyncInterfaces(up bool) error

type Peer

type Peer struct {
	PublicKey     string `validate:"required,base64"`               // required, the public key of the peer
	AddressFamily string `validate:"required,oneof=ip4 ip6"`        // required, [ip4]/ip6, the address family of this node
	Endpoint      string `validate:"omitempty,ip|hostname_rfc1123"` // the endpoint ip address or resolvable hostname
	SendPort      int    `validate:"required,min=1,max=65535"`      // required, the sending port of the peer
}

Peer represents a single rait node which corresponds to a wireguard interface

func PeersFromPath

func PeersFromPath(path string) ([]*Peer, error)

type RAIT added in v2.4.0

type RAIT struct {
	Instances []*Instance
}

func RAITFromPaths added in v2.4.0

func RAITFromPaths(paths []string) (*RAIT, error)

func (*RAIT) ListInterfaceName added in v2.4.0

func (ra *RAIT) ListInterfaceName() ([]string, error)

func (*RAIT) RenderTemplate added in v2.4.0

func (ra *RAIT) RenderTemplate(in, out string) error

func (*RAIT) SyncInterfaces added in v2.4.0

func (ra *RAIT) SyncInterfaces(up bool) error

Jump to

Keyboard shortcuts

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