pull/18/head
Hugo Landau 10 years ago
parent 3f88db348f
commit 12b30fa15c

@ -216,12 +216,12 @@ func (tx *btx) doRootDomain() (rrs []dns.RR, err error) {
soa := &dns.SOA { soa := &dns.SOA {
Hdr: dns.RR_Header { Hdr: dns.RR_Header {
Name: util.Absname(tx.rootname), Name: dns.Fqdn(tx.rootname),
Ttl: 86400, Ttl: 86400,
Class: dns.ClassINET, Class: dns.ClassINET,
Rrtype: dns.TypeSOA, Rrtype: dns.TypeSOA,
}, },
Ns: util.Absname(nsname), Ns: dns.Fqdn(nsname),
Mbox: ".", Mbox: ".",
Serial: 1, Serial: 1,
Refresh: 600, Refresh: 600,
@ -232,12 +232,12 @@ func (tx *btx) doRootDomain() (rrs []dns.RR, err error) {
ns := &dns.NS { ns := &dns.NS {
Hdr: dns.RR_Header { Hdr: dns.RR_Header {
Name: util.Absname(tx.rootname), Name: dns.Fqdn(tx.rootname),
Ttl: 86400, Ttl: 86400,
Class: dns.ClassINET, Class: dns.ClassINET,
Rrtype: dns.TypeNS, Rrtype: dns.TypeNS,
}, },
Ns: util.Absname(nsname), Ns: dns.Fqdn(nsname),
} }
rrs = []dns.RR{ soa, ns, } rrs = []dns.RR{ soa, ns, }
@ -255,7 +255,7 @@ func (tx *btx) doMetaDomain() (rrs []dns.RR, err error) {
rrs = []dns.RR{ rrs = []dns.RR{
&dns.A{ &dns.A{
Hdr: dns.RR_Header{ Hdr: dns.RR_Header{
Name: util.Absname("this." + tx.basename + "." + tx.rootname), Name: dns.Fqdn("this." + tx.basename + "." + tx.rootname),
Ttl: 86400, Ttl: 86400,
Class: dns.ClassINET, Class: dns.ClassINET,
Rrtype: dns.TypeA, Rrtype: dns.TypeA,
@ -363,7 +363,7 @@ func (tx *btx) addAnswersUnderNCValueActual(ncv *ncValue, sn string) (rrs []dns.
continue continue
} }
rrs = append(rrs, &dns.A { 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 }) A: pip })
} }
@ -379,7 +379,7 @@ func (tx *btx) addAnswersUnderNCValueActual(ncv *ncValue, sn string) (rrs []dns.
continue continue
} }
rrs = append(rrs, &dns.AAAA { 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 }) AAAA: pip })
} }
@ -390,9 +390,9 @@ func (tx *btx) addAnswersUnderNCValueActual(ncv *ncValue, sn string) (rrs []dns.
} }
for _, ns := range nss { for _, ns := range nss {
ns = util.Absname(ns) ns = dns.Fqdn(ns)
rrs = append(rrs, &dns.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 }) Ns: ns })
} }
@ -404,7 +404,7 @@ func (tx *btx) addAnswersUnderNCValueActual(ncv *ncValue, sn string) (rrs []dns.
for _, txt := range txts { for _, txt := range txts {
rrs = append(rrs, &dns.TXT { 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 }) Txt: txt })
} }
@ -418,7 +418,7 @@ func (tx *btx) addAnswersUnderNCValueActual(ncv *ncValue, sn string) (rrs []dns.
} }
for i := range dss { 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]) rrs = append(rrs, &dss[i])
} }

@ -11,7 +11,6 @@ import "github.com/hlandau/degoutils/config"
import "github.com/hlandau/ncdns/ncerr" import "github.com/hlandau/ncdns/ncerr"
import "github.com/hlandau/ncdns/abstract" import "github.com/hlandau/ncdns/abstract"
import "github.com/hlandau/ncdns/backend" import "github.com/hlandau/ncdns/backend"
import "github.com/hlandau/ncdns/util"
// A Go daemon to serve Namecoin domain records via DNS. // A Go daemon to serve Namecoin domain records via DNS.
// This daemon is intended to be used in one of the following situations: // This daemon is intended to be used in one of the following situations:
@ -365,7 +364,7 @@ A:
if firstNSAtLen < 0 { if firstNSAtLen < 0 {
firstNSAtLen = len(n) firstNSAtLen = len(n)
tx.delegationPoint = util.Absname(n) tx.delegationPoint = dns.Fqdn(n)
log.Info("DELEGATION POINT: ", tx.delegationPoint) log.Info("DELEGATION POINT: ", tx.delegationPoint)
if n == norig { if n == norig {
@ -571,7 +570,7 @@ func (tx *Tx) addNSEC3RRActual(name string, tset map[uint16]struct{}) error {
nsr1nn := stepName(nsr1n) nsr1nn := stepName(nsr1n)
nsr1 := &dns.NSEC3 { nsr1 := &dns.NSEC3 {
Hdr: dns.RR_Header { Hdr: dns.RR_Header {
Name: util.Absname(nsr1n + "." + tx.soa.Hdr.Name), Name: dns.Fqdn(nsr1n + "." + tx.soa.Hdr.Name),
Rrtype: dns.TypeNSEC3, Rrtype: dns.TypeNSEC3,
Class: dns.ClassINET, Class: dns.ClassINET,
Ttl: 600, Ttl: 600,

@ -4,7 +4,6 @@ import "fmt"
import "github.com/miekg/dns" import "github.com/miekg/dns"
import "github.com/hlandau/degoutils/log" import "github.com/hlandau/degoutils/log"
import "time" import "time"
import "github.com/hlandau/ncdns/util"
// Determines if a transaction should be considered to have the given query type. // Determines if a transaction should be considered to have the given query type.
// Returns true iff the query type was qtype or ANY. // 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, Algorithm: dns.RSASHA256,
Expiration: uint32(now.Add(exp).Unix()), Expiration: uint32(now.Add(exp).Unix()),
Inception: uint32(now.Add(time.Duration(-10)*time.Minute).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 pk := tx.s.zskPrivate
if useKSK { if useKSK {

@ -1,17 +1,6 @@
package util package util
import "strings" 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). // 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) { func SplitDomainHead(name string) (head string, rest string, err error) {
parts := strings.Split(name, ".") parts := strings.Split(name, ".")

Loading…
Cancel
Save