mqtt.go 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. NodeAddrs []net.IPNet `json:"nodes_addrs" yaml:"nodes_addrs"`
  10. Server string `json:"server" bson:"server" yaml:"server"`
  11. ServerVersion string `json:"serverversion" bson:"serverversion" yaml:"serverversion"`
  12. ServerAddrs []ServerAddr `json:"serveraddrs" bson:"serveraddrs" yaml:"serveraddrs"`
  13. NodePeers []wgtypes.PeerConfig `json:"peers" bson:"peers" yaml:"peers"`
  14. Peers []wgtypes.PeerConfig
  15. PeerIDs PeerMap `json:"peerids" bson:"peerids" yaml:"peerids"`
  16. EndpointDetection bool `json:"endpointdetection" yaml:"endpointdetection"`
  17. HostNetworkInfo HostInfoMap `json:"host_network_info,omitempty" bson:"host_network_info,omitempty" yaml:"host_network_info,omitempty"`
  18. EgressRoutes []EgressNetworkRoutes `json:"egress_network_routes"`
  19. FwUpdate FwUpdate `json:"fw_update"`
  20. }
  21. // IngressInfo - struct for ingress info
  22. type IngressInfo struct {
  23. ExtPeers map[string]ExtClientInfo `json:"ext_peers" yaml:"ext_peers"`
  24. EgressRanges []string `json:"egress_ranges" yaml:"egress_ranges"`
  25. }
  26. // EgressInfo - struct for egress info
  27. type EgressInfo struct {
  28. EgressID string `json:"egress_id" yaml:"egress_id"`
  29. Network net.IPNet `json:"network" yaml:"network"`
  30. EgressGwAddr net.IPNet `json:"egress_gw_addr" yaml:"egress_gw_addr"`
  31. EgressGWCfg EgressGatewayRequest `json:"egress_gateway_cfg" yaml:"egress_gateway_cfg"`
  32. }
  33. // EgressNetworkRoutes - struct for egress network routes for adding routes to peer's interface
  34. type EgressNetworkRoutes struct {
  35. NodeAddr net.IPNet `json:"node_addr"`
  36. EgressRanges []string `json:"egress_ranges"`
  37. }
  38. // PeerRouteInfo - struct for peer info for an ext. client
  39. type PeerRouteInfo struct {
  40. PeerAddr net.IPNet `json:"peer_addr" yaml:"peer_addr"`
  41. PeerKey string `json:"peer_key" yaml:"peer_key"`
  42. Allow bool `json:"allow" yaml:"allow"`
  43. ID string `json:"id,omitempty" yaml:"id,omitempty"`
  44. }
  45. // ExtClientInfo - struct for ext. client and it's peers
  46. type ExtClientInfo struct {
  47. IngGwAddr net.IPNet `json:"ingress_gw_addr" yaml:"ingress_gw_addr"`
  48. Network net.IPNet `json:"network" yaml:"network"`
  49. Masquerade bool `json:"masquerade" yaml:"masquerade"`
  50. ExtPeerAddr net.IPNet `json:"ext_peer_addr" yaml:"ext_peer_addr"`
  51. ExtPeerKey string `json:"ext_peer_key" yaml:"ext_peer_key"`
  52. Peers map[string]PeerRouteInfo `json:"peers" yaml:"peers"`
  53. }
  54. // KeyUpdate - key update struct
  55. type KeyUpdate struct {
  56. Network string `json:"network" bson:"network"`
  57. Interface string `json:"interface" bson:"interface"`
  58. }
  59. // FwUpdate - struct for firewall updates
  60. type FwUpdate struct {
  61. IsEgressGw bool `json:"is_egress_gw"`
  62. EgressInfo map[string]EgressInfo `json:"egress_info"`
  63. }