Update the documentation

This commit is contained in:
Miek Gieben 2011-02-24 16:13:23 +01:00
parent 71b860e0d3
commit 77348913dd
4 changed files with 34 additions and 27 deletions

View File

@ -94,9 +94,7 @@ Flags:
opt.SetDo()
opt.SetUDPSize(dns.DefaultMsgSize)
if *nsid {
opt.Option = make([]dns.Option, 1)
opt.Option[0].Code = dns.OptionCodeNSID
opt.Option[0].Data = ""
opt.SetNsid("")
}
m.Extra = make([]dns.RR, 1)
m.Extra[0] = opt

2
dns.go
View File

@ -113,7 +113,7 @@ func (h *RR_Header) String() string {
return s
}
// Return the number of labels in a domain name
// Return the number of labels in a domain name.
func LabelCount(a string) (c uint8) {
// walk the string and count the dots
// except when it is escaped

11
edns.go
View File

@ -31,6 +31,14 @@ type Option struct {
* Rdlength uint16 // length of data after the header
*/
// Adding an EDNS0 record to a message is done as follows:
// opt := new(RR_OPT)
// opt.Hdr = dns.RR_Header{Name: "", Rrtype: TypeOPT}
// opt.SetVersion(0) // set version to zero
// opt.SetDo() // set the DO bit
// opt.SetUDPSize(4096) // set the message size
// m.Extra = make([]RR, 1)
// m.Extra[0] = opt // add OPT RR to the message
type RR_OPT struct {
Hdr RR_Header
Option []Option "OPT" // tag is used in Pack and Unpack
@ -101,7 +109,7 @@ func (rr *RR_OPT) Do() bool {
return byte(rr.Hdr.Ttl >> 8) &_DO == _DO
}
// Set the do bit
// Set the DO bit
func (rr *RR_OPT) SetDo() {
b1 := byte(rr.Hdr.Ttl >> 24)
b2 := byte(rr.Hdr.Ttl >> 16)
@ -118,6 +126,7 @@ func (rr *RR_OPT) Nsid() string {
// Set the NSID from a string which is represented as hex characters.
func (rr *RR_OPT) SetNsid(hexnsid string) {
rr.Option = make([]Option, 1) // TODO(mg) check length first?
rr.Option[0].Code = OptionCodeNSID
rr.Option[0].Data = hexnsid
}

View File

@ -341,7 +341,7 @@ func (rr *RR_NAPTR) String() string {
rr.Replacement
}
// RFC 4398
// See RFC 4398.
type RR_CERT struct {
Hdr RR_Header
Type uint16