Переглянути джерело

host updates inital commit

Abhishek Kondur 2 роки тому
батько
коміт
7845f757ca
3 змінених файлів з 17 додано та 16 видалено
  1. 15 0
      logic/hosts.go
  2. 1 13
      mq/dynsec_helper.go
  3. 1 3
      mq/handlers.go

+ 15 - 0
logic/hosts.go

@@ -133,6 +133,21 @@ func UpdateHost(newHost, currentHost *models.Host) {
 	}
 }
 
+func UpdateHostFromClient(newHost, currHost *models.Host) {
+
+	if newHost.ListenPort != 0 {
+		currHost.ListenPort = newHost.ListenPort
+	}
+	if newHost.ProxyListenPort != 0 {
+		currHost.ProxyListenPort = newHost.ProxyListenPort
+	}
+	currHost.ProxyEnabled = newHost.ProxyEnabled
+	currHost.DaemonInstalled = newHost.DaemonInstalled
+	currHost.Debug = newHost.Debug
+	currHost.Verbosity = newHost.Verbosity
+	currHost.Version = newHost.Version
+}
+
 // UpsertHost - upserts into DB a given host model, does not check for existence*
 func UpsertHost(h *models.Host) error {
 	data, err := json.Marshal(h)

+ 1 - 13
mq/dynsec_helper.go

@@ -179,7 +179,7 @@ func fetchHostAcls(hostID string) []Acl {
 			Allow:    true,
 		},
 		{
-			AclType:  "publishClientReceive",
+			AclType:  "publishClientSend",
 			Topic:    fmt.Sprintf("host/update/%s", hostID),
 			Priority: -1,
 			Allow:    true,
@@ -202,12 +202,6 @@ func FetchNetworkAcls(network string) []Acl {
 			Priority: -1,
 			Allow:    true,
 		},
-		{
-			AclType:  "publishClientReceive",
-			Topic:    fmt.Sprintf("proxy/%s/#", network),
-			Priority: -1,
-			Allow:    true,
-		},
 		{
 			AclType:  "subscribePattern",
 			Topic:    "#",
@@ -299,12 +293,6 @@ func fetchServerAcls() []Acl {
 			Priority: -1,
 			Allow:    true,
 		},
-		{
-			AclType:  "publishClientSend",
-			Topic:    "proxy/#",
-			Priority: -1,
-			Allow:    true,
-		},
 		{
 			AclType:  "publishClientSend",
 			Topic:    "peers/host/#",

+ 1 - 3
mq/handlers.go

@@ -141,18 +141,16 @@ func UpdateHost(client mqtt.Client, msg mqtt.Message) {
 			logger.Log(1, "error unmarshaling payload ", err.Error())
 			return
 		}
-		// ifaceDelta := logic.IfaceDelta(&currentHost, newNode)
 		// if servercfg.Is_EE && ifaceDelta {
 		// 	if err = logic.EnterpriseResetAllPeersFailovers(currentHost.ID.String(), currentHost.Network); err != nil {
 		// 		logger.Log(1, "failed to reset failover list during node update", currentHost.ID.String(), currentHost.Network)
 		// 	}
 		// }
-		logic.UpdateHost(&newHost, currentHost)
+		logic.UpdateHostFromClient(&newHost, currentHost)
 		if err := logic.UpsertHost(&newHost); err != nil {
 			logger.Log(1, "error saving host", err.Error())
 			return
 		}
-
 		logger.Log(1, "updated host", newHost.ID.String())
 	}()
 }