core

package
v0.0.0-...-de4c1f9 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: LGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddHandler

type AddHandler interface {
	AddHandler(name string, args []string, handlerfunc AddHandlerFunc) error
}

type AddHandlerFunc

type AddHandlerFunc func(json.RawMessage) (interface{}, error)

type Core

type Core struct {
	// This is the main data structure that holds everything else for a node
	// We're going to keep our own copy of the provided config - that way we can
	// guarantee that it will be covered by the mutex
	phony.Inbox
	*iwe.PacketConn
	// contains filtered or unexported fields
}

The Core object represents the Yggdrasil node. You should create a Core object for each Yggdrasil node you plan to run.

func (*Core) Address

func (c *Core) Address() net.IP

Address gets the IPv6 address of the Yggdrasil node. This is always a /128 address. The IPv6 address is only relevant when the node is operating as an IP router and often is meaningless when embedded into an application, unless that application also implements either VPN functionality or deals with IP packets specifically.

func (*Core) CallPeer

func (c *Core) CallPeer(u *url.URL, sintf string) error

CallPeer calls a peer once. This should be specified in the peer URI format, e.g.:

tcp://a.b.c.d:e
socks://a.b.c.d:e/f.g.h.i:j

This does not add the peer to the peer list, so if the connection drops, the peer will not be called again automatically.

func (*Core) Close

func (c *Core) Close() error

func (*Core) GetDHT

func (c *Core) GetDHT() []DHTEntry

func (*Core) GetPaths

func (c *Core) GetPaths() []PathEntry

func (*Core) GetPeers

func (c *Core) GetPeers() []Peer

func (*Core) GetSelf

func (c *Core) GetSelf() Self

func (*Core) GetSessions

func (c *Core) GetSessions() []Session

func (*Core) Listen

func (c *Core) Listen(u *url.URL, sintf string) (*TcpListener, error)

Listen starts a new listener (either TCP or TLS). The input should be a url.URL parsed from a string of the form e.g. "tcp://a.b.c.d:e". In the case of a link-local address, the interface should be provided as the second argument.

func (*Core) MTU

func (c *Core) MTU() uint64

func (*Core) PublicKey

func (c *Core) PublicKey() ed25519.PublicKey

func (*Core) ReadFrom

func (c *Core) ReadFrom(p []byte) (n int, from net.Addr, err error)

func (*Core) SetAdmin

func (c *Core) SetAdmin(a AddHandler) error

SetAdmin must be called after Init and before Start. It sets the admin handler for NodeInfo and the Debug admin functions.

func (*Core) SetLogger

func (c *Core) SetLogger(log *log.Logger)

SetLogger sets the output logger of the Yggdrasil node after startup. This may be useful if you want to redirect the output later. Note that this expects a Logger from the github.com/gologme/log package and not from Go's built-in log package.

func (*Core) Start

func (c *Core) Start(nc *config.NodeConfig, log *log.Logger) (err error)

Start starts up Yggdrasil using the provided config.NodeConfig, and outputs debug logging through the provided log.Logger. The started stack will include TCP and UDP sockets, a multicast discovery socket, an admin socket, router, switch and DHT node. A config.NodeState is returned which contains both the current and previous configurations (from reconfigures).

func (*Core) Stop

func (c *Core) Stop()

Stop shuts down the Yggdrasil node.

func (*Core) Subnet

func (c *Core) Subnet() net.IPNet

Subnet gets the routed IPv6 subnet of the Yggdrasil node. This is always a /64 subnet. The IPv6 subnet is only relevant when the node is operating as an IP router and often is meaningless when embedded into an application, unless that application also implements either VPN functionality or deals with IP packets specifically.

func (*Core) WriteTo

func (c *Core) WriteTo(p []byte, addr net.Addr) (n int, err error)

type DHTEntry

type DHTEntry struct {
	Key  ed25519.PublicKey
	Port uint64
	Rest uint64
}

type DebugGetDHTRequest

type DebugGetDHTRequest struct {
	Key string `json:"key"`
}

type DebugGetDHTResponse

type DebugGetDHTResponse map[string]interface{}

type DebugGetPeersRequest

type DebugGetPeersRequest struct {
	Key string `json:"key"`
}

type DebugGetPeersResponse

type DebugGetPeersResponse map[string]interface{}

type DebugGetSelfRequest

type DebugGetSelfRequest struct {
	Key string `json:"key"`
}

type DebugGetSelfResponse

type DebugGetSelfResponse map[string]interface{}

type GetNodeInfoRequest

type GetNodeInfoRequest struct {
	Key string `json:"key"`
}

type GetNodeInfoResponse

type GetNodeInfoResponse map[string]interface{}

type NodeInfoPayload

type NodeInfoPayload []byte

NodeInfoPayload represents a RequestNodeInfo response, in bytes.

type PathEntry

type PathEntry struct {
	Key  ed25519.PublicKey
	Path []uint64
}

type Peer

type Peer struct {
	Key     ed25519.PublicKey
	Root    ed25519.PublicKey
	Coords  []uint64
	Port    uint64
	Remote  string
	RXBytes uint64
	TXBytes uint64
	Uptime  time.Duration
}

type Self

type Self struct {
	Key    ed25519.PublicKey
	Root   ed25519.PublicKey
	Coords []uint64
}

type Session

type Session struct {
	Key ed25519.PublicKey
}

type TcpListener

type TcpListener struct {
	Listener net.Listener
	// contains filtered or unexported fields
}

TcpListener is a stoppable TCP listener interface. These are typically returned from calls to the ListenTCP() function and are also used internally to represent listeners created by the "Listen" configuration option and for multicast interfaces.

func (*TcpListener) Stop

func (l *TcpListener) Stop()

type TcpUpgrade

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

Jump to

Keyboard shortcuts

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