From 73cc848e002313cfea93d5c4743c788e375f922f Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Tue, 28 Dec 2010 08:29:17 +0100 Subject: [PATCH] remove these files, stay lean and mean --- Makefile | 7 ++++--- TODO | 1 + keytest.go | 27 +++++++++++++++++++++++++++ readtest.go | 23 +++++++++++++++++++++++ resolver.go | 3 ++- server.go | 7 ------- strconv.go | 20 -------------------- types.go | 2 ++ 8 files changed, 59 insertions(+), 31 deletions(-) create mode 100644 keytest.go create mode 100644 readtest.go delete mode 100644 server.go delete mode 100644 strconv.go diff --git a/Makefile b/Makefile index 5e52fe41..bad1541f 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,6 @@ GOFILES=\ types.go\ dnssec.go\ edns.go\ - server.go\ - strconv.go\ include $(GOROOT)/src/Make.pkg @@ -21,7 +19,7 @@ include $(GOROOT)/src/Make.pkg examples: (cd examples; make) -progs: dnssectest keytest +progs: dnssectest keytest readtest # too lazy to lookup how this works again in Makefiles dnssectest: dnssectest.go $(GOFILES) @@ -29,3 +27,6 @@ dnssectest: dnssectest.go $(GOFILES) keytest: keytest.go $(GOFILES) 6g -I _obj keytest.go && 6l -L _obj -o keytest keytest.6 + +readtest: readtest.go $(GOFILES) + 6g -I _obj readtest.go && 6l -L _obj -o readtest readtest.6 diff --git a/TODO b/TODO index ca54ffe3..f2f9ce47 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,7 @@ Todo: * parse RRs from strings AToRR() * DNSSEC validation +* NSEC(3) secure denial of existence * Unknown RRs * fix os.Erros usage diff --git a/keytest.go b/keytest.go new file mode 100644 index 00000000..d4d88801 --- /dev/null +++ b/keytest.go @@ -0,0 +1,27 @@ +package main + +import ( + "dns" + "fmt" +) + +func main() { + key := new(dns.RR_DNSKEY) + key.Hdr.Name = "miek.nl" + key.Hdr.Rrtype = dns.TypeDNSKEY + key.Hdr.Class = dns.ClassINET + key.Hdr.Ttl = 3600 + key.Flags = 256 + key.Protocol = 3 + key.Algorithm = dns.AlgRSASHA256 + key.PubKey = "AwEAAcNEU67LJI5GEgF9QLNqLO1SMq1EdoQ6E9f85ha0k0ewQGCblyW2836GiVsm6k8Kr5ECIoMJ6fZWf3CQSQ9ycWfTyOHfmI3eQ/1Covhb2y4bAmL/07PhrL7ozWBW3wBfM335Ft9xjtXHPy7ztCbV9qZ4TVDTW/Iyg0PiwgoXVesz" + + tag := key.KeyTag() + fmt.Printf("%v\n", key) + fmt.Printf("Wrong key tag: %d\n", tag) + + m := new(dns.Msg) + m.Ns = make([]dns.RR, 1) + m.Ns[0] = key + m.Pack() +} diff --git a/readtest.go b/readtest.go new file mode 100644 index 00000000..bd839747 --- /dev/null +++ b/readtest.go @@ -0,0 +1,23 @@ +package main + +import ( + "dns" + "fmt" +) + +func main() { + key := new(dns.RR_DNSKEY) + key.Hdr.Name = "miek.nl." + key.Hdr.Rrtype = dns.TypeDNSKEY + key.Hdr.Class = dns.ClassINET + key.Hdr.Ttl = 3600 + key.Flags = 256 + key.Protocol = 3 + key.Algorithm = dns.AlgRSASHA256 + key.PubKey = "AwEAAcNEU67LJI5GEgF9QLNqLO1SMq1EdoQ6E9f85ha0k0ewQGCblyW2836GiVsm6k8Kr5ECIoMJ6fZWf3CQSQ9ycWfTyOHfmI3eQ/1Covhb2y4bAmL/07PhrL7ozWBW3wBfM335Ft9xjtXHPy7ztCbV9qZ4TVDTW/Iyg0PiwgoXVesz" + + fmt.Printf("%v\n", key) + + s := "miek.nl. 3600 IN DNSKEY 256 3 8 AwEAAcNEU67LJI5GEgF9QLNqLO1SMq1EdoQ6E9f85ha0k0ewQGCblyW2836GiVsm6k8Kr5ECIoMJ6fZWf3CQSQ9ycWfTyOHfmI3eQ/1Covhb2y4bAmL/07PhrL7ozWBW3wBfM335Ft9xjtXHPy7ztCbV9qZ4TVDTW/Iyg0PiwgoXVesz" + dns.ParseString(s) +} diff --git a/resolver.go b/resolver.go index 21dea579..fa0c2704 100644 --- a/resolver.go +++ b/resolver.go @@ -6,7 +6,8 @@ // A dns resolver is to be run as a seperate goroutine. // For every reply the resolver answers by sending the // received packet (with a possible error) back on the channel. -// A simple resolver can be setup with the following code: +// +// Basic usage pattern: // // res := new(Resolver) // ch := NewQuerier(res) // start new resolver diff --git a/server.go b/server.go deleted file mode 100644 index 7e5344b3..00000000 --- a/server.go +++ /dev/null @@ -1,7 +0,0 @@ -// Server side. An receiver listen for incoming packets. -// If the packet is wellformed it is passed on to the channel. -// Otherwise a FORMERR is returned directly. -// -package dns - -// TODO MG diff --git a/strconv.go b/strconv.go deleted file mode 100644 index d1001122..00000000 --- a/strconv.go +++ /dev/null @@ -1,20 +0,0 @@ -package dns - -// use scanner or ebnf - -// Convert a string to an resource record. The string must fir on one line. -// miek.nl. 3600 IN A 192.168.1.1 // ok -// miek.nl. IN A 192.168.1.1 // ok, ttl may be omitted -// miek.nl. A 192.168.1.1 // ok, ttl and class omitted -// miek.nl. 3600 A 192.168.1.1 // ok, class omitted -// IN A 192.168.1.1 // not ok -func ParseString(s string) *RR { - // up to first whitespace is domainname - // next word is: - // -> TTL - // IN|CH|HS -> Class - // -> Type - // When the type is seen, we can read the rest - // of the string in an rr-specific manner - return nil -} diff --git a/types.go b/types.go index eb843288..4bc69df8 100644 --- a/types.go +++ b/types.go @@ -15,6 +15,8 @@ // DNS RR types definitions. See RFC 1035/.../4034 and many more. // To create quad-A record: "a.miek.nl" IN AAAA 2001:7b8:206:1:200:39ff:fe59:b187 // +// Basic usage pattern: +// // import "net" // for IP functions // r := new(RR_AAAA) // r.AAAA = net.ParseIP("2001:7b8:206:1:200:39ff:fe59:b187").To16()