mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-26 13:01:39 +00:00
commit
248edf8319
@ -14,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// The peers struct represents peers with an active connection.
|
// The peers struct represents peers with an active connection.
|
||||||
// Incomping packets are passed to the corresponding peer, which handles them somehow.
|
// Incoming packets are passed to the corresponding peer, which handles them somehow.
|
||||||
// In most cases, this involves passing the packet to the handler for outgoing traffic to another peer.
|
// In most cases, this involves passing the packet to the handler for outgoing traffic to another peer.
|
||||||
// In other cases, it's link protocol traffic used to build the spanning tree, in which case this checks signatures and passes the message along to the switch.
|
// In other cases, it's link protocol traffic used to build the spanning tree, in which case this checks signatures and passes the message along to the switch.
|
||||||
type peers struct {
|
type peers struct {
|
||||||
@ -97,7 +97,7 @@ type peer struct {
|
|||||||
close func() // Called when a peer is removed, to close the underlying connection, or via admin api
|
close func() // Called when a peer is removed, to close the underlying connection, or via admin api
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new peer with the specified box, sig, and linkShared keys, using the lowest unocupied port number.
|
// Creates a new peer with the specified box, sig, and linkShared keys, using the lowest unoccupied port number.
|
||||||
func (ps *peers) newPeer(box *crypto.BoxPubKey, sig *crypto.SigPubKey, linkShared *crypto.BoxSharedKey, endpoint string) *peer {
|
func (ps *peers) newPeer(box *crypto.BoxPubKey, sig *crypto.SigPubKey, linkShared *crypto.BoxSharedKey, endpoint string) *peer {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
p := peer{box: *box,
|
p := peer{box: *box,
|
||||||
@ -342,7 +342,7 @@ func (p *peer) handleSwitchMsg(packet []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This generates the bytes that we sign or check the signature of for a switchMsg.
|
// This generates the bytes that we sign or check the signature of for a switchMsg.
|
||||||
// It begins with the next node's key, followed by the root and the timetsamp, followed by coords being advertised to the next node.
|
// It begins with the next node's key, followed by the root and the timestamp, followed by coords being advertised to the next node.
|
||||||
func getBytesForSig(next *crypto.SigPubKey, msg *switchMsg) []byte {
|
func getBytesForSig(next *crypto.SigPubKey, msg *switchMsg) []byte {
|
||||||
var loc switchLocator
|
var loc switchLocator
|
||||||
for _, hop := range msg.Hops {
|
for _, hop := range msg.Hops {
|
||||||
|
@ -30,7 +30,7 @@ const search_MAX_SEARCH_SIZE = 16
|
|||||||
const search_RETRY_TIME = time.Second
|
const search_RETRY_TIME = time.Second
|
||||||
|
|
||||||
// Information about an ongoing search.
|
// Information about an ongoing search.
|
||||||
// Includes the targed NodeID, the bitmask to match it to an IP, and the list of nodes to visit / already visited.
|
// Includes the target NodeID, the bitmask to match it to an IP, and the list of nodes to visit / already visited.
|
||||||
type searchInfo struct {
|
type searchInfo struct {
|
||||||
dest crypto.NodeID
|
dest crypto.NodeID
|
||||||
mask crypto.NodeID
|
mask crypto.NodeID
|
||||||
|
@ -4,7 +4,7 @@ package yggdrasil
|
|||||||
// It routes packets based on distance on the spanning tree
|
// It routes packets based on distance on the spanning tree
|
||||||
// In general, this is *not* equivalent to routing on the tree
|
// In general, this is *not* equivalent to routing on the tree
|
||||||
// It falls back to the tree in the worst case, but it can take shortcuts too
|
// It falls back to the tree in the worst case, but it can take shortcuts too
|
||||||
// This is the part that makse routing reasonably efficient on scale-free graphs
|
// This is the part that makes routing reasonably efficient on scale-free graphs
|
||||||
|
|
||||||
// TODO document/comment everything in a lot more detail
|
// TODO document/comment everything in a lot more detail
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user