From 104af4cc98aa23661244749ae67fdcbf603ce89d Mon Sep 17 00:00:00 2001 From: abhishek9686 Date: Thu, 12 Dec 2024 15:53:52 +0400 Subject: [PATCH] append default domain if not append --- controllers/dns.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/dns.go b/controllers/dns.go index 859d36e44..651f2e381 100644 --- a/controllers/dns.go +++ b/controllers/dns.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "net/http" + "strings" "github.com/gorilla/mux" "github.com/gravitl/netmaker/database" @@ -162,7 +163,10 @@ func createDNS(w http.ResponseWriter, r *http.Request) { logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest")) return } - + // check if default domain is appended if not append + if !strings.HasSuffix(entry.Name, servercfg.GetDefaultDomain()) { + entry.Name += servercfg.GetDefaultDomain() + } entry, err = logic.CreateDNS(entry) if err != nil { logger.Log(0, r.Header.Get("user"),