NodeID creates a Tailscale NodeID from the last 8 bytes of a UUID. It ensures the returned NodeID is always positive.
(uid uuid.UUID)
| 141 | // NodeID creates a Tailscale NodeID from the last 8 bytes of a UUID. It ensures |
| 142 | // the returned NodeID is always positive. |
| 143 | func NodeID(uid uuid.UUID) tailcfg.NodeID { |
| 144 | // #nosec G115 - This is safe because the next lines ensure the ID is always positive |
| 145 | id := int64(binary.BigEndian.Uint64(uid[8:])) |
| 146 | |
| 147 | // ensure id is positive |
| 148 | y := id >> 63 |
| 149 | id = (id ^ y) - y |
| 150 | |
| 151 | return tailcfg.NodeID(id) |
| 152 | } |
| 153 | |
| 154 | // NewConn constructs a new Wireguard server that will accept connections from the addresses provided. |
| 155 | func NewConn(options *Options) (conn *Conn, err error) { |