Skip to content

Commit

Permalink
Implementation of EDNS and NSID
Browse files Browse the repository at this point in the history
  • Loading branch information
bortzmeyer committed Mar 11, 2010
1 parent 65f971a commit 4cd33cf
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 40 deletions.
24 changes: 17 additions & 7 deletions README
Expand Up @@ -25,7 +25,7 @@ Usage

./dnsserver [-address="[ADDRESS]:PORT"] [-debug=N]

Run with -h to see the defaults.
Run with -h to see the defaults (and the other, less common, options)

The -address option takes either a port (in the syntax ":NNN"), in
that case GRONG listens on all IP addresses, or one address (in the
Expand Down Expand Up @@ -69,6 +69,9 @@ responder. The prototype is:

func Respond(query types.DNSquery) types.DNSresponse

To see what is available for you in the query, see the descriptio of
type DNSquery.

In the DNSresponse, RRs (Resource Records) have to be in the wire
format (the front-end does not know the format of the RR, to keep it
generic). For instance, data in TXT RR has to be {length,
Expand All @@ -85,10 +88,7 @@ are behind BIND.
TODO
****

EDNS, specially for NSID (RFC 5001)

Give the responder some global info such as the debug level and some
per-query info such as the buffer size (512 by default)
Give the responder some global info such as the debug level.

Pass unknown command-line options to the responder. Options Qname for
the reflector and various TXT for as112
Expand All @@ -98,11 +98,12 @@ Use the log package
Hardening against rogue packets. Better handling of errors, an invalid
packet should not stop the name server. Test with typing junk in
telnet. Or learn Scapy, which seems more interesting. See for instance
the example in <http://www.secdev.org/projects/scapy/demo.html>
the example in <http://www.secdev.org/projects/scapy/demo.html> and
the example test-scapy.py in the distribution.

Finish the AS112 responder

The abiity to listen to more than one address (but not all). Can I
The ability to listen to more than one address (but not all). Can I
give several -address option to the flag module? If so, it probably
just means firing several udpListeners and several tcpListeners

Expand All @@ -111,11 +112,20 @@ queryperf!

Test with gccgo

Implements id.server and version.bind

See if we can replace a good part of package "types" by standard
package net/ <http://golang.org/src/pkg/net/dnsmsg.go>

Daemonize <http://groups.google.com/group/golang-nuts/browse_thread/thread/2b29d93b90501a4b/95242bfb7ae0549e>

A name server with data, for instance able to serve a zone with a
simple setup, one SOA, a few NS, and one A record for www.$ORIGIN. The
list of zones (all with identical data) and the IP address of the Web
server being taken from a file or on the command-line.

Configuration file. What is idiomatic in Go? .INI ?

DNSSEC (no, I'm joking)


Expand Down
16 changes: 8 additions & 8 deletions as112.go
Expand Up @@ -79,18 +79,18 @@ func soaRecord(domain string, soa types.SOArecord) (result types.RR) {
}

func Respond(query types.DNSquery) (result types.DNSresponse) {
result.Asection = nil
result.Ansection = nil
qname := strings.ToLower(query.Qname)
if query.Qclass == types.IN {
switch {
case as112Domain.Match([]byte(qname)):
result.Responsecode = types.NOERROR
switch {
case query.Qtype == types.NS:
result.Asection = nsRecords(query.Qname)
result.Ansection = nsRecords(query.Qname)
case query.Qtype == types.SOA:
result.Asection = make([]types.RR, 1)
result.Asection[0] = soaRecord(query.Qname, as112soa)
result.Ansection = make([]types.RR, 1)
result.Ansection[0] = soaRecord(query.Qname, as112soa)
default:
// Do nothing
}
Expand All @@ -102,9 +102,9 @@ func Respond(query types.DNSquery) (result types.DNSresponse) {
result.Responsecode = types.NOERROR
switch query.Qtype { // TODO: handle ANY qtypes
case types.TXT:
result.Asection = make([]types.RR, len(hostnameAnswers))
result.Ansection = make([]types.RR, len(hostnameAnswers))
for i, text := range hostnameAnswers {
result.Asection[i] = types.RR{
result.Ansection[i] = types.RR{
Name: query.Qname,
TTL: defaultTTL,
Type: types.TXT,
Expand All @@ -113,9 +113,9 @@ func Respond(query types.DNSquery) (result types.DNSresponse) {
}
}
case types.NS:
result.Asection = nsRecords(query.Qname)
result.Ansection = nsRecords(query.Qname)
case types.SOA:
result.Asection = []types.RR{soaRecord(query.Qname, hostnamesoa)}
result.Ansection = []types.RR{soaRecord(query.Qname, hostnamesoa)}
default:
// Do nothing
}
Expand Down
22 changes: 11 additions & 11 deletions reflector-responder.go
Expand Up @@ -63,7 +63,7 @@ func Respond(query types.DNSquery) types.DNSresponse {
var (
result types.DNSresponse
)
result.Asection = nil
result.Ansection = nil
tcpAddr, _ := net.ResolveTCPAddr(query.Client.String())
ipaddressV4 := tcpAddr.IP.To4()
switch {
Expand All @@ -73,34 +73,34 @@ func Respond(query types.DNSquery) types.DNSresponse {
result.Responsecode = types.NOERROR
if ipaddressV4 != nil {
ancount := 1
result.Asection = make([]types.RR, ancount)
result.Asection[0] = addressSection(query.Qname, ipaddressV4)
result.Ansection = make([]types.RR, ancount)
result.Ansection[0] = addressSection(query.Qname, ipaddressV4)
} else {
// ancount := 0
}
case query.Qtype == types.AAAA:
result.Responsecode = types.NOERROR
if ipaddressV4 == nil {
ancount := 1
result.Asection = make([]types.RR, ancount)
result.Asection[0] = aaaaSection(query.Qname, tcpAddr.IP)
result.Ansection = make([]types.RR, ancount)
result.Ansection[0] = aaaaSection(query.Qname, tcpAddr.IP)
} else {
// ancount := 0
}
case query.Qtype == types.TXT:
result.Responsecode = types.NOERROR
ancount := 1
result.Asection = make([]types.RR, ancount)
result.Asection[0] = txtSection(query.Qname, query.Client)
result.Ansection = make([]types.RR, ancount)
result.Ansection[0] = txtSection(query.Qname, query.Client)
case query.Qtype == types.ALL:
result.Responsecode = types.NOERROR
ancount := 2
result.Asection = make([]types.RR, ancount)
result.Asection[0] = txtSection(query.Qname, query.Client)
result.Ansection = make([]types.RR, ancount)
result.Ansection[0] = txtSection(query.Qname, query.Client)
if ipaddressV4 == nil {
result.Asection[1] = aaaaSection(query.Qname, tcpAddr.IP)
result.Ansection[1] = aaaaSection(query.Qname, tcpAddr.IP)
} else {
result.Asection[1] = addressSection(query.Qname, ipaddressV4)
result.Ansection[1] = addressSection(query.Qname, ipaddressV4)
}
default:
result.Responsecode = types.NOERROR
Expand Down

0 comments on commit 4cd33cf

Please sign in to comment.