From 9f3a1c1f13b8301f6c5ae4b47d5152548641302a Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Mon, 16 Jan 2012 21:44:49 +0100 Subject: [PATCH] Documentation and make ParseKey private (parseKey) --- dns.go | 10 +++++----- dnssec.go | 7 +++++++ kscan.go | 6 +++--- msg.go | 5 +++++ tsig.go | 4 ++-- update.go | 7 ++++--- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/dns.go b/dns.go index 8da9ff88..ff95a0cc 100644 --- a/dns.go +++ b/dns.go @@ -67,11 +67,11 @@ import ( ) const ( - Year68 = 2 << (32 - 1) // For RFC1982 (Serial Arithmetic) calculations in 32 bits. - DefaultMsgSize = 4096 // Standard default for larger than 512 packets. - UDPReceiveMsgSize = 360 // Default buffer size for servers receiving UDP packets. - MaxMsgSize = 65536 // Largest possible DNS packet. - DefaultTtl = 3600 // Default TTL. + Year68 = 1 << 32 // For RFC1982 (Serial Arithmetic) calculations in 32 bits. + DefaultMsgSize = 4096 // Standard default for larger than 512 packets. + UDPReceiveMsgSize = 360 // Default buffer size for servers receiving UDP packets. + MaxMsgSize = 65536 // Largest possible DNS packet. + DefaultTtl = 3600 // Default TTL. ) // Error represents a DNS error diff --git a/dnssec.go b/dnssec.go index 9d97b20b..bd27da9d 100644 --- a/dnssec.go +++ b/dnssec.go @@ -1,3 +1,10 @@ +// Copyright 2012 Miek Gieben. All rights reserved. + +// DNSSEC +// +// DNSSEC (DNS Security Extension) adds a layer of security to the DNS. It +// uses public key cryptography to securely sign resource records. The +// public keys are stored in DNSKEY records and the signatures in RRSIG records. package dns import ( diff --git a/kscan.go b/kscan.go index 0ed31731..bf1010c5 100644 --- a/kscan.go +++ b/kscan.go @@ -11,7 +11,7 @@ import ( // ReadPrivateKey reads a private key from the io.Reader q. func ReadPrivateKey(q io.Reader) (PrivateKey, error) { - m, e := ParseKey(q) + m, e := parseKey(q) if m == nil { return nil, e } @@ -89,9 +89,9 @@ func readPrivateKeyECDSA(m map[string]string) (PrivateKey, error) { return p, nil } -// ParseKey reads a private key from r. It returns a map[string]string, +// parseKey reads a private key from r. It returns a map[string]string, // with the key-value pairs, or an error when the file is not correct. -func ParseKey(r io.Reader) (map[string]string, error) { +func parseKey(r io.Reader) (map[string]string, error) { var s scanner.Scanner m := make(map[string]string) c := make(chan lex) diff --git a/msg.go b/msg.go index 62688d66..a681e748 100644 --- a/msg.go +++ b/msg.go @@ -175,6 +175,9 @@ var Rcode_str = map[int]string{ // PackDomainName packs a domain name s into msg[off:]. // Domain names are a sequence of counted strings // split at the dots. They end with a zero-length string. +// If compression is want compress must be true and the compression +// map, needs to hold a mapping between domain names and offsets +// pointing into msg[]. func PackDomainName(s string, msg []byte, off int, compression map[string]int, compress bool) (off1 int, ok bool) { // Add trailing dot to canonicalize name. lenmsg := len(msg) @@ -975,7 +978,9 @@ func reverseInt(m map[int]string) map[string]int { } // Convert a MsgHdr to a string, mimic the way Dig displays headers: +// //;; opcode: QUERY, status: NOERROR, id: 48404 +// //;; flags: qr aa rd ra; func (h *MsgHdr) String() string { if h == nil { diff --git a/tsig.go b/tsig.go index b76f0e2e..6c4f0227 100644 --- a/tsig.go +++ b/tsig.go @@ -14,7 +14,7 @@ // secrets["axfr."] = "so6ZGir4GPAqINNh9U5c3A==" // don't forget the . here // // The secrets' map index is set to 'axfr.'. This must match the ownername of the -// TSIG records, which in the above example, is also set to 'axfr.' +// TSIG record, which in the above example, is also set to 'axfr.' // // The message requesting an AXFR (almost all TSIG usage is when requesting zone transfers) // for miek.nl with the TSIG record added is now ready to use. @@ -24,7 +24,7 @@ // c.TsigSecret = secrets // err := c.XfrReceive(m, "85.223.71.124:53") // -// You can now read the records from the AXFR as the come in. Each envelope is checked with TSIG. +// You can now read the records from the AXFR as they come in. Each envelope is checked with TSIG. // If something is not correct an error is returned. // // Basic use pattern replying to a message that has TSIG set. diff --git a/update.go b/update.go index 3c73c891..ed281594 100644 --- a/update.go +++ b/update.go @@ -1,6 +1,6 @@ // DYNAMIC UPDATES // -// Dynamic updates reuses the DNS message format, but renames the three of +// Dynamic updates reuses the DNS message format, but renames three of // the sections. Question is Zone, Answer is Prerequisite, Authority is // Update, only the Additional is not renamed. See RFC 2136 for the gory details. // @@ -20,9 +20,10 @@ // zone rrset rr RRset exists (value dep) RRsetUsedRdata // // The prerequisite section can also be left empty. -// If you have decided an the prerequisites you can tell what RRs should +// If you have decided on the prerequisites you can tell what RRs should // be added or deleted. The next table shows the options you have and -// what function to call. +// what functions to call. +// // 3.4.2.6 - Table Of Metavalues Used In Update Section // // CLASS TYPE RDATA Meaning Function