peer.go 904 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package models
  2. import (
  3. "context"
  4. "net"
  5. "golang.zx2c4.com/wireguard/wgctrl/wgtypes"
  6. )
  7. const (
  8. NmProxyPort = 51722
  9. DefaultCIDR = "127.0.0.1/8"
  10. )
  11. // ConnConfig is a peer Connection configuration
  12. type ConnConfig struct {
  13. // Key is a public key of a remote peer
  14. Key string
  15. IsExtClient bool
  16. IsRelayed bool
  17. RelayedEndpoint *net.UDPAddr
  18. IsAttachedExtClient bool
  19. PeerConf *wgtypes.PeerConfig
  20. StopConn context.CancelFunc
  21. RemoteConn *net.UDPAddr
  22. LocalConn net.Conn
  23. }
  24. type RemotePeer struct {
  25. PeerKey string
  26. Interface string
  27. Endpoint *net.UDPAddr
  28. IsExtClient bool
  29. IsAttachedExtClient bool
  30. }
  31. type ExtClientPeer struct {
  32. CancelFunc context.CancelFunc
  33. CommChan chan *net.UDPAddr
  34. }
  35. type WgIfaceConf struct {
  36. Iface *wgtypes.Device
  37. PeerMap map[string]*ConnConfig
  38. }