Browse Source

add public port to api model

Abhishek Kondur 2 years ago
parent
commit
f19b33a84c
2 changed files with 4 additions and 3 deletions
  1. 2 3
      logic/hosts.go
  2. 2 0
      models/api_host.go

+ 2 - 3
logic/hosts.go

@@ -133,9 +133,8 @@ func UpdateHost(newHost, currentHost *models.Host) {
 	if newHost.ProxyListenPort == 0 {
 	if newHost.ProxyListenPort == 0 {
 		newHost.ProxyListenPort = currentHost.ProxyListenPort
 		newHost.ProxyListenPort = currentHost.ProxyListenPort
 	}
 	}
-	if newHost.PublicListenPort == 0 {
-		newHost.PublicListenPort = currentHost.PublicListenPort
-	}
+	newHost.PublicListenPort = currentHost.PublicListenPort
+
 }
 }
 
 
 // UpdateHostFromClient - used for updating host on server with update recieved from client
 // UpdateHostFromClient - used for updating host on server with update recieved from client

+ 2 - 0
models/api_host.go

@@ -15,6 +15,7 @@ type ApiHost struct {
 	ListenPort       int      `json:"listenport"`
 	ListenPort       int      `json:"listenport"`
 	LocalListenPort  int      `json:"locallistenport"`
 	LocalListenPort  int      `json:"locallistenport"`
 	ProxyListenPort  int      `json:"proxy_listen_port"`
 	ProxyListenPort  int      `json:"proxy_listen_port"`
+	PublicListenPort int      `json:"public_listen_port" yaml:"public_listen_port"`
 	MTU              int      `json:"mtu" yaml:"mtu"`
 	MTU              int      `json:"mtu" yaml:"mtu"`
 	Interfaces       []Iface  `json:"interfaces" yaml:"interfaces"`
 	Interfaces       []Iface  `json:"interfaces" yaml:"interfaces"`
 	DefaultInterface string   `json:"defaultinterface" yaml:"defautlinterface"`
 	DefaultInterface string   `json:"defaultinterface" yaml:"defautlinterface"`
@@ -55,6 +56,7 @@ func (h *Host) ConvertNMHostToAPI() *ApiHost {
 	a.OS = h.OS
 	a.OS = h.OS
 	a.Nodes = h.Nodes
 	a.Nodes = h.Nodes
 	a.ProxyEnabled = h.ProxyEnabled
 	a.ProxyEnabled = h.ProxyEnabled
+	a.PublicListenPort = h.PublicListenPort
 	a.ProxyListenPort = h.ProxyListenPort
 	a.ProxyListenPort = h.ProxyListenPort
 	a.PublicKey = h.PublicKey.String()
 	a.PublicKey = h.PublicKey.String()
 	a.Verbosity = h.Verbosity
 	a.Verbosity = h.Verbosity