proto

package
v0.0.0-...-d773db1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownMessageType = fmt.Errorf("unknown message type")

Functions

func ParseCIDR

func ParseCIDR(s string) (IP, Subnet, error)

ParseCIDR parses an IP and subnet in CIDR notation.

Types

type ConfigUpdater

type ConfigUpdater interface {
	UpdateConfig([]byte, []byte, time.Time)
	WaitForConfigConvergence(context.Context) error
}

ConfigUpdater is a service that can update configurations

type ExternalRouter

type ExternalRouter interface {
	// AddExternalRoute adds an external route.  When packets arrive for this destination, outgoingPacketFunc will be called.
	AddExternalRoute(string, Subnet, float32, func([]byte) error)
	// DelExternalRoute removes a previously added external route.  If the route does not exist, this has no effect.
	DelExternalRoute(string)
	// SendPacket routes and sends a packet
	SendPacket(packet []byte) error
	// SubscribeUpdates returns a channel that will be sent to whenever the routing policy changes
	SubscribeUpdates() <-chan RoutingPolicy
	// UnsubscribeUpdates unsubscribes a previously subscribed updates channel
	UnsubscribeUpdates(<-chan RoutingPolicy)
}

ExternalRouter is a device that can accept and send packets to external routes

type IP

type IP string

IP represents an IP address (IPv4 or IPv6)

func ParseIP

func ParseIP(s string) IP

ParseIP parses a human-readable address and returns an IP. Unlike net.IP, if the address is ipv4, the returned IP will be in ipv4 format (as if .To4() had been called on it).

func (IP) DebugString

func (a IP) DebugString() string

DebugString returns a representation to show in debuggers. Gor compatibility with GoLand this function must be able to be statically evaluated, so it cannot call other functions.

func (IP) Equal

func (a IP) Equal(b IP) bool

Equal returns true if the two IPs are equivalent, including IPv6 address equivalencies to IPv4.

func (IP) MarshalJSON

func (a IP) MarshalJSON() ([]byte, error)

MarshalJSON marshals an IP address to JSON.

func (IP) MarshalYAML

func (a IP) MarshalYAML() (interface{}, error)

MarshalYAML marshals an IP address to YAML.

func (IP) String

func (a IP) String() string

String returns the human-readable string representation of this address.

func (*IP) UnmarshalJSON

func (a *IP) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals an IP address from JSON.

func (*IP) UnmarshalYAML

func (a *IP) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals an IP address from YAML.

type InitMsg

type InitMsg struct {
	MyAddr IP
}

InitMsg is a message type sent at connection initialization time

func (*InitMsg) Marshal

func (m *InitMsg) Marshal() ([]byte, error)

Marshal marshals an InitMsg to a []byte

type KeepaliveMsg

type KeepaliveMsg struct{}

func (*KeepaliveMsg) Marshal

func (m *KeepaliveMsg) Marshal() ([]byte, error)

Marshal marshals a KeepaliveMsg to a []byte

type KeepaliveReplyMsg

type KeepaliveReplyMsg struct{}

func (*KeepaliveReplyMsg) Marshal

func (m *KeepaliveReplyMsg) Marshal() ([]byte, error)

Marshal marshals a KeepaliveReplyMsg to a []byte

type MarshalablePublicKey

type MarshalablePublicKey struct {
	ssh.PublicKey
	Comment string
}

func ParseAuthorizedKey

func ParseAuthorizedKey(key string) (*MarshalablePublicKey, error)

func (MarshalablePublicKey) MarshalJSON

func (mpk MarshalablePublicKey) MarshalJSON() ([]byte, error)

MarshalJSON marshals an SSH public key to JSON.

func (MarshalablePublicKey) MarshalYAML

func (mpk MarshalablePublicKey) MarshalYAML() (interface{}, error)

MarshalYAML marshals an SSH public key to YAML.

func (*MarshalablePublicKey) String

func (mpk *MarshalablePublicKey) String() string

String returns the SSH authorized_keys formatted string of the public key.

func (*MarshalablePublicKey) UnmarshalJSON

func (mpk *MarshalablePublicKey) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals an SSH public key from JSON.

func (*MarshalablePublicKey) UnmarshalYAML

func (mpk *MarshalablePublicKey) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals an SSH public key from YAML.

type Mask

type Mask string

Mask represents a netmask (IPv4 or IPv6)

func CIDRMask

func CIDRMask(ones int, bits int) Mask

func (Mask) DebugString

func (m Mask) DebugString() string

DebugString returns a representation to show in debuggers. Gor compatibility with GoLand this function must be able to be statically evaluated, so it cannot call other functions.

func (Mask) Prefix

func (m Mask) Prefix() int

Prefix returns the number of leading 1 bits in the netmask

func (Mask) String

func (m Mask) String() string

String returns the human-readable string representation of this netmask.

type Msg

type Msg []byte

Msg is the type of a single Netopus protocol datagram

func (Msg) Type

func (m Msg) Type() MsgType

Type returns the MsgType of a Msg

func (Msg) Unmarshal

func (m Msg) Unmarshal() (any, error)

Unmarshal unmarshals a message, returning []byte for a data message or a pointer to struct for other types

type MsgType

type MsgType int

MsgType enumerates the types of Netopus protocol messages

const (
	MsgTypeError          MsgType = -1
	MsgTypeData           MsgType = 0
	MsgTypeInit           MsgType = 1
	MsgTypeRouteOOB       MsgType = 2
	MsgTypeOOB            MsgType = 3
	MsgTypeKeepalive      MsgType = 4
	MsgTypeKeepaliveReply MsgType = 5
	MaxMsgType            MsgType = 5
)

type NameService

type NameService interface {
	// LookupName returns the IP for a name, with the IP being zero length if it is unknown.
	LookupName(string) IP
	// LookupIP returns the name for an IP, or the empty string if it is unknown.
	LookupIP(IP) string
	// AddExternalName adds an external name and associated IP address.
	AddExternalName(string, IP)
	// DelExternalName deletes a previous added external name.
	DelExternalName(string)
}

NameService is a service that can map names to IP addresses

type Netopus

Netopus is the aggregate interface providing all the functionality of a netopus instance

type OOBAddr

type OOBAddr struct {
	Host IP
	Port uint16
}

func (OOBAddr) Network

func (a OOBAddr) Network() string

func (OOBAddr) String

func (a OOBAddr) String() string

type OOBConnector

type OOBConnector interface {
	NewOOBPacketConn(ctx context.Context, port uint16) (net.PacketConn, error)
	DialOOB(ctx context.Context, raddr OOBAddr) (net.Conn, error)
	ListenOOB(ctx context.Context, port uint16) (net.Listener, error)
}

type OOBMessage

type OOBMessage struct {
	Hops       byte
	SourceAddr IP
	SourcePort uint16
	DestAddr   IP
	DestPort   uint16
	Data       []byte
}

OOBMessage is an out-of-band message

func (*OOBMessage) Marshal

func (oob *OOBMessage) Marshal() ([]byte, error)

Marshal marshals an OOBMessage to a []byte

func (*OOBMessage) String

func (oob *OOBMessage) String() string

String produces a string representation of an OOBMessage

type RouteOOBMessage

type RouteOOBMessage OOBMessage

func (*RouteOOBMessage) Marshal

func (rm *RouteOOBMessage) Marshal() ([]byte, error)

Marshal marshals a RouteOOBMessage to a []byte

func (*RouteOOBMessage) String

func (rm *RouteOOBMessage) String() string

String produces a string representation of a RouteOOBMessage

type RoutingConns

type RoutingConns map[Subnet]float32

RoutingConns stores the known connections and costs directly connected to a node

func (RoutingConns) MarshalJSON

func (rc RoutingConns) MarshalJSON() ([]byte, error)

func (*RoutingConns) UnmarshalJSON

func (rc *RoutingConns) UnmarshalJSON(data []byte) error

type RoutingNodes

type RoutingNodes map[IP]RoutingConns

RoutingNodes stores the known connection information for a network of nodes

type RoutingPolicy

type RoutingPolicy map[Subnet]IP

RoutingPolicy is a routing table giving the next hop for a list of subnets

type RoutingUpdate

type RoutingUpdate struct {
	Origin          IP
	NodeName        string
	UpdateEpoch     uint64
	UpdateSequence  uint64
	Connections     RoutingConns
	Names           map[string]IP
	ConfigVersion   time.Time
	ConfigData      []byte
	ConfigSignature []byte
}

RoutingUpdate is a message type carrying routing information

func (*RoutingUpdate) String

func (ru *RoutingUpdate) String() string

type SessionStatus

type SessionStatus struct {
	Connected bool
	ConnStart time.Time
}

SessionStatus represents the status of a single session

type Status

type Status struct {
	Name        string
	Addr        IP
	NameToAddr  map[string]string
	AddrToName  map[string]string
	RouterNodes map[string]map[string]float32
	Sessions    map[string]SessionStatus
}

Status is returned by netopus.Status()

type Subnet

type Subnet string

Subnet represents an IP subnet (IPv4 or IPv6)

func NewHostOnlySubnet

func NewHostOnlySubnet(a IP) Subnet

NewHostOnlySubnet creates a subnet containing only a single IP address (ie, a /32 for IPv4 or a /128 for IPv6).

func NewSubnet

func NewSubnet(a IP, m Mask) Subnet

NewSubnet creates a subnet from an address and mask, masking the host bits of the address. It is up to the caller to ensure a and m are the same length - if they are not, an invalid subnet will be returned.

func RandomSubnet

func RandomSubnet(ip IP, keepBits uint, prefixBits uint) Subnet

RandomSubnet returns a subnet with an address starting with keepBits bits of IP and random for the rest of prefixBits

func (Subnet) AsIPNet

func (s Subnet) AsIPNet() *net.IPNet

AsIPNet returns the subnet as a *net.IPNet

func (Subnet) Contains

func (s Subnet) Contains(a IP) bool

Contains returns true if the IP is contained within the subnet

func (Subnet) DebugString

func (s Subnet) DebugString() string

DebugString returns a representation to show in debuggers. Gor compatibility with GoLand this function must be able to be statically evaluated, so it cannot call other functions.

func (Subnet) IP

func (s Subnet) IP() IP

IP returns the IP address (network ID) of the subnet

func (Subnet) MarshalJSON

func (s Subnet) MarshalJSON() ([]byte, error)

MarshalJSON marshals an IP subnet to JSON.

func (Subnet) MarshalYAML

func (s Subnet) MarshalYAML() (interface{}, error)

MarshalYAML marshals an IP subnet to YAML.

func (Subnet) Mask

func (s Subnet) Mask() Mask

Mask returns the netmask of the subnet

func (Subnet) Prefix

func (s Subnet) Prefix() int

Prefix returns the prefix length of the subnet's netmask

func (Subnet) String

func (s Subnet) String() string

String returns the human-readable string representation of this subnet.

func (*Subnet) UnmarshalJSON

func (s *Subnet) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals an IP subnet from JSON.

func (*Subnet) UnmarshalYAML

func (s *Subnet) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals a subnet from YAML.

Jump to

Keyboard shortcuts

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