Browse Source

publish dns update on custom dns creation

Matthew R Kasun 2 years ago
parent
commit
4f7c038702
2 changed files with 15 additions and 0 deletions
  1. 3 0
      controllers/dns.go
  2. 12 0
      mq/publishers.go

+ 3 - 0
controllers/dns.go

@@ -179,6 +179,9 @@ func createDNS(w http.ResponseWriter, r *http.Request) {
 		if err = mq.PublishPeerUpdate(); err != nil {
 			logger.Log(0, "failed to publish peer update after ACL update on", entry.Network)
 		}
+		if err := mq.PublishCustomDNS(&entry); err != nil {
+			logger.Log(0, "error publishing custom dns", err.Error())
+		}
 	}
 	logger.Log(2, r.Header.Get("user"),
 		fmt.Sprintf("DNS entry is set: %+v", entry))

+ 12 - 0
mq/publishers.go

@@ -316,6 +316,18 @@ func PublishDeleteExtClientDNS(client *models.ExtClient) error {
 	return nil
 }
 
+func PublishCustomDNS(entry *models.DNSEntry) error {
+	dns := models.DNSUpdate{
+		Action: models.DNSInsert,
+		Name:   entry.Name,
+		//entry.Address6 is never used
+		Address: entry.Address,
+	}
+	if err := PublishDNSUpdate(entry.Network, dns); err != nil {
+		return err
+	}
+}
+
 // function to collect and store metrics for server nodes
 //func collectServerMetrics(networks []models.Network) {
 //	if !servercfg.Is_EE {