| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 | package modelsimport (	"net"	"net/netip"	"github.com/google/uuid"	"golang.zx2c4.com/wireguard/wgctrl/wgtypes")// OS_Types - list of OS types Netmaker cares aboutvar OS_Types = struct {	Linux   string	Windows string	Mac     string	FreeBSD string	IoT     string}{	Linux:   "linux",	Windows: "windows",	Mac:     "darwin",	FreeBSD: "freebsd",	IoT:     "iot",}// NAT_Types - the type of NAT in which a HOST currently resides (simplified)var NAT_Types = struct {	Public     string	Symmetric  string	Asymmetric string	Double     string}{	Public:     "public",	Symmetric:  "symmetric",	Asymmetric: "asymmetric",	Double:     "double",}// WIREGUARD_INTERFACE name of wireguard interfaceconst WIREGUARD_INTERFACE = "netmaker"// Host - represents a host on the networktype Host struct {	ID               uuid.UUID        `json:"id" yaml:"id"`	Verbosity        int              `json:"verbosity" yaml:"verbosity"`	FirewallInUse    string           `json:"firewallinuse" yaml:"firewallinuse"`	Version          string           `json:"version" yaml:"version"`	IPForwarding     bool             `json:"ipforwarding" yaml:"ipforwarding"`	DaemonInstalled  bool             `json:"daemoninstalled" yaml:"daemoninstalled"`	AutoUpdate       bool             `json:"autoupdate" yaml:"autoupdate"`	HostPass         string           `json:"hostpass" yaml:"hostpass"`	Name             string           `json:"name" yaml:"name"`	OS               string           `json:"os" yaml:"os"`	Interface        string           `json:"interface" yaml:"interface"`	Debug            bool             `json:"debug" yaml:"debug"`	ListenPort       int              `json:"listenport" yaml:"listenport"`	PublicListenPort int              `json:"public_listen_port" yaml:"public_listen_port"`	ProxyListenPort  int              `json:"proxy_listen_port" yaml:"proxy_listen_port"`	MTU              int              `json:"mtu" yaml:"mtu"`	PublicKey        wgtypes.Key      `json:"publickey" yaml:"publickey"`	MacAddress       net.HardwareAddr `json:"macaddress" yaml:"macaddress"`	TrafficKeyPublic []byte           `json:"traffickeypublic" yaml:"traffickeypublic"`	InternetGateway  net.UDPAddr      `json:"internetgateway" yaml:"internetgateway"`	Nodes            []string         `json:"nodes" yaml:"nodes"`	IsRelayed        bool             `json:"isrelayed" yaml:"isrelayed"`	RelayedBy        string           `json:"relayed_by" yaml:"relayed_by"`	IsRelay          bool             `json:"isrelay" yaml:"isrelay"`	RelayedHosts     []string         `json:"relay_hosts" yaml:"relay_hosts"`	Interfaces       []Iface          `json:"interfaces" yaml:"interfaces"`	DefaultInterface string           `json:"defaultinterface" yaml:"defaultinterface"`	EndpointIP       net.IP           `json:"endpointip" yaml:"endpointip"`	ProxyEnabled     bool             `json:"proxy_enabled" yaml:"proxy_enabled"`	ProxyEnabledSet  bool             `json:"proxy_enabled_updated" yaml:"proxy_enabled_updated"`	IsDocker         bool             `json:"isdocker" yaml:"isdocker"`	IsK8S            bool             `json:"isk8s" yaml:"isk8s"`	IsStatic         bool             `json:"isstatic" yaml:"isstatic"`	IsDefault        bool             `json:"isdefault" yaml:"isdefault"`	NatType          string           `json:"nat_type,omitempty" yaml:"nat_type,omitempty"`	TurnEndpoint     *netip.AddrPort  `json:"turn_endpoint,omitempty" yaml:"turn_endpoint,omitempty"`}// FormatBool converts a boolean to a [yes|no] stringfunc FormatBool(b bool) string {	s := "no"	if b {		s = "yes"	}	return s}// ParseBool parses a [yes|no] string to boolean valuefunc ParseBool(s string) bool {	b := false	if s == "yes" {		b = true	}	return b}// HostMqAction - type for host update actiontype HostMqAction stringconst (	// UpdateHost - constant for host update action	UpdateHost = "UPDATE_HOST"	// DeleteHost - constant for host delete action	DeleteHost = "DELETE_HOST"	// JoinHostToNetwork - constant for host network join action	JoinHostToNetwork = "JOIN_HOST_TO_NETWORK"	// Acknowledgement - ACK response for hosts	Acknowledgement = "ACK"	// RequestAck - request an ACK	RequestAck = "REQ_ACK"	// CheckIn - update last check in times and public address and interfaces	CheckIn = "CHECK_IN"	// UpdateKeys - update wireguard private/public keys	UpdateKeys = "UPDATE_KEYS")// HostUpdate - struct for host updatetype HostUpdate struct {	Action HostMqAction	Host   Host	Node   Node}// RegisterMsg - login message struct for hosts to join via SSO logintype RegisterMsg struct {	RegisterHost Host   `json:"host"`	Network      string `json:"network,omitempty"`	User         string `json:"user,omitempty"`	Password     string `json:"password,omitempty"`	JoinAll      bool   `json:"join_all,omitempty"`}
 |