Browse Source

feat(NET-591): allow generic DNS entries (#2568)

pwillis7 1 year ago
parent
commit
fe842e0f05
3 changed files with 4 additions and 4 deletions
  1. 2 2
      controllers/dns_test.go
  2. 1 1
      logic/dns.go
  3. 1 1
      mq/publishers.go

+ 2 - 2
controllers/dns_test.go

@@ -238,7 +238,7 @@ func TestSetDNS(t *testing.T) {
 		assert.False(t, info.IsDir())
 		assert.False(t, info.IsDir())
 		content, err := os.ReadFile("./config/dnsconfig/netmaker.hosts")
 		content, err := os.ReadFile("./config/dnsconfig/netmaker.hosts")
 		assert.Nil(t, err)
 		assert.Nil(t, err)
-		assert.Contains(t, string(content), "linuxhost.skynet")
+		assert.Contains(t, string(content), "linuxhost")
 	})
 	})
 	t.Run("EntryExists", func(t *testing.T) {
 	t.Run("EntryExists", func(t *testing.T) {
 		entry := models.DNSEntry{Address: "10.0.0.3", Name: "newhost", Network: "skynet"}
 		entry := models.DNSEntry{Address: "10.0.0.3", Name: "newhost", Network: "skynet"}
@@ -251,7 +251,7 @@ func TestSetDNS(t *testing.T) {
 		assert.False(t, info.IsDir())
 		assert.False(t, info.IsDir())
 		content, err := os.ReadFile("./config/dnsconfig/netmaker.hosts")
 		content, err := os.ReadFile("./config/dnsconfig/netmaker.hosts")
 		assert.Nil(t, err)
 		assert.Nil(t, err)
-		assert.Contains(t, string(content), "newhost.skynet")
+		assert.Contains(t, string(content), "newhost")
 	})
 	})
 
 
 }
 }

+ 1 - 1
logic/dns.go

@@ -32,7 +32,7 @@ func SetDNS() error {
 			return err
 			return err
 		}
 		}
 		for _, entry := range dns {
 		for _, entry := range dns {
-			hostfile.AddHost(entry.Address, entry.Name+"."+entry.Network)
+			hostfile.AddHost(entry.Address, entry.Name)
 		}
 		}
 	}
 	}
 	if corefilestring == "" {
 	if corefilestring == "" {

+ 1 - 1
mq/publishers.go

@@ -315,7 +315,7 @@ func PublishDeleteExtClientDNS(client *models.ExtClient) error {
 func PublishCustomDNS(entry *models.DNSEntry) error {
 func PublishCustomDNS(entry *models.DNSEntry) error {
 	dns := models.DNSUpdate{
 	dns := models.DNSUpdate{
 		Action: models.DNSInsert,
 		Action: models.DNSInsert,
-		Name:   entry.Name + "." + entry.Network,
+		Name:   entry.Name,
 		//entry.Address6 is never used
 		//entry.Address6 is never used
 		Address: entry.Address,
 		Address: entry.Address,
 	}
 	}