Documentation
¶
Overview ¶
Package traffic contains helpers for evaluating traffic steering scores and picking appropriate nodes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NodeHasher ¶
NodeHasher returns a 64-bit hash of a node ID.
func MakeRendezvousHasher ¶
func MakeRendezvousHasher(seed tailcfg.NodeID) NodeHasher
MakeRendezvousHasher returns a function that hashes a node ID to a uint64. https://en.wikipedia.org/wiki/Rendezvous_hashing
func (NodeHasher) Compare ¶
func (h NodeHasher) Compare(a, b tailcfg.NodeID) int
Compare compares the node ID hashes of peers a and b, using the same convention as cmp.Compare. Since h is seeded with the current node’s ID, the ordering between a and b will remain stable for this node; but the order may flip for when h is seeded for another node. This function should return zero, if and only if a and b have the same node ID.
type Score ¶
type Score int
Score is a node’s traffic score, where any int could be a valid score. A higher traffic score suggests that the client should prefer that peer over one with a lower traffic score.
type Scores ¶
type Scores struct {
// contains filtered or unexported fields
}
Scores is a memoization cache for the traffic scores of the current node’s peers.
func ScoresFor ¶
ScoresFor returns a new Scores cache for the current node’s ID, after scoring the peer nodes and adding these scores to the cache.
func (Scores) All ¶
All returns an iterator over the scores for every peer in the cache. The iteration order is not specified and is not guaranteed to be the same from one call to the next.
func (*Scores) Score ¶
Score scores the given peer node and returns it after adding the score to the cache.
func (*Scores) ScorePeers ¶
ScorePeers scores the peer nodes and adds these scores to the cache.