nr

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFunc

func AppendFunc[A any, B any, S []A, D []B](d D, s S, f func(A) B) D

AppendFunc appends arrays with automatic map

func Convert4to6

func Convert4to6(netID string, ip net.IP) net.IP

Convert4to6 converts a (private) ipv4 to the corresponding ipv6

Types

type MyceliumInspection

type MyceliumInspection struct {
	PublicHexKey string `json:"publicKey"`
	Address      net.IP `json:"address"`
}

func (*MyceliumInspection) Gateway

func (m *MyceliumInspection) Gateway() (subnet net.IPNet, gw net.IPNet, err error)

Gateway derive the gateway IP from the mycelium IP in the /64 range. It also return the full /64 subnet.

func (*MyceliumInspection) IP

func (m *MyceliumInspection) IP(seed zos.Bytes) (ip net.IPNet, gw net.IPNet, err error)

type NetResource

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

NetResource holds the logic to configure an network resource

func New

func New(nr pkg.Network, keyDir string) *NetResource

New creates a new NetResource object iprange is the full network subnet keyDir is the path where keys (mainly mycelium) is stored.

func (*NetResource) AttachMycelium

func (nr *NetResource) AttachMycelium(name string) (err error)

AttachMycelium attaches a tap device to mycelium, move it to the host namespace to it can be used by VMs later. It also return the IP that should be used with the interface

func (*NetResource) BridgeName

func (nr *NetResource) BridgeName() (string, error)

BridgeName returns the name of the bridge to create for the network resource in the host network namespace

func (*NetResource) ConfigureWG

func (nr *NetResource) ConfigureWG(privateKey string) error

ConfigureWG sets the routes and IP addresses on the wireguard interface of the network resources

func (*NetResource) Create

func (nr *NetResource) Create() error

Create setup the basic components of the network resource network namespace, bridge, wireguard interface and veth pair

func (*NetResource) Delete

func (nr *NetResource) Delete() error

Delete removes all the interfaces and namespaces created by the Create method

func (*NetResource) HasWireguard

func (nr *NetResource) HasWireguard() (bool, error)

HasWireguard checks if network resource has wireguard setup up

func (*NetResource) ID

func (nr *NetResource) ID() string

ID returns the network ID in which the NetResource is defined

func (*NetResource) MyceliumIP

func (nr *NetResource) MyceliumIP(seed zos.Bytes) (ip net.IPNet, gw net.IPNet, err error)

func (*NetResource) NRIface

func (nr *NetResource) NRIface() (string, error)

NRIface returns name of netresource local interface

func (*NetResource) Namespace

func (nr *NetResource) Namespace() (string, error)

Namespace returns the name of the network namespace to create for the network resource

func (*NetResource) SetMycelium

func (nr *NetResource) SetMycelium() (err error)

func (*NetResource) SetWireguard

func (nr *NetResource) SetWireguard(wg *wireguard.Wireguard) error

SetWireguard sets wireguard of this network resource

func (*NetResource) String

func (nr *NetResource) String() string

func (*NetResource) WGName

func (nr *NetResource) WGName() (string, error)

WGName returns the name of the wireguard interface to create for the network resource

Jump to

Keyboard shortcuts

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