Documentation
¶
Index ¶
- func AppendFunc[A any, B any, S []A, D []B](d D, s S, f func(A) B) D
- func Convert4to6(netID string, ip net.IP) net.IP
- type MyceliumInspection
- type NetResource
- func (nr *NetResource) AttachMycelium(name string) (err error)
- func (nr *NetResource) BridgeName() (string, error)
- func (nr *NetResource) ConfigureWG(privateKey string) error
- func (nr *NetResource) Create() error
- func (nr *NetResource) Delete() error
- func (nr *NetResource) HasWireguard() (bool, error)
- func (nr *NetResource) ID() string
- func (nr *NetResource) MyceliumIP(seed zos.Bytes) (ip net.IPNet, gw net.IPNet, err error)
- func (nr *NetResource) NRIface() (string, error)
- func (nr *NetResource) Namespace() (string, error)
- func (nr *NetResource) SetMycelium() (err error)
- func (nr *NetResource) SetWireguard(wg *wireguard.Wireguard) error
- func (nr *NetResource) String() string
- func (nr *NetResource) WGName() (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendFunc ¶
AppendFunc appends arrays with automatic map
Types ¶
type MyceliumInspection ¶
type MyceliumInspection struct { PublicHexKey string `json:"publicKey"` Address net.IP `json:"address"` }
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 (*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