Try to convert TUN/TAP to use new yggdrasil.Conn, search masks are still broken

This commit is contained in:
Neil Alexander 2019-04-20 16:32:27 +01:00
parent 319366513c
commit d01662c1fb
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
14 changed files with 502 additions and 366 deletions

View file

@ -37,10 +37,37 @@ func (n *NodeID) String() string {
return hex.EncodeToString(n[:])
}
// Network returns "nodeid" nearly always right now.
func (n *NodeID) Network() string {
return "nodeid"
}
// PrefixLength returns the number of bits set in a masked NodeID.
func (n *NodeID) PrefixLength() int {
var len int
for i, v := range *n {
_, _ = i, v
if v == 0xff {
len += 8
continue
}
for v&0x80 != 0 {
len++
v <<= 1
}
if v != 0 {
return -1
}
for i++; i < NodeIDLen; i++ {
if n[i] != 0 {
return -1
}
}
break
}
return len
}
func GetNodeID(pub *BoxPubKey) *NodeID {
h := sha512.Sum512(pub[:])
return (*NodeID)(&h)