Pārlūkot izejas kodu

Merge pull request #3494 from gravitl/v0.99_fixes

v0.99: fix host dns setting
Abhishek K 3 mēneši atpakaļ
vecāks
revīzija
31d485bdaa
4 mainītis faili ar 10 papildinājumiem un 7 dzēšanām
  1. 2 2
      logic/hosts.go
  2. 1 1
      logic/peers.go
  3. 6 3
      migrate/migrate.go
  4. 1 1
      models/api_host.go

+ 2 - 2
logic/hosts.go

@@ -231,9 +231,9 @@ func CreateHost(h *models.Host) error {
 	h.AutoUpdate = AutoUpdateEnabled()
 
 	if GetServerSettings().ManageDNS {
-		h.DNS = "on"
+		h.DNS = "yes"
 	} else {
-		h.DNS = "off"
+		h.DNS = "no"
 	}
 	checkForZombieHosts(h)
 	return UpsertHost(h)

+ 1 - 1
logic/peers.go

@@ -163,7 +163,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
 		HostNetworkInfo: models.HostInfoMap{},
 		ServerConfig:    GetServerInfo(),
 	}
-	if host.DNS == "off" {
+	if host.DNS == "no" {
 		hostPeerUpdate.ManageDNS = false
 	}
 	defer func() {

+ 6 - 3
migrate/migrate.go

@@ -196,11 +196,11 @@ func updateHosts() {
 				continue
 			}
 		}
-		if host.DNS == "" {
+		if host.DNS == "" || (host.DNS != "yes" && host.DNS != "no") {
 			if logic.GetServerSettings().ManageDNS {
-				host.DNS = "on"
+				host.DNS = "yes"
 			} else {
-				host.DNS = "off"
+				host.DNS = "no"
 			}
 		}
 	}
@@ -582,5 +582,8 @@ func settings() {
 	if settings.AuditLogsRetentionPeriodInDays == 0 {
 		settings.AuditLogsRetentionPeriodInDays = 30
 	}
+	if settings.DefaultDomain == "" {
+		settings.DefaultDomain = servercfg.GetDefaultDomain()
+	}
 	logic.UpsertServerSettings(settings)
 }

+ 1 - 1
models/api_host.go

@@ -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.DNS = a.DNS
+	h.DNS = strings.ToLower(a.DNS)
 	return &h
 }