Преглед изворни кода

add egressServices on host model

abhishek9686 пре 5 месеци
родитељ
комит
598eedbbd4
2 измењених фајлова са 58 додато и 58 уклоњено
  1. 26 26
      models/api_host.go
  2. 32 32
      models/host.go

+ 26 - 26
models/api_host.go

@@ -8,30 +8,30 @@ import (
 
 // ApiHost - the host struct for API usage
 type ApiHost struct {
-	ID                  string     `json:"id"`
-	Verbosity           int        `json:"verbosity"`
-	FirewallInUse       string     `json:"firewallinuse"`
-	Version             string     `json:"version"`
-	Name                string     `json:"name"`
-	OS                  string     `json:"os"`
-	Debug               bool       `json:"debug"`
-	IsStaticPort        bool       `json:"isstaticport"`
-	IsStatic            bool       `json:"isstatic"`
-	ListenPort          int        `json:"listenport"`
-	WgPublicListenPort  int        `json:"wg_public_listen_port" yaml:"wg_public_listen_port"`
-	MTU                 int        `json:"mtu"                   yaml:"mtu"`
-	Interfaces          []ApiIface `json:"interfaces"            yaml:"interfaces"`
-	DefaultInterface    string     `json:"defaultinterface"      yaml:"defautlinterface"`
-	EndpointIP          string     `json:"endpointip"            yaml:"endpointip"`
-	EndpointIPv6        string     `json:"endpointipv6"            yaml:"endpointipv6"`
-	PublicKey           string     `json:"publickey"`
-	MacAddress          string     `json:"macaddress"`
-	Nodes               []string   `json:"nodes"`
-	IsDefault           bool       `json:"isdefault"             yaml:"isdefault"`
-	NatType             string     `json:"nat_type"              yaml:"nat_type"`
-	PersistentKeepalive int        `json:"persistentkeepalive"   yaml:"persistentkeepalive"`
-	AutoUpdate          bool       `json:"autoupdate"              yaml:"autoupdate"`
-	ExternalServices    []string   `json:"external_services"`
+	ID                  string              `json:"id"`
+	Verbosity           int                 `json:"verbosity"`
+	FirewallInUse       string              `json:"firewallinuse"`
+	Version             string              `json:"version"`
+	Name                string              `json:"name"`
+	OS                  string              `json:"os"`
+	Debug               bool                `json:"debug"`
+	IsStaticPort        bool                `json:"isstaticport"`
+	IsStatic            bool                `json:"isstatic"`
+	ListenPort          int                 `json:"listenport"`
+	WgPublicListenPort  int                 `json:"wg_public_listen_port" yaml:"wg_public_listen_port"`
+	MTU                 int                 `json:"mtu"                   yaml:"mtu"`
+	Interfaces          []ApiIface          `json:"interfaces"            yaml:"interfaces"`
+	DefaultInterface    string              `json:"defaultinterface"      yaml:"defautlinterface"`
+	EndpointIP          string              `json:"endpointip"            yaml:"endpointip"`
+	EndpointIPv6        string              `json:"endpointipv6"            yaml:"endpointipv6"`
+	PublicKey           string              `json:"publickey"`
+	MacAddress          string              `json:"macaddress"`
+	Nodes               []string            `json:"nodes"`
+	IsDefault           bool                `json:"isdefault"             yaml:"isdefault"`
+	NatType             string              `json:"nat_type"              yaml:"nat_type"`
+	PersistentKeepalive int                 `json:"persistentkeepalive"   yaml:"persistentkeepalive"`
+	AutoUpdate          bool                `json:"autoupdate"              yaml:"autoupdate"`
+	EgressServices      map[string][]string `json:"egress_services"`
 }
 
 // ApiIface - the interface struct for API usage
@@ -79,7 +79,7 @@ func (h *Host) ConvertNMHostToAPI() *ApiHost {
 	a.NatType = h.NatType
 	a.PersistentKeepalive = int(h.PersistentKeepalive.Seconds())
 	a.AutoUpdate = h.AutoUpdate
-	a.ExternalServices = h.ExternalServices
+	a.EgressServices = h.EgressServices
 	return &a
 }
 
@@ -125,6 +125,6 @@ func (a *ApiHost) ConvertAPIHostToNMHost(currentHost *Host) *Host {
 	h.TurnEndpoint = currentHost.TurnEndpoint
 	h.PersistentKeepalive = time.Duration(a.PersistentKeepalive) * time.Second
 	h.AutoUpdate = a.AutoUpdate
-	h.ExternalServices = a.ExternalServices
+	h.EgressServices = a.EgressServices
 	return &h
 }

+ 32 - 32
models/host.go

@@ -41,38 +41,38 @@ const (
 
 // Host - represents a host on the network
 type 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"`
-	WgPublicListenPort  int              `json:"wg_public_listen_port"   yaml:"wg_public_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"`
-	Nodes               []string         `json:"nodes"                   yaml:"nodes"`
-	Interfaces          []Iface          `json:"interfaces"              yaml:"interfaces"`
-	DefaultInterface    string           `json:"defaultinterface"        yaml:"defaultinterface"`
-	EndpointIP          net.IP           `json:"endpointip"              yaml:"endpointip"`
-	EndpointIPv6        net.IP           `json:"endpointipv6"            yaml:"endpointipv6"`
-	IsDocker            bool             `json:"isdocker"                yaml:"isdocker"`
-	IsK8S               bool             `json:"isk8s"                   yaml:"isk8s"`
-	IsStaticPort        bool             `json:"isstaticport"            yaml:"isstaticport"`
-	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"`
-	PersistentKeepalive time.Duration    `json:"persistentkeepalive" swaggertype:"primitive,integer" format:"int64" yaml:"persistentkeepalive"`
-	ExternalServices    []string         `json:"external_services"`
+	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"`
+	WgPublicListenPort  int                 `json:"wg_public_listen_port"   yaml:"wg_public_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"`
+	Nodes               []string            `json:"nodes"                   yaml:"nodes"`
+	Interfaces          []Iface             `json:"interfaces"              yaml:"interfaces"`
+	DefaultInterface    string              `json:"defaultinterface"        yaml:"defaultinterface"`
+	EndpointIP          net.IP              `json:"endpointip"              yaml:"endpointip"`
+	EndpointIPv6        net.IP              `json:"endpointipv6"            yaml:"endpointipv6"`
+	IsDocker            bool                `json:"isdocker"                yaml:"isdocker"`
+	IsK8S               bool                `json:"isk8s"                   yaml:"isk8s"`
+	IsStaticPort        bool                `json:"isstaticport"            yaml:"isstaticport"`
+	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"`
+	PersistentKeepalive time.Duration       `json:"persistentkeepalive" swaggertype:"primitive,integer" format:"int64" yaml:"persistentkeepalive"`
+	EgressServices      map[string][]string `json:"egress_services"`
 }
 
 // FormatBool converts a boolean to a [yes|no] string