mqtt.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. ChangeDefaultGw bool `json:"change_default_gw"`
  10. DefaultGwIp net.IP `json:"default_gw_ip"`
  11. IsInternetGw bool `json:"is_inet_gw"`
  12. NodeAddrs []net.IPNet `json:"nodes_addrs" yaml:"nodes_addrs"`
  13. Server string `json:"server" bson:"server" yaml:"server"`
  14. ServerVersion string `json:"serverversion" bson:"serverversion" yaml:"serverversion"`
  15. ServerAddrs []ServerAddr `json:"serveraddrs" bson:"serveraddrs" yaml:"serveraddrs"`
  16. NodePeers []wgtypes.PeerConfig `json:"peers" bson:"peers" yaml:"peers"`
  17. Peers []wgtypes.PeerConfig
  18. PeerIDs PeerMap `json:"peerids" bson:"peerids" yaml:"peerids"`
  19. HostNetworkInfo HostInfoMap `json:"host_network_info,omitempty" bson:"host_network_info,omitempty" yaml:"host_network_info,omitempty"`
  20. EgressRoutes []EgressNetworkRoutes `json:"egress_network_routes"`
  21. FwUpdate FwUpdate `json:"fw_update"`
  22. ReplacePeers bool `json:"replace_peers"`
  23. EndpointDetection bool `json:"endpoint_detection"`
  24. }
  25. type FwRule struct {
  26. SrcIp net.IP
  27. DstIP net.IP
  28. Allow bool
  29. }
  30. // IngressInfo - struct for ingress info
  31. type IngressInfo struct {
  32. IngressID string `json:"ingress_id"`
  33. Network net.IPNet `json:"network"`
  34. Network6 net.IPNet `json:"network6"`
  35. StaticNodeIps []net.IP `json:"static_node_ips"`
  36. Rules []FwRule `json:"rules"`
  37. AllowAll bool `json:"allow_all"`
  38. }
  39. // EgressInfo - struct for egress info
  40. type EgressInfo struct {
  41. EgressID string `json:"egress_id" yaml:"egress_id"`
  42. Network net.IPNet `json:"network" yaml:"network"`
  43. EgressGwAddr net.IPNet `json:"egress_gw_addr" yaml:"egress_gw_addr"`
  44. Network6 net.IPNet `json:"network6" yaml:"network6"`
  45. EgressGwAddr6 net.IPNet `json:"egress_gw_addr6" yaml:"egress_gw_addr6"`
  46. EgressGWCfg EgressGatewayRequest `json:"egress_gateway_cfg" yaml:"egress_gateway_cfg"`
  47. }
  48. // EgressNetworkRoutes - struct for egress network routes for adding routes to peer's interface
  49. type EgressNetworkRoutes struct {
  50. EgressGwAddr net.IPNet `json:"egress_gw_addr" yaml:"egress_gw_addr"`
  51. EgressGwAddr6 net.IPNet `json:"egress_gw_addr6" yaml:"egress_gw_addr6"`
  52. NodeAddr net.IPNet `json:"node_addr"`
  53. NodeAddr6 net.IPNet `json:"node_addr6"`
  54. EgressRanges []string `json:"egress_ranges"`
  55. }
  56. // PeerRouteInfo - struct for peer info for an ext. client
  57. type PeerRouteInfo struct {
  58. PeerAddr net.IPNet `json:"peer_addr" yaml:"peer_addr"`
  59. PeerKey string `json:"peer_key" yaml:"peer_key"`
  60. Allow bool `json:"allow" yaml:"allow"`
  61. ID string `json:"id,omitempty" yaml:"id,omitempty"`
  62. }
  63. // ExtClientInfo - struct for ext. client and it's peers
  64. type ExtClientInfo struct {
  65. IngGwAddr net.IPNet `json:"ingress_gw_addr" yaml:"ingress_gw_addr"`
  66. Network net.IPNet `json:"network" yaml:"network"`
  67. Masquerade bool `json:"masquerade" yaml:"masquerade"`
  68. ExtPeerAddr net.IPNet `json:"ext_peer_addr" yaml:"ext_peer_addr"`
  69. ExtPeerKey string `json:"ext_peer_key" yaml:"ext_peer_key"`
  70. Peers map[string]PeerRouteInfo `json:"peers" yaml:"peers"`
  71. }
  72. // KeyUpdate - key update struct
  73. type KeyUpdate struct {
  74. Network string `json:"network" bson:"network"`
  75. Interface string `json:"interface" bson:"interface"`
  76. }
  77. // FwUpdate - struct for firewall updates
  78. type FwUpdate struct {
  79. IsEgressGw bool `json:"is_egress_gw"`
  80. IsIngressGw bool `json:"is_ingress_gw"`
  81. EgressInfo map[string]EgressInfo `json:"egress_info"`
  82. IngressInfo map[string]IngressInfo `json:"ingress_info"`
  83. }
  84. // FailOverMeReq - struct for failover req
  85. type FailOverMeReq struct {
  86. NodeID string `json:"node_id"`
  87. }