vppn/peer/state.go
2025-01-29 11:45:09 +01:00

30 lines
758 B
Go

package peer
import (
"net/netip"
"time"
)
type peerRoute struct {
IP byte // VPN IP of peer (last byte).
Up bool // True if data can be sent on the route.
Relay bool // True if the peer is a relay.
Direct bool // True if this is a direct connection.
PubSignKey []byte
ControlCipher *controlCipher
DataCipher *dataCipher
RemoteAddr netip.AddrPort // Remote address if directly connected.
Counter *uint64 // For sending to. Atomic access only.
DupCheck *dupCheck // For receiving from. Not safe for concurrent use.
}
func newPeerRoute(ip byte) *peerRoute {
counter := uint64(time.Now().Unix()<<30 + 1)
return &peerRoute{
IP: ip,
Counter: &counter,
DupCheck: newDupCheck(0),
}
}