mqtt.go 3.5 KB

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