2
0

mqtt.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package models
  2. import (
  3. "net"
  4. "golang.zx2c4.com/wireguard/wgctrl/wgtypes"
  5. )
  6. type HostPeerInfo struct {
  7. NetworkPeerIDs map[NetworkID]PeerMap `json:"network_peers"`
  8. }
  9. // HostPeerUpdate - struct for host peer updates
  10. type HostPeerUpdate struct {
  11. Host Host `json:"host"`
  12. ChangeDefaultGw bool `json:"change_default_gw"`
  13. DefaultGwIp net.IP `json:"default_gw_ip"`
  14. IsInternetGw bool `json:"is_inet_gw"`
  15. NodeAddrs []net.IPNet `json:"nodes_addrs"`
  16. Server string `json:"server"`
  17. ServerVersion string `json:"serverversion"`
  18. ServerAddrs []ServerAddr `json:"serveraddrs"`
  19. NodePeers []wgtypes.PeerConfig `json:"node_peers"`
  20. Peers []wgtypes.PeerConfig `json:"host_peers"`
  21. PeerIDs PeerMap `json:"peerids"`
  22. HostNetworkInfo HostInfoMap `json:"host_network_info,omitempty"`
  23. EgressRoutes []EgressNetworkRoutes `json:"egress_network_routes"`
  24. FwUpdate FwUpdate `json:"fw_update"`
  25. ReplacePeers bool `json:"replace_peers"`
  26. NameServers []string `json:"name_servers"`
  27. ServerConfig
  28. OldPeerUpdateFields
  29. }
  30. type OldPeerUpdateFields struct {
  31. NodePeers []wgtypes.PeerConfig `json:"peers" bson:"peers" yaml:"peers"`
  32. OldPeers []wgtypes.PeerConfig `json:"Peers"`
  33. EndpointDetection bool `json:"endpoint_detection"`
  34. }
  35. type FwRule struct {
  36. SrcIP net.IPNet `json:"src_ip"`
  37. DstIP net.IPNet `json:"dst_ip"`
  38. AllowedProtocol Protocol `json:"allowed_protocols"` // tcp, udp, etc.
  39. AllowedPorts []string `json:"allowed_ports"`
  40. Allow bool `json:"allow"`
  41. }
  42. // IngressInfo - struct for ingress info
  43. type IngressInfo struct {
  44. IngressID string `json:"ingress_id"`
  45. Network net.IPNet `json:"network"`
  46. Network6 net.IPNet `json:"network6"`
  47. StaticNodeIps []net.IP `json:"static_node_ips"`
  48. Rules []FwRule `json:"rules"`
  49. AllowAll bool `json:"allow_all"`
  50. EgressRanges []net.IPNet `json:"egress_ranges"`
  51. EgressRanges6 []net.IPNet `json:"egress_ranges6"`
  52. }
  53. // EgressInfo - struct for egress info
  54. type EgressInfo struct {
  55. EgressID string `json:"egress_id" yaml:"egress_id"`
  56. Network net.IPNet `json:"network" yaml:"network"`
  57. EgressGwAddr net.IPNet `json:"egress_gw_addr" yaml:"egress_gw_addr"`
  58. Network6 net.IPNet `json:"network6" yaml:"network6"`
  59. EgressGwAddr6 net.IPNet `json:"egress_gw_addr6" yaml:"egress_gw_addr6"`
  60. EgressGWCfg EgressGatewayRequest `json:"egress_gateway_cfg" yaml:"egress_gateway_cfg"`
  61. }
  62. // EgressNetworkRoutes - struct for egress network routes for adding routes to peer's interface
  63. type EgressNetworkRoutes struct {
  64. EgressGwAddr net.IPNet `json:"egress_gw_addr" yaml:"egress_gw_addr"`
  65. EgressGwAddr6 net.IPNet `json:"egress_gw_addr6" yaml:"egress_gw_addr6"`
  66. NodeAddr net.IPNet `json:"node_addr"`
  67. NodeAddr6 net.IPNet `json:"node_addr6"`
  68. EgressRanges []string `json:"egress_ranges"`
  69. EgressRangesWithMetric []EgressRangeMetric `json:"egress_ranges_metric"`
  70. }
  71. // PeerRouteInfo - struct for peer info for an ext. client
  72. type PeerRouteInfo struct {
  73. PeerAddr net.IPNet `json:"peer_addr" yaml:"peer_addr"`
  74. PeerKey string `json:"peer_key" yaml:"peer_key"`
  75. Allow bool `json:"allow" yaml:"allow"`
  76. ID string `json:"id,omitempty" yaml:"id,omitempty"`
  77. }
  78. // ExtClientInfo - struct for ext. client and it's peers
  79. type ExtClientInfo struct {
  80. IngGwAddr net.IPNet `json:"ingress_gw_addr" yaml:"ingress_gw_addr"`
  81. Network net.IPNet `json:"network" yaml:"network"`
  82. Masquerade bool `json:"masquerade" yaml:"masquerade"`
  83. ExtPeerAddr net.IPNet `json:"ext_peer_addr" yaml:"ext_peer_addr"`
  84. ExtPeerKey string `json:"ext_peer_key" yaml:"ext_peer_key"`
  85. Peers map[string]PeerRouteInfo `json:"peers" yaml:"peers"`
  86. }
  87. // KeyUpdate - key update struct
  88. type KeyUpdate struct {
  89. Network string `json:"network" bson:"network"`
  90. Interface string `json:"interface" bson:"interface"`
  91. }
  92. // FwUpdate - struct for firewall updates
  93. type FwUpdate struct {
  94. AllowAll bool `json:"allow_all"`
  95. AllowedNetworks []net.IPNet `json:"networks"`
  96. IsEgressGw bool `json:"is_egress_gw"`
  97. IsIngressGw bool `json:"is_ingress_gw"`
  98. EgressInfo map[string]EgressInfo `json:"egress_info"`
  99. IngressInfo map[string]IngressInfo `json:"ingress_info"`
  100. AclRules map[string]AclRule `json:"acl_rules"`
  101. }
  102. // FailOverMeReq - struct for failover req
  103. type FailOverMeReq struct {
  104. NodeID string `json:"node_id"`
  105. }