vppn/peer/state.go
2025-01-31 21:32:47 +01:00

30 lines
801 B
Go

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