router

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: Apache-2.0 Imports: 23 Imported by: 32

Documentation

Index

Constants

View Source
const (
	PeerTypePipe int = iota
	PeerTypeMulticast
	PeerTypeBonjour
	PeerTypeRemote
	PeerTypeBluetooth
)

Lower numbers for these consts are typically faster connections.

View Source
const BWReportingInterval = time.Minute

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionKeepalives added in v0.6.0

type ConnectionKeepalives bool

type ConnectionOption added in v0.6.0

type ConnectionOption interface {
	// contains filtered or unexported methods
}

type ConnectionPeerType added in v0.6.0

type ConnectionPeerType int

type ConnectionPublicKey added in v0.6.0

type ConnectionPublicKey types.PublicKey

type ConnectionURI added in v0.6.0

type ConnectionURI string

type ConnectionZone added in v0.6.0

type ConnectionZone string

type FilterFn added in v0.7.0

type FilterFn func(from types.PublicKey, f *types.Frame) bool

type FloodType added in v0.11.0

type FloodType int
const (
	ClassicFlood FloodType = iota
	TreeFlood
)

type NeighbourInfo added in v0.5.0

type NeighbourInfo struct {
	PublicKey types.PublicKey
}

type PeerInfo

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

type Router

type Router struct {
	phony.Inbox
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(logger types.Logger, sk ed25519.PrivateKey, opts ...RouterOption) *Router

func (*Router) Addr

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

Addr returns the local address of the node in the form of a `types.PublicKey`.

func (*Router) Close

func (r *Router) Close() error

Close will stop the Pinecone node. Once this has been called, the node cannot be restarted or reused.

func (*Router) Connect

func (r *Router) Connect(conn net.Conn, options ...ConnectionOption) (types.SwitchPortID, error)

Connect takes a connection and attaches it to the switch as a peering. This function takes one or more ConnectionOptions to configure the peer. If no ConnectionPublicKey is specified, the connection will autonegotiate with the remote peer to exchange public keys and version/capability information.

func (*Router) Coords

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

func (*Router) DisableHopLimiting added in v0.11.0

func (r *Router) DisableHopLimiting()

func (*Router) DisableWakeupBroadcasts added in v0.11.0

func (r *Router) DisableWakeupBroadcasts()

func (*Router) Disconnect

func (r *Router) Disconnect(i types.SwitchPortID, err error)

Disconnect will disconnect whatever is connected to the given port number on the Pinecone node. The peering will no longer be used and the underlying connection will be closed.

func (*Router) EnableHopLimiting added in v0.11.0

func (r *Router) EnableHopLimiting()

func (*Router) EnableWakeupBroadcasts added in v0.11.0

func (r *Router) EnableWakeupBroadcasts()

func (*Router) InjectPacketFilter added in v0.7.0

func (r *Router) InjectPacketFilter(fn FilterFn)

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) LocalAddr

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

LocalAddr returns a net.Addr containing the public key of the node for SNEK routing.

func (*Router) ManholeHandler added in v0.7.0

func (r *Router) ManholeHandler(w http.ResponseWriter, req *http.Request)

func (*Router) PeerCount

func (r *Router) PeerCount(peertype int) (count int)

PeerCount returns the number of nodes that are directly connected to this Pinecone node.

func (*Router) Peers

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

func (*Router) PrivateKey

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

PrivateKey returns the private key of the node.

func (*Router) PublicKey

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

PublicKey returns the public key of the node.

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 frames will be returned here (not protocol frames). The returned address will either be a `types.PublicKey` (if the frame was delivered using SNEK routing) or `types.Coordinates` (if the frame was delivered using tree routing).

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

func (*Router) SetWriteDeadline

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

SetWriteDeadline is not implemented.

func (*Router) Subscribe added in v0.6.0

func (r *Router) Subscribe(ch chan<- events.Event)

Subscribe registers a subscriber to this node's events

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 supplied net.Addr will dictate the method used to route the packet — the address should be a `types.PublicKey` for SNEK routing or `types.Coordinates` for tree routing. Supplying an unsupported address type will result in a `*net.AddrError` being returned.

type RouterOption added in v0.10.0

type RouterOption interface {
	// contains filtered or unexported methods
}

type RouterOptionBlackhole added in v0.10.0

type RouterOptionBlackhole bool

type TreeAnnouncementAction added in v0.7.0

type TreeAnnouncementAction int64
const (
	DropFrame TreeAnnouncementAction = iota // Default value
	AcceptUpdate
	AcceptNewParent
	SelectNewParent
	SelectNewParentWithWait
	InformPeerOfStrongerRoot
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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