Documentation ¶
Index ¶
- Constants
- type NeighbourInfo
- type PeerInfo
- type Router
- func (r *Router) Addr() net.Addr
- func (r *Router) Ascending() *NeighbourInfo
- func (r *Router) AuthenticatedConnect(conn net.Conn, zone string, peertype int, keepalives bool) (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.Coordinates
- func (r *Router) DHTInfo() (asc, desc *NeighbourInfo, table map[virtualSnakeIndex]virtualSnakeEntry, ...)
- func (r *Router) Descending() *NeighbourInfo
- func (r *Router) Disconnect(i types.SwitchPortID, err error)
- func (r *Router) IsConnected(key types.PublicKey, zone string) bool
- func (r *Router) IsRoot() bool
- func (r *Router) LocalAddr() net.Addr
- func (r *Router) ParentPublicKey() types.PublicKey
- func (r *Router) PeerCount(peertype int) (count int)
- func (r *Router) Peers() []PeerInfo
- func (r *Router) Ping(ctx context.Context, a net.Addr) (uint16, time.Duration, error)
- 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) SetDeadline(t time.Time) error
- 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)
Constants ¶
const ( PeerTypeMulticast int = iota PeerTypeBluetooth PeerTypeRemote )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NeighbourInfo ¶ added in v0.5.0
type NeighbourInfo struct { PublicKey types.PublicKey PathID types.VirtualSnakePathID }
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Addr ¶
Addr returns the local address of the node in the form of a `types.PublicKey`.
func (*Router) Ascending ¶ added in v0.3.0
func (r *Router) Ascending() *NeighbourInfo
func (*Router) AuthenticatedConnect ¶
func (r *Router) AuthenticatedConnect(conn net.Conn, zone string, peertype int, keepalives bool) (types.SwitchPortID, error)
AuthenticatedConnect takes a connection and exchanges a handshake containing node capabilities and public keys. If the handshake succeeds then the connection will be connected to the Pinecone switch.
func (*Router) Close ¶
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, public types.PublicKey, zone string, peertype int, keepalives bool) (types.SwitchPortID, error)
Connect takes a connection and attaches it to the switch as a peering. This function assumes that you already know the public key of the remote node. If this is not true, then AuthenticatedConnect should be used instead.
func (*Router) Coords ¶
func (r *Router) Coords() types.Coordinates
func (*Router) DHTInfo ¶ added in v0.3.0
func (r *Router) DHTInfo() (asc, desc *NeighbourInfo, table map[virtualSnakeIndex]virtualSnakeEntry, stale int)
func (*Router) Descending ¶ added in v0.3.0
func (r *Router) Descending() *NeighbourInfo
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) IsConnected ¶
IsConnected returns true if the node is connected within the given zone, or false otherwise.
func (*Router) LocalAddr ¶
LocalAddr returns a net.Addr containing the public key of the node for SNEK routing.
func (*Router) ParentPublicKey ¶ added in v0.2.0
func (*Router) PeerCount ¶
PeerCount returns the number of nodes that are directly connected to this Pinecone node.
func (*Router) PrivateKey ¶
func (r *Router) PrivateKey() types.PrivateKey
PrivateKey returns the private key of the node.
func (*Router) ReadFrom ¶
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) RootPublicKey ¶
func (*Router) SetDeadline ¶
SetDeadline is not implemented.
func (*Router) SetReadDeadline ¶
SetReadDeadline is not implemented.
func (*Router) SetWriteDeadline ¶
SetWriteDeadline is not implemented.
func (*Router) WriteTo ¶
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.