documentation
make Str_rr and Str_class private, prolly only needed for parsing
This commit is contained in:
parent
0dcfa0b427
commit
9b1e7b4b3d
21
dns.go
21
dns.go
|
@ -3,15 +3,19 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
// Extended and bugfixes by Miek Gieben.
|
// 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.
|
// 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.
|
// Resource records are native types. They are not stored in wire format.
|
||||||
// Basic usage pattern for creating a new resource record:
|
// Basic usage pattern for creating a new resource record:
|
||||||
//
|
//
|
||||||
// r := new(RR_TXT)
|
// r := new(RR_TXT)
|
||||||
// r.Hdr = RR_Header{Name: "a.miek.nl", Rrtype: TypeTXT, Class: ClassINET, Ttl: 3600}
|
// 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.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,
|
// The package dns supports (async) querying/replying, incoming/outgoing Axfr/Ixfr,
|
||||||
// TSIG, EDNS0, dynamic updates, notifies and DNSSEC validation/signing.
|
// TSIG, EDNS0, dynamic updates, notifies and DNSSEC validation/signing.
|
||||||
|
@ -21,8 +25,7 @@
|
||||||
// m := new(Msg)
|
// m := new(Msg)
|
||||||
// m.SetQuestion("miek.nl.", TypeMX)
|
// m.SetQuestion("miek.nl.", TypeMX)
|
||||||
//
|
//
|
||||||
//
|
// Or slightly more verbose, but more flexible:
|
||||||
// Or slightly more verbose and flexible:
|
|
||||||
//
|
//
|
||||||
// m1 := new(Msg)
|
// m1 := new(Msg)
|
||||||
// m1.MsgHdr.Id = Id()
|
// m1.MsgHdr.Id = Id()
|
||||||
|
@ -30,8 +33,10 @@
|
||||||
// m1.Question = make([]Question, 1)
|
// m1.Question = make([]Question, 1)
|
||||||
// m1.Question[0] = Question{"miek.nl", TypeDNSKEY, ClassINET}
|
// m1.Question[0] = Question{"miek.nl", TypeDNSKEY, ClassINET}
|
||||||
//
|
//
|
||||||
//
|
// After creating a message it can be send.
|
||||||
// Basic use pattern for synchronous querying of the DNS
|
// 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 := dns.NewClient()
|
||||||
// // c.Net = "tcp" // If you want to use TCP
|
// // c.Net = "tcp" // If you want to use TCP
|
||||||
|
|
|
@ -34,7 +34,7 @@ const (
|
||||||
ECDSAP384SHA384 = 14
|
ECDSAP384SHA384 = 14
|
||||||
)
|
)
|
||||||
|
|
||||||
// DNSSEC hashing codes.
|
// DNSSEC hashing algorithm codes.
|
||||||
const (
|
const (
|
||||||
_ = iota
|
_ = iota
|
||||||
SHA1 // RFC 4034
|
SHA1 // RFC 4034
|
||||||
|
@ -43,7 +43,7 @@ const (
|
||||||
SHA384 // Experimental
|
SHA384 // Experimental
|
||||||
)
|
)
|
||||||
|
|
||||||
// DNSKEY flags values.
|
// DNSKEY flag values.
|
||||||
const (
|
const (
|
||||||
KSK = 1
|
KSK = 1
|
||||||
ZSK = 1 << 8
|
ZSK = 1 << 8
|
||||||
|
|
4
msg.go
4
msg.go
|
@ -118,8 +118,8 @@ var Rr_str = map[uint16]string{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reverse, needed for string parsing.
|
// Reverse, needed for string parsing.
|
||||||
var Str_rr = reverse(Rr_str)
|
var str_rr = reverse(Rr_str)
|
||||||
var Str_class = reverse(Class_str)
|
var str_class = reverse(Class_str)
|
||||||
|
|
||||||
// Map of strings for each CLASS wire type.
|
// Map of strings for each CLASS wire type.
|
||||||
var Class_str = map[uint16]string{
|
var Class_str = map[uint16]string{
|
||||||
|
|
1
types.go
1
types.go
|
@ -183,7 +183,6 @@ func (rr *RR_HINFO) String() string {
|
||||||
return rr.Hdr.String() + rr.Cpu + " " + rr.Os
|
return rr.Hdr.String() + rr.Cpu + " " + rr.Os
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type RR_MB struct {
|
type RR_MB struct {
|
||||||
Hdr RR_Header
|
Hdr RR_Header
|
||||||
Mb string "domain-name"
|
Mb string "domain-name"
|
||||||
|
|
4
types.rl
4
types.rl
|
@ -138,7 +138,7 @@
|
||||||
// Fill the Type Bit Map
|
// Fill the Type Bit Map
|
||||||
for i := 1; i < len(rdf); i++ {
|
for i := 1; i < len(rdf); i++ {
|
||||||
// Check if its there in the map TODO
|
// 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)
|
z.Push(rr)
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@
|
||||||
// Fill the Type Bit Map
|
// Fill the Type Bit Map
|
||||||
for i := 6; i < len(rdf); i++ {
|
for i := 6; i < len(rdf); i++ {
|
||||||
// Check if its there in the map TODO
|
// 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)
|
z.Push(rr)
|
||||||
}
|
}
|
||||||
|
|
7
zone.go
7
zone.go
|
@ -2,30 +2,33 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// 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
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/vector"
|
"container/vector"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Zone implements the concept of RFC 1035 master zone files.
|
||||||
type Zone struct {
|
type Zone struct {
|
||||||
v vector.Vector
|
v vector.Vector
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a new RR to the zone.
|
||||||
func (z *Zone) Push(r RR) {
|
func (z *Zone) Push(r RR) {
|
||||||
z.v.Push(r)
|
z.v.Push(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove a RR from the zone.
|
||||||
func (z *Zone) Pop() RR {
|
func (z *Zone) Pop() RR {
|
||||||
return z.v.Pop().(RR)
|
return z.v.Pop().(RR)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the RR at index i of zone.
|
||||||
func (z *Zone) At(i int) RR {
|
func (z *Zone) At(i int) RR {
|
||||||
return z.v.At(i).(RR)
|
return z.v.At(i).(RR)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The number of RRs in zone.
|
||||||
func (z *Zone) Len() int {
|
func (z *Zone) Len() int {
|
||||||
return z.v.Len()
|
return z.v.Len()
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ tr121:
|
||||||
// Fill the Type Bit Map
|
// Fill the Type Bit Map
|
||||||
for i := 1; i < len(rdf); i++ {
|
for i := 1; i < len(rdf); i++ {
|
||||||
// Check if its there in the map TODO
|
// 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)
|
z.Push(rr)
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ tr127:
|
||||||
// Fill the Type Bit Map
|
// Fill the Type Bit Map
|
||||||
for i := 6; i < len(rdf); i++ {
|
for i := 6; i < len(rdf); i++ {
|
||||||
// Check if its there in the map TODO
|
// 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)
|
z.Push(rr)
|
||||||
}
|
}
|
||||||
|
@ -726,7 +726,7 @@ tr184:
|
||||||
goto st22
|
goto st22
|
||||||
tr51:
|
tr51:
|
||||||
// line 97 "zparse.rl"
|
// line 97 "zparse.rl"
|
||||||
{ hdr.Class = Str_class[data[mark:p]] }
|
{ hdr.Class = str_class[data[mark:p]] }
|
||||||
goto st22
|
goto st22
|
||||||
st22:
|
st22:
|
||||||
p++
|
p++
|
||||||
|
@ -2037,7 +2037,7 @@ case 127:
|
||||||
goto st0
|
goto st0
|
||||||
tr181:
|
tr181:
|
||||||
// line 97 "zparse.rl"
|
// line 97 "zparse.rl"
|
||||||
{ hdr.Class = Str_class[data[mark:p]] }
|
{ hdr.Class = str_class[data[mark:p]] }
|
||||||
goto st128
|
goto st128
|
||||||
st128:
|
st128:
|
||||||
p++
|
p++
|
||||||
|
|
|
@ -94,7 +94,7 @@ func (zp *Parser) Zone() (z *Zone, err os.Error) {
|
||||||
%%{
|
%%{
|
||||||
action mark { mark = p }
|
action mark { mark = p }
|
||||||
action setQname { hdr.Name = data[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 defTtl { /* ... */ }
|
||||||
action setTtl { ttl := atoi(data[mark:p]); hdr.Ttl = uint32(ttl) }
|
action setTtl { ttl := atoi(data[mark:p]); hdr.Ttl = uint32(ttl) }
|
||||||
action lineCount { lines++ }
|
action lineCount { lines++ }
|
||||||
|
|
Loading…
Reference in New Issue