mqtt.go 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package models
  2. import (
  3. "net"
  4. "golang.zx2c4.com/wireguard/wgctrl/wgtypes"
  5. )
  6. type NodePeersInfo struct {
  7. Peers []wgtypes.PeerConfig `json:"peers" yaml:"peers"`
  8. PeerIDs PeerMap `json:"peerids" yaml:"peerids"`
  9. }
  10. // HostPeerUpdate - struct for host peer updates
  11. type HostPeerUpdate struct {
  12. Host Host `json:"host" bson:"host" yaml:"host"`
  13. Server string `json:"server" bson:"server" yaml:"server"`
  14. ServerVersion string `json:"serverversion" bson:"serverversion" yaml:"serverversion"`
  15. Peers []wgtypes.PeerConfig `json:"peers" yaml:"peers"`
  16. HostNetworkInfo HostInfoMap `json:"host_network_info,omitempty" bson:"host_network_info,omitempty" yaml:"host_network_info,omitempty"`
  17. }
  18. // IngressInfo - struct for ingress info
  19. type IngressInfo struct {
  20. ExtPeers map[string]ExtClientInfo `json:"ext_peers" yaml:"ext_peers"`
  21. EgressRanges []string `json:"egress_ranges" yaml:"egress_ranges"`
  22. }
  23. // EgressInfo - struct for egress info
  24. type EgressInfo struct {
  25. EgressID string `json:"egress_id" yaml:"egress_id"`
  26. Network net.IPNet `json:"network" yaml:"network"`
  27. EgressGwAddr net.IPNet `json:"egress_gw_addr" yaml:"egress_gw_addr"`
  28. GwPeers map[string]PeerRouteInfo `json:"gateway_peers" yaml:"gateway_peers"`
  29. EgressGWCfg EgressGatewayRequest `json:"egress_gateway_cfg" yaml:"egress_gateway_cfg"`
  30. }
  31. // PeerRouteInfo - struct for peer info for an ext. client
  32. type PeerRouteInfo struct {
  33. PeerAddr net.IPNet `json:"peer_addr" yaml:"peer_addr"`
  34. PeerKey string `json:"peer_key" yaml:"peer_key"`
  35. Allow bool `json:"allow" yaml:"allow"`
  36. ID string `json:"id,omitempty" yaml:"id,omitempty"`
  37. }
  38. // ExtClientInfo - struct for ext. client and it's peers
  39. type ExtClientInfo struct {
  40. IngGwAddr net.IPNet `json:"ingress_gw_addr" yaml:"ingress_gw_addr"`
  41. Network net.IPNet `json:"network" yaml:"network"`
  42. Masquerade bool `json:"masquerade" yaml:"masquerade"`
  43. ExtPeerAddr net.IPNet `json:"ext_peer_addr" yaml:"ext_peer_addr"`
  44. ExtPeerKey string `json:"ext_peer_key" yaml:"ext_peer_key"`
  45. Peers map[string]PeerRouteInfo `json:"peers" yaml:"peers"`
  46. }
  47. // KeyUpdate - key update struct
  48. type KeyUpdate struct {
  49. Network string `json:"network" bson:"network"`
  50. Interface string `json:"interface" bson:"interface"`
  51. }
  52. // PeerMqActionType - peer update action type
  53. type PeerMqActionType string
  54. const (
  55. // AddPeer - peer mq action type for adding peers
  56. AddPeer PeerMqActionType = "ADD_PEER"
  57. // UpdatePeer - peer mq action type for updating peers
  58. UpdatePeer PeerMqActionType = "UPDATE_PEER"
  59. // RemovePeer - peer mq action type for removing peers
  60. RemovePeer PeerMqActionType = "REMOVE_PEER"
  61. )
  62. // PeerAction - struct for mq peer actions
  63. type PeerAction struct {
  64. Action PeerMqActionType `json:"action"`
  65. Peers []wgtypes.PeerConfig `json:"peers"`
  66. }
  67. // FwUpdate - struct for firewall updates
  68. type FwUpdate struct {
  69. IsIngressGw bool `json:"is_ingress_gw"`
  70. IsEgressGw bool `json:"is_egress_gw"`
  71. IngressInfo IngressInfo `json:"ingress_info"`
  72. EgressInfo map[string]EgressInfo `json:"egress_info"`
  73. }