Skip to content

Commit

Permalink
Don't add a '.' prefix on the record header on apex records
Browse files Browse the repository at this point in the history
  • Loading branch information
abh committed Jun 15, 2014
1 parent f2639a9 commit a68f161
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 10 additions & 3 deletions zones.go
Expand Up @@ -3,8 +3,6 @@ package main
import (
"encoding/json"
"fmt"
"github.com/abh/dns"
"github.com/abh/errorutil"
"io/ioutil"
"log"
"net"
Expand All @@ -15,6 +13,9 @@ import (
"strconv"
"strings"
"time"

"github.com/abh/dns"
"github.com/abh/errorutil"
)

// Zones maps domain names to zone data
Expand Down Expand Up @@ -300,7 +301,13 @@ func setupZoneData(data map[string]interface{}, Zone *Zone) {
h.Ttl = uint32(label.Ttl)
h.Class = dns.ClassINET
h.Rrtype = dnsType
h.Name = label.Label + "." + Zone.Origin + "."

switch len(label.Label) {
case 0:
h.Name = Zone.Origin + "."
default:
h.Name = label.Label + "." + Zone.Origin + "."
}

switch dnsType {
case dns.TypeA, dns.TypeAAAA:
Expand Down
3 changes: 3 additions & 0 deletions zones_test.go
Expand Up @@ -62,6 +62,9 @@ func (s *ConfigSuite) TestReadConfigs(c *C) {
firstRR(dns.TypeMF).(*dns.MF).
Mf, Equals, "www")

// The header name should just have a dot-prefix
c.Check(tz.Labels[""].Records[dns.TypeNS][0].RR.(*dns.NS).Hdr.Name, Equals, "test.example.com.")

}

func (s *ConfigSuite) TestRemoveConfig(c *C) {
Expand Down

0 comments on commit a68f161

Please sign in to comment.