From 12b30fa15c51cfe18fc5539e885bba0589a1174f Mon Sep 17 00:00:00 2001 From: Hugo Landau Date: Wed, 22 Oct 2014 15:43:47 +0100 Subject: [PATCH] cleanup --- backend/backend.go | 22 +++++++++++----------- ncdns.go | 5 ++--- txutil.go | 3 +-- util/util.go | 11 ----------- 4 files changed, 14 insertions(+), 27 deletions(-) diff --git a/backend/backend.go b/backend/backend.go index c3f1bc7..0709fd3 100644 --- a/backend/backend.go +++ b/backend/backend.go @@ -216,12 +216,12 @@ func (tx *btx) doRootDomain() (rrs []dns.RR, err error) { soa := &dns.SOA { Hdr: dns.RR_Header { - Name: util.Absname(tx.rootname), + Name: dns.Fqdn(tx.rootname), Ttl: 86400, Class: dns.ClassINET, Rrtype: dns.TypeSOA, }, - Ns: util.Absname(nsname), + Ns: dns.Fqdn(nsname), Mbox: ".", Serial: 1, Refresh: 600, @@ -232,12 +232,12 @@ func (tx *btx) doRootDomain() (rrs []dns.RR, err error) { ns := &dns.NS { Hdr: dns.RR_Header { - Name: util.Absname(tx.rootname), + Name: dns.Fqdn(tx.rootname), Ttl: 86400, Class: dns.ClassINET, Rrtype: dns.TypeNS, }, - Ns: util.Absname(nsname), + Ns: dns.Fqdn(nsname), } rrs = []dns.RR{ soa, ns, } @@ -255,7 +255,7 @@ func (tx *btx) doMetaDomain() (rrs []dns.RR, err error) { rrs = []dns.RR{ &dns.A{ Hdr: dns.RR_Header{ - Name: util.Absname("this." + tx.basename + "." + tx.rootname), + Name: dns.Fqdn("this." + tx.basename + "." + tx.rootname), Ttl: 86400, Class: dns.ClassINET, Rrtype: dns.TypeA, @@ -363,7 +363,7 @@ func (tx *btx) addAnswersUnderNCValueActual(ncv *ncValue, sn string) (rrs []dns. continue } rrs = append(rrs, &dns.A { - Hdr: dns.RR_Header { Name: util.Absname(tx.qname), Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 600, }, + Hdr: dns.RR_Header { Name: dns.Fqdn(tx.qname), Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 600, }, A: pip }) } @@ -379,7 +379,7 @@ func (tx *btx) addAnswersUnderNCValueActual(ncv *ncValue, sn string) (rrs []dns. continue } rrs = append(rrs, &dns.AAAA { - Hdr: dns.RR_Header { Name: util.Absname(tx.qname), Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: 600, }, + Hdr: dns.RR_Header { Name: dns.Fqdn(tx.qname), Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: 600, }, AAAA: pip }) } @@ -390,9 +390,9 @@ func (tx *btx) addAnswersUnderNCValueActual(ncv *ncValue, sn string) (rrs []dns. } for _, ns := range nss { - ns = util.Absname(ns) + ns = dns.Fqdn(ns) rrs = append(rrs, &dns.NS { - Hdr: dns.RR_Header { Name: util.Absname(tx.qname), Rrtype: dns.TypeNS, Class: dns.ClassINET, Ttl: 600, }, + Hdr: dns.RR_Header { Name: dns.Fqdn(tx.qname), Rrtype: dns.TypeNS, Class: dns.ClassINET, Ttl: 600, }, Ns: ns }) } @@ -404,7 +404,7 @@ func (tx *btx) addAnswersUnderNCValueActual(ncv *ncValue, sn string) (rrs []dns. for _, txt := range txts { rrs = append(rrs, &dns.TXT { - Hdr: dns.RR_Header { Name: util.Absname(tx.qname), Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: 600, }, + Hdr: dns.RR_Header { Name: dns.Fqdn(tx.qname), Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: 600, }, Txt: txt }) } @@ -418,7 +418,7 @@ func (tx *btx) addAnswersUnderNCValueActual(ncv *ncValue, sn string) (rrs []dns. } for i := range dss { - dss[i].Hdr.Name = util.Absname(tx.qname) + dss[i].Hdr.Name = dns.Fqdn(tx.qname) rrs = append(rrs, &dss[i]) } diff --git a/ncdns.go b/ncdns.go index 856df9e..6f36f15 100644 --- a/ncdns.go +++ b/ncdns.go @@ -11,7 +11,6 @@ import "github.com/hlandau/degoutils/config" import "github.com/hlandau/ncdns/ncerr" import "github.com/hlandau/ncdns/abstract" import "github.com/hlandau/ncdns/backend" -import "github.com/hlandau/ncdns/util" // A Go daemon to serve Namecoin domain records via DNS. // This daemon is intended to be used in one of the following situations: @@ -365,7 +364,7 @@ A: if firstNSAtLen < 0 { firstNSAtLen = len(n) - tx.delegationPoint = util.Absname(n) + tx.delegationPoint = dns.Fqdn(n) log.Info("DELEGATION POINT: ", tx.delegationPoint) if n == norig { @@ -571,7 +570,7 @@ func (tx *Tx) addNSEC3RRActual(name string, tset map[uint16]struct{}) error { nsr1nn := stepName(nsr1n) nsr1 := &dns.NSEC3 { Hdr: dns.RR_Header { - Name: util.Absname(nsr1n + "." + tx.soa.Hdr.Name), + Name: dns.Fqdn(nsr1n + "." + tx.soa.Hdr.Name), Rrtype: dns.TypeNSEC3, Class: dns.ClassINET, Ttl: 600, diff --git a/txutil.go b/txutil.go index 595837d..75cc250 100644 --- a/txutil.go +++ b/txutil.go @@ -4,7 +4,6 @@ import "fmt" import "github.com/miekg/dns" import "github.com/hlandau/degoutils/log" import "time" -import "github.com/hlandau/ncdns/util" // Determines if a transaction should be considered to have the given query type. // Returns true iff the query type was qtype or ANY. @@ -97,7 +96,7 @@ func (tx *Tx) signRRs(rra []dns.RR, useKSK bool) (dns.RR, error) { Algorithm: dns.RSASHA256, Expiration: uint32(now.Add(exp).Unix()), Inception: uint32(now.Add(time.Duration(-10)*time.Minute).Unix()), - SignerName: util.Absname(tx.soa.Hdr.Name), + SignerName: dns.Fqdn(tx.soa.Hdr.Name), } pk := tx.s.zskPrivate if useKSK { diff --git a/util/util.go b/util/util.go index 7849af8..d095c57 100644 --- a/util/util.go +++ b/util/util.go @@ -1,17 +1,6 @@ package util import "strings" -// miekg/dns demands a superflous trailing dot, this makes sure it is correctly appended. -func Absname(n string) string { - if n == "" { - return "." - } - if n[len(n)-1] != '.' { - return n + "." - } - return n -} - // Split a domain name a.b.c.d.e into parts a (the head) and b.c.d.e (the rest). func SplitDomainHead(name string) (head string, rest string, err error) { parts := strings.Split(name, ".")