Documentation ¶
Index ¶
- Constants
- type GreedyAddr
- type Peer
- type PeerInfo
- type Router
- func (r *Router) Addr() net.Addr
- func (r *Router) AllowImpreciseTraffic(allow bool)
- func (r *Router) Ascending() (*types.PublicKey, *types.VirtualSnakePathID)
- func (r *Router) AuthenticatedConnect(conn net.Conn, zone string, peertype int) (types.SwitchPortID, error)
- func (r *Router) Close() error
- func (r *Router) Connect(conn net.Conn, public types.PublicKey, zone string, peertype int) (types.SwitchPortID, error)
- func (r *Router) Coords() types.SwitchPorts
- func (r *Router) DHTInfo() (asc, desc *virtualSnakeNeighbour, ...)
- func (r *Router) DHTSearch(ctx context.Context, pk ed25519.PublicKey, stopshort bool) (types.PublicKey, net.Addr, error)
- func (r *Router) Descending() (*types.PublicKey, *types.VirtualSnakePathID)
- func (r *Router) Disconnect(i types.SwitchPortID, err error) error
- func (r *Router) IsConnected(key types.PublicKey, zone string) bool
- func (r *Router) IsRoot() bool
- func (r *Router) KnownNodes() []types.PublicKey
- func (r *Router) LocalAddr() net.Addr
- func (r *Router) ParentPublicKey() types.PublicKey
- func (r *Router) Pathfind(ctx context.Context, addr net.Addr) (net.Addr, error)
- func (r *Router) PeerCount(peertype int) int
- func (r *Router) Peers() []PeerInfo
- func (r *Router) PrivateKey() types.PrivateKey
- func (r *Router) PublicKey() types.PublicKey
- func (r *Router) ReadFrom(p []byte) (n int, addr net.Addr, err error)
- func (r *Router) RootPublicKey() types.PublicKey
- func (r *Router) SetConnectedCallback(f func(port types.SwitchPortID, publickey types.PublicKey, peertype int))
- func (r *Router) SetDeadline(t time.Time) error
- func (r *Router) SetDisconnectedCallback(...)
- func (r *Router) SetReadDeadline(t time.Time) error
- func (r *Router) SetWriteDeadline(t time.Time) error
- func (r *Router) WriteTo(p []byte, addr net.Addr) (n int, err error)
- type Simulator
- type SourceAddr
Constants ¶
const ( PeerTypeMulticast int = iota PeerTypeBluetooth PeerTypeRemote )
const MaxFrameSize = 65535*3 + 12
MaxFrameSize is the maximum size that a single frame can be, including all headers.
const MaxPayloadSize = 65535
MaxPayloadSize is the maximum size that a single frame can contain as a payload, not including headers.
const PortCount = 64
PortCount contains the number of ports supported by this Pinecone node. This is, in practice, the limit of concurrent peering connections that are supported at one time.
const ProtoBufferSize = 16
ProtoBufferSize is the number of protocol packets that a node will buffer on a slow port.
const TrafficBufferSize = 256
TrafficBufferSize is the number of traffic packets that a node will buffer on a slow port.
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 Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
func (*Peer) Coordinates ¶
func (p *Peer) Coordinates() types.SwitchPorts
func (*Peer) SeenCommonRootRecently ¶ added in v0.2.0
func (*Peer) SeenRecently ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Implements net.PacketConn. A Router is an instance of a Pinecone node and should only be instantiated using the NewRouter method.
func NewRouter ¶
func NewRouter(log *log.Logger, id string, private ed25519.PrivateKey, public ed25519.PublicKey, simulator Simulator) *Router
NewRouter instantiates a new Pinecone Router instance. The logger is where all log output will be sent for this node. The ID is a friendly string that identifies the node, but is not used at the protocol level and is not visible outside externally. The private and public keys are the primary identity of the node and therefore must be unique for each node. These keys are also used to sign protocol messages.
func (*Router) Addr ¶
Addr returns a net.Addr instance that addresses this node using greedy routing.
func (*Router) AllowImpreciseTraffic ¶ added in v0.2.0
AllowImpreciseTraffic controls whether the router should return traffic that isn't specifically destined for this node but has nowhere else to go. This is a requirement for routing with partial public keys.
func (*Router) Ascending ¶ added in v0.3.0
func (r *Router) Ascending() (*types.PublicKey, *types.VirtualSnakePathID)
DHTSuccessor returns the public key of the next node in the DHT snake.
func (*Router) AuthenticatedConnect ¶
func (r *Router) AuthenticatedConnect(conn net.Conn, zone string, peertype int) (types.SwitchPortID, error)
AuthenticatedConnect initiates a peer connection using the given net.Conn connection. The public keys of the nodes are exchanged using a handshake. The connection will fail if this handshake fails. The port number that the node was connected to will be returned in the event of a successful connection.
func (*Router) Close ¶
Close shuts down the node and stops the peering connections. The node should not be used after this has been called.
func (*Router) Connect ¶
func (r *Router) Connect(conn net.Conn, public types.PublicKey, zone string, peertype int) (types.SwitchPortID, error)
Connect initiates a peer connection using the given net.Conn connection, in the event that the public key of the node is already known (e.g. in the simulator). The port number that the node was connected to will be returned in the event of a successful connection.
func (*Router) Coords ¶
func (r *Router) Coords() types.SwitchPorts
Coords returns the current spanning tree coordinates of this node. The coordinates are effectively a source routing path from the root down to the node.
func (*Router) DHTInfo ¶ added in v0.3.0
func (r *Router) DHTInfo() (asc, desc *virtualSnakeNeighbour, table map[virtualSnakeIndex]virtualSnakeEntry)
func (*Router) DHTSearch ¶
func (r *Router) DHTSearch(ctx context.Context, pk ed25519.PublicKey, stopshort bool) (types.PublicKey, net.Addr, error)
DHTSearch initiates a DHT search for the given public key. The stopshort flag, if set to true, will return the closest node to the public key found in the search. If set to false, the search will fail and return an error if the specific node is not found.
func (*Router) Descending ¶ added in v0.3.0
func (r *Router) Descending() (*types.PublicKey, *types.VirtualSnakePathID)
DHTPredecessor returns the public key of the previous node in the DHT snake.
func (*Router) Disconnect ¶
func (r *Router) Disconnect(i types.SwitchPortID, err error) 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) IsConnected ¶
IsConnected returns true if the node is connected within the given zone, or false otherwise.
func (*Router) IsRoot ¶
IsRoot returns true if this node believes it is the root of the network. This will likely return true if the node is isolated (e.g. has no peers).
func (*Router) KnownNodes ¶
KnownNodes returns a list of all nodes that are known about directly. This includes all peers and all ancestor nodes between this node and the root node.
func (*Router) LocalAddr ¶
LocalAddr returns a net.Addr containing the greedy routing coordinates for this node.
func (*Router) ParentPublicKey ¶ added in v0.2.0
ParentPublicKey returns the public key of the node that this node believes is the parent.
func (*Router) Pathfind ¶
Pathfind takes a GreedyAddr (for greedy routing) or a types.PublicKey (for snake routing) and performs an active pathfind through the network. A SourceAddr will be returned which can be used to send packets using source routing instead. Note that this generates protocol traffic, so don't call it again unless you are sure the path has changed and the remote host is no longer answering. If the pathfind fails then an error will be returned instead.
func (*Router) PeerCount ¶
PeerCount returns the number of nodes that are directly connected to this Pinecone node. This will de-duplicate peerings to the same node in different zones.
func (*Router) Peers ¶
Peers returns a list of PeerInfos that show all of the currently connected peers.
func (*Router) PrivateKey ¶
func (r *Router) PrivateKey() types.PrivateKey
PrivateKey returns the ed25519 private key in use by this node.
func (*Router) ReadFrom ¶
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 ¶
RootPublicKey returns the public key of the node that this node believes is the root of the network.
func (*Router) SetConnectedCallback ¶
func (r *Router) SetConnectedCallback(f func(port types.SwitchPortID, publickey types.PublicKey, peertype int))
SetConnectedCallback defines a function that will be called when a new peer connection is successfully established.
func (*Router) SetDeadline ¶
SetDeadline is not implemented.
func (*Router) SetDisconnectedCallback ¶
func (r *Router) SetDisconnectedCallback(f func(port types.SwitchPortID, publickey types.PublicKey, peertype int, err error))
SetDisconnectedCallback defines a function that will be called either when an existing peer connection disconnects. An error field contains additional information about why the peering connection was closed.
func (*Router) SetReadDeadline ¶
SetReadDeadline is not implemented.
func (*Router) SetWriteDeadline ¶
SetWriteDeadline is not implemented.
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) }
Simulator is not used by normal Pinecone nodes and specifies the functions that must be satisfied if running under pineconesim.
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