types

package
v0.4.5-rc5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// PublicNamespace is the name of the public namespace of a node
	// the public namespace is currently unique for a node so we hardcode its name
	PublicNamespace = "public"
	// PublicIface is the name of the interface we create in the public namespace
	PublicIface = "public"
	// GatewayNamespace is the name of the gateway namespace of a node
	GatewayNamespace = "gateway"
	// DefaultBridge is the name of the default bridge created
	// by the bootstrap of networkd
	DefaultBridge = "zos"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IPNet

type IPNet struct{ net.IPNet }

IPNet type

func MustParseIPNet

func MustParseIPNet(txt string) IPNet

MustParseIPNet prases iprange, panics if invalid

func NewIPNet

func NewIPNet(n *net.IPNet) IPNet

NewIPNet creates a new IPNet from net.IPNet

func NewIPNetFromSchema

func NewIPNetFromSchema(n schema.IPRange) IPNet

NewIPNetFromSchema creates an IPNet from schema.IPRange

func ParseIPNet

func ParseIPNet(txt string) (r IPNet, err error)

ParseIPNet parse iprange

func (IPNet) MarshalJSON

func (i IPNet) MarshalJSON() ([]byte, error)

MarshalJSON dumps iprange as a string

func (*IPNet) Nil

func (i *IPNet) Nil() bool

Nil returns true if IPNet is not set

func (IPNet) String

func (i IPNet) String() string

func (*IPNet) ToSchema

func (i *IPNet) ToSchema() schema.IPRange

ToSchema creates a schema IPRange from IPNet

func (*IPNet) UnmarshalText

func (i *IPNet) UnmarshalText(text []byte) error

UnmarshalText loads IPRange from string

type IfaceInfo

type IfaceInfo struct {
	Name       string            `json:"name"`
	Addrs      []IPNet           `json:"addrs"`
	Gateway    []net.IP          `json:"gateway"`
	MacAddress schema.MacAddress `json:"macaddress"`
}

IfaceInfo is the information about network interfaces that the node will publish publicly this is used to be able to configure public side of a node

func NewIfaceInfoFromSchema

func NewIfaceInfoFromSchema(iface directory.Iface) IfaceInfo

NewIfaceInfoFromSchema creates an IfaceInfo from schema type

func (*IfaceInfo) DefaultIP

func (i *IfaceInfo) DefaultIP() (net.IP, error)

DefaultIP return the IP address of the interface that has a default gateway configured this function currently only check IPv6 addresses

func (*IfaceInfo) ToSchema

func (i *IfaceInfo) ToSchema() directory.Iface

ToSchema converts IfaceInfo to a schema type

type IfaceType

type IfaceType string

IfaceType define the different public interface supported

const (
	//VlanIface means we use vlan for the public interface
	VlanIface IfaceType = "vlan"
	//MacVlanIface means we use macvlan for the public interface
	MacVlanIface IfaceType = "macvlan"
)

type Node

type Node struct {
	NodeID string `json:"node_id"`
	FarmID uint64 `json:"farm_id"`

	Ifaces []*IfaceInfo `json:"ifaces"`

	PublicConfig *PubIface `json:"public_config"`
	ExitNode     int       `json:"exit_node"`
	WGPorts      []uint    `json:"wg_ports"`
}

Node is the public information about a node

func NewNodeFromSchema

func NewNodeFromSchema(node directory.Node) *Node

NewNodeFromSchema converts a TfgridNode2 into Node

type PubIface

type PubIface struct {
	Master string `json:"master"`
	// Type define if we need to use
	// the Vlan field or the MacVlan
	Type IfaceType `json:"type"`
	Vlan int16     `json:"vlan"`

	IPv4 IPNet `json:"ipv4"`
	IPv6 IPNet `json:"ipv6"`

	GW4 net.IP `json:"gw4"`
	GW6 net.IP `json:"gw6"`

	Version int `json:"version"`
}

PubIface is the configuration of the interface that is connected to the public internet

func (*PubIface) ToSchema

func (p *PubIface) ToSchema() directory.PublicIface

ToSchema converts PubIface to schema type

Jump to

Keyboard shortcuts

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