package node import ( "net/netip" "sync/atomic" "vppn/m" ) var zeroAddrPort = netip.AddrPort{} const ( bufferSize = 1536 if_mtu = 1200 if_queue_len = 2048 controlCipherOverhead = 16 dataCipherOverhead = 16 ) type peerRoute struct { IP byte Up bool // True if data can be sent on the route. Relay bool // True if the peer is a relay. ControlCipher *controlCipher DataCipher *dataCipher RemoteAddr netip.AddrPort // Remote address if directly connected. // TODO: Remove this and use global localAddr and relayIP. // Replace w/ a Direct boolean. LocalAddr netip.AddrPort // Local address as seen by the remote. RelayIP byte // Non-zero if we should relay. } var ( // Configuration for this peer. netName string localIP byte localPub bool localAddr netip.AddrPort privateKey []byte // Shared interface for writing. _iface *ifWriter // Shared connection for writing. _conn *connWriter // Counters for sending to each peer. sendCounters [256]uint64 // Duplicate checkers for incoming packets. dupChecks [256]*dupCheck // Channels for incoming control packets. controlPackets [256]chan controlPacket // Channels for incoming peer updates from the hub. peerUpdates [256]chan *m.Peer // Global routing table. routingTable [256]*atomic.Pointer[peerRoute] // TODO: use relay for local address discovery. This should be new stream ID, // managed by a single thread. // localAddr *atomic.Pointer[netip.AddrPort] // relayIP *atomic.Pointer[byte] )