documentation

make Str_rr and Str_class private, prolly only needed
for parsing
This commit is contained in:
Miek Gieben 2011-07-23 23:15:40 +02:00
parent 0dcfa0b427
commit 9b1e7b4b3d
8 changed files with 29 additions and 22 deletions

21
dns.go
View File

@ -3,15 +3,19 @@
// license that can be found in the LICENSE file.
// Extended and bugfixes by Miek Gieben.
// Package dns implements a full featured interface to the DNS.
// Package dns implements a full featured interface to the Domain Name System.
// The package allows complete control over what is send out to the DNS.
//
// Resource records are native types. They are not stored in wire format.
// Basic usage pattern for creating a new resource record:
//
// r := new(RR_TXT)
// r.Hdr = RR_Header{Name: "a.miek.nl", Rrtype: TypeTXT, Class: ClassINET, Ttl: 3600}
// r.TXT = "This is the content of the TXT record"
// r := new(RR_TXT)
// r.Hdr = RR_Header{Name: "a.miek.nl", Rrtype: TypeTXT, Class: ClassINET, Ttl: 3600}
// r.TXT = "This is the content of the TXT record"
//
// Or directly from a string:
//
// mx := NewRR("miek.nl IN MX 10 mx.miek.nl.")
//
// The package dns supports (async) querying/replying, incoming/outgoing Axfr/Ixfr,
// TSIG, EDNS0, dynamic updates, notifies and DNSSEC validation/signing.
@ -21,8 +25,7 @@
// m := new(Msg)
// m.SetQuestion("miek.nl.", TypeMX)
//
//
// Or slightly more verbose and flexible:
// Or slightly more verbose, but more flexible:
//
// m1 := new(Msg)
// m1.MsgHdr.Id = Id()
@ -30,8 +33,10 @@
// m1.Question = make([]Question, 1)
// m1.Question[0] = Question{"miek.nl", TypeDNSKEY, ClassINET}
//
//
// Basic use pattern for synchronous querying of the DNS
// After creating a message it can be send.
// Basic use pattern for synchronous querying the DNS, here
// sending the message 'm' to the server 127.0.0.1 on port 53 and
// waiting for the reply.
//
// c := dns.NewClient()
// // c.Net = "tcp" // If you want to use TCP

View File

@ -34,7 +34,7 @@ const (
ECDSAP384SHA384 = 14
)
// DNSSEC hashing codes.
// DNSSEC hashing algorithm codes.
const (
_ = iota
SHA1 // RFC 4034
@ -43,7 +43,7 @@ const (
SHA384 // Experimental
)
// DNSKEY flags values.
// DNSKEY flag values.
const (
KSK = 1
ZSK = 1 << 8

4
msg.go
View File

@ -118,8 +118,8 @@ var Rr_str = map[uint16]string{
}
// Reverse, needed for string parsing.
var Str_rr = reverse(Rr_str)
var Str_class = reverse(Class_str)
var str_rr = reverse(Rr_str)
var str_class = reverse(Class_str)
// Map of strings for each CLASS wire type.
var Class_str = map[uint16]string{

View File

@ -183,7 +183,6 @@ func (rr *RR_HINFO) String() string {
return rr.Hdr.String() + rr.Cpu + " " + rr.Os
}
type RR_MB struct {
Hdr RR_Header
Mb string "domain-name"

View File

@ -138,7 +138,7 @@
// Fill the Type Bit Map
for i := 1; i < len(rdf); i++ {
// Check if its there in the map TODO
rr.TypeBitMap[i-1] = Str_rr[rdf[i]]
rr.TypeBitMap[i-1] = str_rr[rdf[i]]
}
z.Push(rr)
}
@ -159,7 +159,7 @@
// Fill the Type Bit Map
for i := 6; i < len(rdf); i++ {
// Check if its there in the map TODO
rr.TypeBitMap[i-6] = Str_rr[rdf[i]]
rr.TypeBitMap[i-6] = str_rr[rdf[i]]
}
z.Push(rr)
}

View File

@ -2,30 +2,33 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Implements a concept of zones. In its most basic form
// a list of RRs.
package dns
import (
"container/vector"
)
// Zone implements the concept of RFC 1035 master zone files.
type Zone struct {
v vector.Vector
}
// Add a new RR to the zone.
func (z *Zone) Push(r RR) {
z.v.Push(r)
}
// Remove a RR from the zone.
func (z *Zone) Pop() RR {
return z.v.Pop().(RR)
}
// Return the RR at index i of zone.
func (z *Zone) At(i int) RR {
return z.v.At(i).(RR)
}
// The number of RRs in zone.
func (z *Zone) Len() int {
return z.v.Len()
}

View File

@ -256,7 +256,7 @@ tr121:
// Fill the Type Bit Map
for i := 1; i < len(rdf); i++ {
// Check if its there in the map TODO
rr.TypeBitMap[i-1] = Str_rr[rdf[i]]
rr.TypeBitMap[i-1] = str_rr[rdf[i]]
}
z.Push(rr)
}
@ -281,7 +281,7 @@ tr127:
// Fill the Type Bit Map
for i := 6; i < len(rdf); i++ {
// Check if its there in the map TODO
rr.TypeBitMap[i-6] = Str_rr[rdf[i]]
rr.TypeBitMap[i-6] = str_rr[rdf[i]]
}
z.Push(rr)
}
@ -726,7 +726,7 @@ tr184:
goto st22
tr51:
// line 97 "zparse.rl"
{ hdr.Class = Str_class[data[mark:p]] }
{ hdr.Class = str_class[data[mark:p]] }
goto st22
st22:
p++
@ -2037,7 +2037,7 @@ case 127:
goto st0
tr181:
// line 97 "zparse.rl"
{ hdr.Class = Str_class[data[mark:p]] }
{ hdr.Class = str_class[data[mark:p]] }
goto st128
st128:
p++

View File

@ -94,7 +94,7 @@ func (zp *Parser) Zone() (z *Zone, err os.Error) {
%%{
action mark { mark = p }
action setQname { hdr.Name = data[mark:p] }
action setQclass { hdr.Class = Str_class[data[mark:p]] }
action setQclass { hdr.Class = str_class[data[mark:p]] }
action defTtl { /* ... */ }
action setTtl { ttl := atoi(data[mark:p]); hdr.Ttl = uint32(ttl) }
action lineCount { lines++ }