netmaker/models/mqtt.go

78 lines
3.1 KiB
Go
Raw Normal View History

package models
2022-11-04 03:54:48 +08:00
import (
2023-01-31 17:33:15 +08:00
"net"
2022-11-04 03:54:48 +08:00
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)
2022-01-16 07:16:44 +08:00
2023-01-06 20:48:25 +08:00
// HostPeerUpdate - struct for host peer updates
2023-01-04 12:34:17 +08:00
type HostPeerUpdate struct {
Host Host `json:"host" bson:"host" yaml:"host"`
NodeAddrs []net.IPNet `json:"nodes_addrs" yaml:"nodes_addrs"`
Server string `json:"server" bson:"server" yaml:"server"`
ServerVersion string `json:"serverversion" bson:"serverversion" yaml:"serverversion"`
ServerAddrs []ServerAddr `json:"serveraddrs" bson:"serveraddrs" yaml:"serveraddrs"`
NodePeers []wgtypes.PeerConfig `json:"peers" bson:"peers" yaml:"peers"`
Peers []wgtypes.PeerConfig
PeerIDs PeerMap `json:"peerids" bson:"peerids" yaml:"peerids"`
HostNetworkInfo HostInfoMap `json:"host_network_info,omitempty" bson:"host_network_info,omitempty" yaml:"host_network_info,omitempty"`
EgressRoutes []EgressNetworkRoutes `json:"egress_network_routes"`
FwUpdate FwUpdate `json:"fw_update"`
2023-01-31 14:21:10 +08:00
}
2023-02-01 20:48:41 +08:00
// IngressInfo - struct for ingress info
2023-01-31 14:21:10 +08:00
type IngressInfo struct {
2023-02-14 00:09:21 +08:00
ExtPeers map[string]ExtClientInfo `json:"ext_peers" yaml:"ext_peers"`
EgressRanges []string `json:"egress_ranges" yaml:"egress_ranges"`
2023-01-31 16:37:22 +08:00
}
2023-02-07 00:18:11 +08:00
// EgressInfo - struct for egress info
2023-02-02 14:22:20 +08:00
type EgressInfo struct {
EgressID string `json:"egress_id" yaml:"egress_id"`
Network net.IPNet `json:"network" yaml:"network"`
EgressGwAddr net.IPNet `json:"egress_gw_addr" yaml:"egress_gw_addr"`
EgressGWCfg EgressGatewayRequest `json:"egress_gateway_cfg" yaml:"egress_gateway_cfg"`
2023-02-02 14:22:20 +08:00
}
// EgressNetworkRoutes - struct for egress network routes for adding routes to peer's interface
type EgressNetworkRoutes struct {
NodeAddr net.IPNet `json:"node_addr"`
EgressRanges []string `json:"egress_ranges"`
}
2023-02-02 14:22:20 +08:00
// PeerRouteInfo - struct for peer info for an ext. client
type PeerRouteInfo struct {
2023-02-01 14:28:11 +08:00
PeerAddr net.IPNet `json:"peer_addr" yaml:"peer_addr"`
PeerKey string `json:"peer_key" yaml:"peer_key"`
Allow bool `json:"allow" yaml:"allow"`
2023-03-14 03:06:07 +08:00
ID string `json:"id,omitempty" yaml:"id,omitempty"`
2023-01-31 16:37:22 +08:00
}
2023-02-01 20:48:41 +08:00
// ExtClientInfo - struct for ext. client and it's peers
2023-01-31 16:37:22 +08:00
type ExtClientInfo struct {
2023-02-02 14:22:20 +08:00
IngGwAddr net.IPNet `json:"ingress_gw_addr" yaml:"ingress_gw_addr"`
2023-02-04 18:02:33 +08:00
Network net.IPNet `json:"network" yaml:"network"`
2023-02-02 14:22:20 +08:00
Masquerade bool `json:"masquerade" yaml:"masquerade"`
ExtPeerAddr net.IPNet `json:"ext_peer_addr" yaml:"ext_peer_addr"`
ExtPeerKey string `json:"ext_peer_key" yaml:"ext_peer_key"`
Peers map[string]PeerRouteInfo `json:"peers" yaml:"peers"`
2023-01-04 12:34:17 +08:00
}
2022-01-26 11:14:31 +08:00
// KeyUpdate - key update struct
type KeyUpdate struct {
2022-01-26 11:14:31 +08:00
Network string `json:"network" bson:"network"`
Interface string `json:"interface" bson:"interface"`
}
// FwUpdate - struct for firewall updates
type FwUpdate struct {
IsEgressGw bool `json:"is_egress_gw"`
EgressInfo map[string]EgressInfo `json:"egress_info"`
}
// FailOverMeReq - struct for failover req
type FailOverMeReq struct {
NodeID string `json:"node_id"`
}