router

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: Apache-2.0 Imports: 17 Imported by: 44

Documentation

Index

Constants

View Source
const (
	PeerTypeMulticast int = iota
	PeerTypeBluetooth
	PeerTypeRemote
)
View Source
const PeerKeepaliveInterval = time.Second * 3
View Source
const PeerKeepaliveTimeout = time.Second * 5
View Source
const PortCount = math.MaxUint8
View Source
const TrafficBuffer = math.MaxUint8

Variables

This section is empty.

Functions

This section is empty.

Types

type GreedyAddr

type GreedyAddr struct {
	types.SwitchPorts
}

GreedyAddr implements net.Addr, containing a greedy-routed set of destination coordinates to another node.

func (GreedyAddr) Network

func (a GreedyAddr) Network() string

func (GreedyAddr) String

func (a GreedyAddr) String() string

type PeerInfo

type PeerInfo struct {
	Port          int
	PublicKey     string
	RootPublicKey string
	PeerType      int
	Zone          string
}

type Router

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

func NewRouter

func NewRouter(log *log.Logger, sk ed25519.PrivateKey, id string, sim Simulator) *Router

func (*Router) Addr

func (r *Router) Addr() net.Addr

func (*Router) Ascending added in v0.3.0

func (r *Router) Ascending() (*types.PublicKey, *types.VirtualSnakePathID)

func (*Router) AuthenticatedConnect

func (r *Router) AuthenticatedConnect(conn net.Conn, zone string, peertype int) (types.SwitchPortID, error)

func (*Router) Close

func (r *Router) Close() error

func (*Router) Connect

func (r *Router) Connect(conn net.Conn, public types.PublicKey, zone string, peertype int) (types.SwitchPortID, error)

func (*Router) Coords

func (r *Router) Coords() types.SwitchPorts

func (*Router) DHTInfo added in v0.3.0

func (r *Router) DHTInfo() (asc, desc *virtualSnakeEntry, table map[virtualSnakeIndex]virtualSnakeEntry, stale int)

func (*Router) Descending added in v0.3.0

func (r *Router) Descending() (*types.PublicKey, *types.VirtualSnakePathID)

func (*Router) IsConnected

func (r *Router) IsConnected(key types.PublicKey, zone string) bool

IsConnected returns true if the node is connected within the given zone, or false otherwise.

func (*Router) IsRoot

func (r *Router) IsRoot() bool

func (*Router) LocalAddr

func (r *Router) LocalAddr() net.Addr

LocalAddr returns a net.Addr containing the greedy routing coordinates for this node.

func (*Router) ParentPublicKey added in v0.2.0

func (r *Router) ParentPublicKey() types.PublicKey

func (*Router) Peers

func (r *Router) Peers() []PeerInfo

func (*Router) PrivateKey

func (r *Router) PrivateKey() types.PrivateKey

func (*Router) PublicKey

func (r *Router) PublicKey() types.PublicKey

func (*Router) ReadFrom

func (r *Router) ReadFrom(p []byte) (n int, addr net.Addr, err error)

ReadFrom reads the next packet that was delivered to this node over the Pinecone network. Only traffic packets will be returned here - no protocol messages will be included. The net.Addr returned will contain the appropriate return path based on the mechanism used to deliver the packet. If the packet was delivered using greedy routing, then the net.Addr will contain the source coordinates. If the packet was delivered using source routing, then the net.Addr will contain the source-routed path back to the sender.

func (*Router) RootPublicKey

func (r *Router) RootPublicKey() types.PublicKey

func (*Router) SNEKPing added in v0.4.0

func (r *Router) SNEKPing(ctx context.Context, dst types.PublicKey) (time.Duration, error)

func (*Router) SetDeadline

func (r *Router) SetDeadline(t time.Time) error

SetDeadline is not implemented.

func (*Router) SetReadDeadline

func (r *Router) SetReadDeadline(t time.Time) error

SetReadDeadline is not implemented.

func (*Router) SetWriteDeadline

func (r *Router) SetWriteDeadline(t time.Time) error

SetWriteDeadline is not implemented.

func (*Router) ToggleDebug added in v0.4.0

func (r *Router) ToggleDebug()

func (*Router) TreePing added in v0.4.0

func (r *Router) TreePing(ctx context.Context, dst types.SwitchPorts) (time.Duration, error)

func (*Router) WriteTo

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

WriteTo sends a packet into the Pinecone network. The packet will be sent as a traffic packet. The net.Addr must be one of the Pinecone address types (e.g. GreedyAddr or SourceAddr), as this will dictate the method of delivery used to forward the packet.

type Simulator

type Simulator interface {
	ReportDistance(a, b string, l int64)
	LookupCoords(string) (types.SwitchPorts, error)
	LookupNodeID(types.SwitchPorts) (string, error)
	LookupPublicKey(types.PublicKey) (string, error)
	ReportNewLink(net.Conn, types.PublicKey, types.PublicKey)
	ReportDeadLink(types.PublicKey, types.PublicKey)
}

type SourceAddr

type SourceAddr struct {
	types.SwitchPorts
}

SourceAddr implements net.Addr, containing a source-routed path to another node.

func (SourceAddr) Network

func (a SourceAddr) Network() string

func (SourceAddr) String

func (a SourceAddr) String() string

Jump to

Keyboard shortcuts

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