Refactor - now wireguard based. (#7)
This commit is contained in:
22
peer/control/role.go
Normal file
22
peer/control/role.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package control
|
||||
|
||||
import "net/netip"
|
||||
|
||||
// Role identifies a peer's role in a ping exchange with a specific remote peer.
|
||||
type Role string
|
||||
|
||||
const (
|
||||
// Client initiates pings and measures RTT.
|
||||
Client Role = "CLIENT"
|
||||
// Server responds to pings.
|
||||
Server Role = "SERVER"
|
||||
)
|
||||
|
||||
// RoleFor returns the Role of local relative to remote.
|
||||
// The peer with the lower VPN IP is the client.
|
||||
func RoleFor(local, remote netip.Addr) Role {
|
||||
if local.Compare(remote) < 0 {
|
||||
return Client
|
||||
}
|
||||
return Server
|
||||
}
|
||||
Reference in New Issue
Block a user