mqtt.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. DnsNameservers []Nameserver `json:"dns_nameservers"`
  28. ServerConfig
  29. OldPeerUpdateFields
  30. }
  31. type Nameserver struct {
  32. IPs []string `json:"ips"`
  33. MatchDomain string `json:"match_domain"`
  34. }
  35. type OldPeerUpdateFields struct {
  36. NodePeers []wgtypes.PeerConfig `json:"peers" bson:"peers" yaml:"peers"`
  37. OldPeers []wgtypes.PeerConfig `json:"Peers"`
  38. EndpointDetection bool `json:"endpoint_detection"`
  39. }
  40. type FwRule struct {
  41. SrcIP net.IPNet `json:"src_ip"`
  42. DstIP net.IPNet `json:"dst_ip"`
  43. AllowedProtocol Protocol `json:"allowed_protocols"` // tcp, udp, etc.
  44. AllowedPorts []string `json:"allowed_ports"`
  45. Allow bool `json:"allow"`
  46. }
  47. // IngressInfo - struct for ingress info
  48. type IngressInfo struct {
  49. IngressID string `json:"ingress_id"`
  50. Network net.IPNet `json:"network"`
  51. Network6 net.IPNet `json:"network6"`
  52. StaticNodeIps []net.IP `json:"static_node_ips"`
  53. Rules []FwRule `json:"rules"`
  54. EgressRanges []net.IPNet `json:"egress_ranges"`
  55. EgressRanges6 []net.IPNet `json:"egress_ranges6"`
  56. }
  57. // EgressInfo - struct for egress info
  58. type EgressInfo struct {
  59. EgressID string `json:"egress_id" yaml:"egress_id"`
  60. Network net.IPNet `json:"network" yaml:"network"`
  61. EgressGwAddr net.IPNet `json:"egress_gw_addr" yaml:"egress_gw_addr"`
  62. Network6 net.IPNet `json:"network6" yaml:"network6"`
  63. EgressGwAddr6 net.IPNet `json:"egress_gw_addr6" yaml:"egress_gw_addr6"`
  64. EgressGWCfg EgressGatewayRequest `json:"egress_gateway_cfg" yaml:"egress_gateway_cfg"`
  65. EgressFwRules map[string]AclRule `json:"egress_fw_rules"`
  66. }
  67. // EgressNetworkRoutes - struct for egress network routes for adding routes to peer's interface
  68. type EgressNetworkRoutes struct {
  69. PeerKey string `json:"peer_key"`
  70. EgressGwAddr net.IPNet `json:"egress_gw_addr" yaml:"egress_gw_addr"`
  71. EgressGwAddr6 net.IPNet `json:"egress_gw_addr6" yaml:"egress_gw_addr6"`
  72. NodeAddr net.IPNet `json:"node_addr"`
  73. NodeAddr6 net.IPNet `json:"node_addr6"`
  74. EgressRanges []string `json:"egress_ranges"`
  75. EgressRangesWithMetric []EgressRangeMetric `json:"egress_ranges_metric"`
  76. Network string `json:"network"`
  77. }
  78. // PeerRouteInfo - struct for peer info for an ext. client
  79. type PeerRouteInfo struct {
  80. PeerAddr net.IPNet `json:"peer_addr" yaml:"peer_addr"`
  81. PeerKey string `json:"peer_key" yaml:"peer_key"`
  82. Allow bool `json:"allow" yaml:"allow"`
  83. ID string `json:"id,omitempty" yaml:"id,omitempty"`
  84. }
  85. // ExtClientInfo - struct for ext. client and it's peers
  86. type ExtClientInfo struct {
  87. IngGwAddr net.IPNet `json:"ingress_gw_addr" yaml:"ingress_gw_addr"`
  88. Network net.IPNet `json:"network" yaml:"network"`
  89. Masquerade bool `json:"masquerade" yaml:"masquerade"`
  90. ExtPeerAddr net.IPNet `json:"ext_peer_addr" yaml:"ext_peer_addr"`
  91. ExtPeerKey string `json:"ext_peer_key" yaml:"ext_peer_key"`
  92. Peers map[string]PeerRouteInfo `json:"peers" yaml:"peers"`
  93. }
  94. // KeyUpdate - key update struct
  95. type KeyUpdate struct {
  96. Network string `json:"network" bson:"network"`
  97. Interface string `json:"interface" bson:"interface"`
  98. }
  99. // FwUpdate - struct for firewall updates
  100. type FwUpdate struct {
  101. AllowAll bool `json:"allow_all"`
  102. AllowedNetworks []AclRule `json:"networks"`
  103. IsEgressGw bool `json:"is_egress_gw"`
  104. IsIngressGw bool `json:"is_ingress_gw"`
  105. EgressInfo map[string]EgressInfo `json:"egress_info"`
  106. IngressInfo map[string]IngressInfo `json:"ingress_info"`
  107. AclRules map[string]AclRule `json:"acl_rules"`
  108. }
  109. // FailOverMeReq - struct for failover req
  110. type FailOverMeReq struct {
  111. NodeID string `json:"node_id"`
  112. }