diff --git a/defaults.go b/defaults.go index ed3168a3..808f5ab4 100644 --- a/defaults.go +++ b/defaults.go @@ -102,7 +102,7 @@ func (dns *Msg) SetAxfr(z string) *Msg { } // SetTsig appends a TSIG RR to the message. -// This is only a skeleton TSIG RR that is added as the last RR in the +// This is only a skeleton TSIG RR that is added as the last RR in the // additional section. The Tsig is calculated when the message is being send. func (dns *Msg) SetTsig(z, algo string, fudge, timesigned int64) *Msg { t := new(TSIG) @@ -115,7 +115,7 @@ func (dns *Msg) SetTsig(z, algo string, fudge, timesigned int64) *Msg { return dns } -// SetEdns0 appends a EDNS0 OPT RR to the message. +// SetEdns0 appends a EDNS0 OPT RR to the message. // TSIG should always the last RR in a message. func (dns *Msg) SetEdns0(udpsize uint16, do bool) *Msg { e := new(OPT) @@ -153,7 +153,7 @@ func (dns *Msg) IsEdns0() *OPT { } // IsDomainName checks if s is a valid domainname, it returns -// the number of labels, total length and true, when a domain name is valid. +// the number of labels, total length and true, when a domain name is valid. // When false is returned the labelcount and length are not defined. func IsDomainName(s string) (uint8, uint8, bool) { // copied from net package. // TODO(mg): check for \DDD @@ -250,9 +250,9 @@ func Fqdn(s string) string { // Copied from the official Go code -// ReverseAddr returns the in-addr.arpa. or ip6.arpa. hostname of the IP -// address addr suitable for rDNS (PTR) record lookup or an error if it fails -// to parse the IP address. +// ReverseAddr returns the in-addr.arpa. or ip6.arpa. hostname of the IP +// address addr suitable for rDNS (PTR) record lookup or an error if it fails +// to parse the IP address. func ReverseAddr(addr string) (arpa string, err error) { ip := net.ParseIP(addr) if ip == nil { @@ -262,9 +262,9 @@ func ReverseAddr(addr string) (arpa string, err error) { return strconv.Itoa(int(ip[15])) + "." + strconv.Itoa(int(ip[14])) + "." + strconv.Itoa(int(ip[13])) + "." + strconv.Itoa(int(ip[12])) + ".in-addr.arpa.", nil } - // Must be IPv6 + // Must be IPv6 buf := make([]byte, 0, len(ip)*4+len("ip6.arpa.")) - // Add it, in reverse, to the buffer + // Add it, in reverse, to the buffer for i := len(ip) - 1; i >= 0; i-- { v := ip[i] buf = append(buf, hexDigit[v&0xF]) @@ -272,7 +272,7 @@ func ReverseAddr(addr string) (arpa string, err error) { buf = append(buf, hexDigit[v>>4]) buf = append(buf, '.') } - // Append "ip6.arpa." and return (buf already has the final .) + // Append "ip6.arpa." and return (buf already has the final .) buf = append(buf, "ip6.arpa."...) return string(buf), nil } diff --git a/dns.go b/dns.go index b645919b..9a5e091c 100644 --- a/dns.go +++ b/dns.go @@ -8,7 +8,7 @@ // The package allows complete control over what is send out to the DNS. The package // API follows the less-is-more principle, by presenting a small, clean interface. // -// The package dns supports (asynchronous) querying/replying, incoming/outgoing AXFR/IXFR, +// The package dns supports (asynchronous) querying/replying, incoming/outgoing AXFR/IXFR, // TSIG, EDNS0, dynamic updates, notifies and DNSSEC validation/signing. // Note that domain names MUST be fully qualified, before sending them, unqualified // names in a message will result in a packing failure. @@ -68,7 +68,7 @@ // the authority section: in.Ns and the additional section: in.Extra. // // Each of these sections (except the Question section) contain a []RR. Basic -// use pattern for accessing the rdata of a TXT RR as the first RR in +// use pattern for accessing the rdata of a TXT RR as the first RR in // the Answer section: // // if t, ok := in.Answer[0].(*TXT); ok { diff --git a/dnssec.go b/dnssec.go index 87b7b0b0..dcfb5e1d 100644 --- a/dnssec.go +++ b/dnssec.go @@ -8,7 +8,7 @@ // // Requesting DNSSEC information for a zone is done by adding the DO (DNSSEC OK) bit // to an request. -// +// // m := new(dns.Msg) // m.SetEdns0(4096, true) // @@ -61,7 +61,7 @@ const ( const ( _ = iota SHA1 // RFC 4034 - SHA256 // RFC 4509 + SHA256 // RFC 4509 GOST94 // RFC 5933 SHA384 // Experimental SHA512 // Experimental @@ -309,7 +309,7 @@ func (rr *RRSIG) Sign(k PrivateKey, rrset []RR) error { // Verify validates an RRSet with the signature and key. This is only the // cryptographic test, the signature validity period must be checked separately. -// This function copies the rdata of some RRs (to lowercase domain names) for the validation to work. +// This function copies the rdata of some RRs (to lowercase domain names) for the validation to work. func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error { // First the easy checks if len(rrset) == 0 { @@ -423,7 +423,7 @@ func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error { return ErrAlg } -// ValidityPeriod uses RFC1982 serial arithmetic to calculate +// ValidityPeriod uses RFC1982 serial arithmetic to calculate // if a signature period is valid. func (rr *RRSIG) ValidityPeriod() bool { utc := time.Now().UTC().Unix() @@ -443,7 +443,7 @@ func (s *RRSIG) sigBuf() []byte { return sigbuf } -// setPublicKeyInPrivate sets the public key in the private key. +// setPublicKeyInPrivate sets the public key in the private key. func (k *DNSKEY) setPublicKeyInPrivate(p PrivateKey) bool { switch t := p.(type) { case *dsa.PrivateKey: @@ -606,7 +606,7 @@ func exponentToBuf(_E int) []byte { return buf } -// Set the public key for X and Y for Curve. The two +// Set the public key for X and Y for Curve. The two // values are just concatenated. func curveToBuf(_X, _Y *big.Int) []byte { buf := _X.Bytes() @@ -614,7 +614,7 @@ func curveToBuf(_X, _Y *big.Int) []byte { return buf } -// Set the public key for X and Y for Curve. The two +// Set the public key for X and Y for Curve. The two // values are just concatenated. func dsaToBuf(_Q, _P, _G, _Y *big.Int) []byte { t := byte((len(_G.Bytes()) - 64) / 8) diff --git a/dnssec_test.go b/dnssec_test.go index 3179c241..4228d1a8 100644 --- a/dnssec_test.go +++ b/dnssec_test.go @@ -220,7 +220,7 @@ Coefficient: UuRoNqe7YHnKmQzE6iDWKTMIWTuoqqrFAmXPmKQnC+Y+BQzOVEHUo9bXdDnoI9hzXP1 /* return // This key was generate with LDNS: - // ldns-keygen -a RSASHA256 -r /dev/urandom -b 1024 miek.nl + // ldns-keygen -a RSASHA256 -r /dev/urandom -b 1024 miek.nl // Show that we have al the RSA parameters and can check them // here to see what I came up with key := new(RR_DNSKEY) diff --git a/edns.go b/edns.go index e6f6804d..1aa6cace 100644 --- a/edns.go +++ b/edns.go @@ -1,7 +1,7 @@ // EDNS0 // -// EDNS0 is an extension mechanism for the DNS defined in RFC 2671. It defines a -// standard RR type, the OPT RR, which is then completely abused. +// EDNS0 is an extension mechanism for the DNS defined in RFC 2671. It defines a +// standard RR type, the OPT RR, which is then completely abused. // Basic use pattern for creating an (empty) OPT RR: // // o := new(dns.OPT) @@ -296,7 +296,7 @@ func (e *EDNS0_SUBNET) String() (s string) { // The UPDATE_LEASE EDNS0 (draft RFC) option is used to tell the server to set // an expiration on an update RR. This is helpful for clients that cannot clean // up after themselves. This is a draft RFC and more information can be found at -// http://files.dns-sd.org/draft-sekar-dns-ul.txt +// http://files.dns-sd.org/draft-sekar-dns-ul.txt // // o := new(dns.OPT) // o.Hdr.Name = "." diff --git a/keygen.go b/keygen.go index bcb74bc7..bc1a0797 100644 --- a/keygen.go +++ b/keygen.go @@ -17,7 +17,7 @@ const _FORMAT = "Private-key-format: v1.3\n" type PrivateKey interface{} // Generate generates a DNSKEY of the given bit size. -// The public part is put inside the DNSKEY record. +// The public part is put inside the DNSKEY record. // The Algorithm in the key must be set as this will define // what kind of DNSKEY will be generated. // The ECDSA algorithms imply a fixed keysize, in that case @@ -88,7 +88,7 @@ func (r *DNSKEY) Generate(bits int) (PrivateKey, error) { } // PrivateKeyString converts a PrivateKey to a string. This -// string has the same format as the private-key-file of BIND9 (Private-key-format: v1.3). +// string has the same format as the private-key-file of BIND9 (Private-key-format: v1.3). // It needs some info from the key (hashing, keytag), so its a method of the DNSKEY. func (r *DNSKEY) PrivateKeyString(p PrivateKey) (s string) { switch t := p.(type) { diff --git a/kscan.go b/kscan.go index 446e8811..e70396d3 100644 --- a/kscan.go +++ b/kscan.go @@ -10,13 +10,13 @@ import ( ) func (k *DNSKEY) NewPrivateKey(s string) (PrivateKey, error) { - if s[len(s)-1] != '\n' { // We need a closing newline + if s[len(s)-1] != '\n' { // We need a closing newline return k.ReadPrivateKey(strings.NewReader(s+"\n"), "") } return k.ReadPrivateKey(strings.NewReader(s), "") } -// NewPrivateKey reads a private key from the io.Reader q. The string file is +// NewPrivateKey reads a private key from the io.Reader q. The string file is // only used in error reporting. // The public key must be // known, because some cryptographics algorithms embed the public inside the privatekey. diff --git a/msg.go b/msg.go index c2f339b7..1d90fa33 100644 --- a/msg.go +++ b/msg.go @@ -129,8 +129,8 @@ var TypeToString = map[uint16]string{ TypeL32: "L32", TypeL64: "L64", TypeLP: "LP", - TypeEUI48: "EUI48", - TypeEUI64: "EUI64", + TypeEUI48: "EUI48", + TypeEUI64: "EUI64", TypeTKEY: "TKEY", // Meta RR TypeTSIG: "TSIG", // Meta RR TypeAXFR: "AXFR", // Meta RR @@ -183,14 +183,14 @@ var RcodeToString = map[int]string{ RcodeNXRrset: "NXRRSET", RcodeNotAuth: "NOTAUTH", RcodeNotZone: "NOTZONE", - RcodeBadSig: "BADSIG", // Also known as RcodeBadVers, see RFC 6891 -// RcodeBadVers: "BADVERS", - RcodeBadKey: "BADKEY", - RcodeBadTime: "BADTIME", - RcodeBadMode: "BADMODE", - RcodeBadName: "BADNAME", - RcodeBadAlg: "BADALG", - RcodeBadTrunc: "BADTRUNC", + RcodeBadSig: "BADSIG", // Also known as RcodeBadVers, see RFC 6891 + // RcodeBadVers: "BADVERS", + RcodeBadKey: "BADKEY", + RcodeBadTime: "BADTIME", + RcodeBadMode: "BADMODE", + RcodeBadName: "BADNAME", + RcodeBadAlg: "BADALG", + RcodeBadTrunc: "BADTRUNC", } // Rather than write the usual handful of routines to pack and @@ -639,7 +639,7 @@ func packStructValue(val reflect.Value, msg []byte, off int, compression map[str copy(msg[off:off+hex.DecodedLen(len(s))], h) off += hex.DecodedLen(len(s)) case `dns:"size"`: - // the size is already encoded in the RR, we can safely use the + // the size is already encoded in the RR, we can safely use the // length of string. String is RAW (not encoded in hex, nor base64) copy(msg[off:off+len(s)], s) off += len(s) @@ -1369,10 +1369,10 @@ func (dns *Msg) String() string { // Len return the message length when in (un)compressed wire format. // If dns.Compress is true compression it is taken into account, currently -// this only counts owner name compression. There is no check for +// this only counts owner name compression. There is no check for // nil valued sections (allocated, but contain no RRs). func (dns *Msg) Len() int { - // Message header is always 12 bytes + // Message header is always 12 bytes l := 12 var compression map[string]int if dns.Compress { diff --git a/server.go b/server.go index 963a37a9..f4ea2a58 100644 --- a/server.go +++ b/server.go @@ -194,7 +194,7 @@ func (mux *ServeMux) match(q string, t uint16) Handler { } lastbyte = q[i] } - // Check for the root zone too, this only delays NXDOMAIN, because if we serve . it + // Check for the root zone too, this only delays NXDOMAIN, because if we serve . it // will be catched above. if h, ok := mux.z["."]; ok { return h diff --git a/tlsa.go b/tlsa.go index 136b4b18..d3bc3b02 100644 --- a/tlsa.go +++ b/tlsa.go @@ -62,7 +62,7 @@ func (r *TLSA) Sign(usage, selector, matchingType int, cert *x509.Certificate) ( func (r *TLSA) Verify(cert *x509.Certificate) error { c, err := CertificateToDANE(r.Selector, r.MatchingType, cert) if err != nil { - return err // Not also ErrSig? + return err // Not also ErrSig? } if r.Certificate == c { return nil diff --git a/tsig.go b/tsig.go index 39b649f3..7aaade74 100644 --- a/tsig.go +++ b/tsig.go @@ -1,10 +1,10 @@ // TRANSACTION SIGNATURE (TSIG) // -// An TSIG or transaction signature adds a HMAC TSIG record to each message sent. +// An TSIG or transaction signature adds a HMAC TSIG record to each message sent. // The supported algorithms include: HmacMD5, HmacSHA1 and HmacSHA256. // // Basic use pattern when querying with a TSIG name "axfr." (note that these key names -// must be fully qualified - as they are domain names) and the base64 secret +// must be fully qualified - as they are domain names) and the base64 secret // "so6ZGir4GPAqINNh9U5c3A==": // // c := new(dns.Client) @@ -23,7 +23,7 @@ // c := new(dns.Client) // c.TsigSecret = map[string]string{"axfr.": "so6ZGir4GPAqINNh9U5c3A=="} // m := new(dns.Msg) -// m.SetAxfr("miek.nl.") +// m.SetAxfr("miek.nl.") // m.SetTsig("axfr.", dns.HmacMD5, 300, time.Now().Unix()) // t, err := c.TransferIn(m, "85.223.71.124:53") // for r := range t { /* ... */ } @@ -148,12 +148,12 @@ type timerWireFmt struct { // TsigGenerate fills out the TSIG record attached to the message. // The message should contain -// a "stub" TSIG RR with the algorithm, key name (owner name of the RR), +// a "stub" TSIG RR with the algorithm, key name (owner name of the RR), // time fudge (defaults to 300 seconds) and the current time // The TSIG MAC is saved in that Tsig RR. // When TsigGenerate is called for the first time requestMAC is set to the empty string and // timersOnly is false. -// If something goes wrong an error is returned, otherwise it is nil. +// If something goes wrong an error is returned, otherwise it is nil. func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) ([]byte, string, error) { if m.IsTsig() == nil { panic("dns: TSIG not last RR in additional") @@ -205,7 +205,7 @@ func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) ([]byte, s return mbuf, t.MAC, nil } -// TsigVerify verifies the TSIG on a message. +// TsigVerify verifies the TSIG on a message. // If the signature does not validate err contains the // error, otherwise it is nil. func TsigVerify(msg []byte, secret, requestMAC string, timersOnly bool) error { diff --git a/update.go b/update.go index 53986372..eb2bf5a7 100644 --- a/update.go +++ b/update.go @@ -1,12 +1,12 @@ // DYNAMIC UPDATES -// +// // 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. // // You can set a rather complex set of rules for the existence of absence of // certain resource records or names in a zone to specify if resource records -// should be added or removed. The table from RFC 2136 supplemented with the Go +// should be added or removed. The table from RFC 2136 supplemented with the Go // DNS function shows which functions exist to specify the prerequisites. // // 3.2.4 - Table Of Metavalues Used In Prerequisite Section @@ -18,21 +18,21 @@ // NONE ANY empty Name is not in use NameNotUsed // NONE rrset empty RRset does not exist RRsetNotUsed // zone rrset rr RRset exists (value dep) Used -// +// // The prerequisite section can also be left empty. // 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 functions to call. // // 3.4.2.6 - Table Of Metavalues Used In Update Section -// +// // CLASS TYPE RDATA Meaning Function // --------------------------------------------------------------- // ANY ANY empty Delete all RRsets from name RemoveName // ANY rrset empty Delete an RRset RemoveRRset // NONE rrset rr Delete an RR from RRset Remove // zone rrset rr Add to an RRset Insert -// +// package dns // NameUsed sets the RRs in the prereq section to diff --git a/xfr.go b/xfr.go index 1f0f588b..748deaf3 100644 --- a/xfr.go +++ b/xfr.go @@ -127,7 +127,7 @@ func (w *reply) ixfrIn(q *Msg, c chan *Envelope) { panic("dns: not reached") } -// Check if he SOA record exists in the Answer section of +// Check if he SOA record exists in the Answer section of // the packet. If first is true the first RR must be a SOA // if false, the last one should be a SOA. func checkXfrSOA(in *Msg, first bool) bool { @@ -147,7 +147,7 @@ func checkXfrSOA(in *Msg, first bool) bool { // Errors are signaled via the error pointer, when an error occurs the function // sets the error and returns (it does not close the channel). // TSIG and enveloping is handled by TransferOut. -// +// // Basic use pattern for sending an AXFR: // // // q contains the AXFR request diff --git a/zscan.go b/zscan.go index fa703e66..0d934244 100644 --- a/zscan.go +++ b/zscan.go @@ -84,7 +84,7 @@ func (e *ParseError) Error() (s string) { type lex struct { token string // text of the token - err bool // when true, token text has lexer error + err bool // when true, token text has lexer error value uint8 // value: _STRING, _BLANK, etc. line int // line in the file column int // column in the file @@ -119,15 +119,15 @@ func ReadRR(q io.Reader, filename string) (RR, error) { return r.RR, nil } -// ParseZone reads a RFC 1035 style one from r. It returns Tokens on the -// returned channel, which consist out the parsed RR, a potential comment or an error. +// ParseZone reads a RFC 1035 style one from r. It returns Tokens on the +// returned channel, which consist out the parsed RR, a potential comment or an error. // If there is an error the RR is nil. The string file is only used // in error reporting. The string origin is used as the initial origin, as // if the file would start with: $ORIGIN origin . // The directives $INCLUDE, $ORIGIN, $TTL and $GENERATE are supported. // The channel t is closed by ParseZone when the end of r is reached. // -// Basic usage pattern when reading from a string (z) containing the +// Basic usage pattern when reading from a string (z) containing the // zone data: // // for x := range dns.ParseZone(strings.NewReader(z), "", "") { @@ -137,10 +137,10 @@ func ReadRR(q io.Reader, filename string) (RR, error) { // } // // Comments specified after an RR (and on the same line!) are returned too: -// +// // foo. IN A 10.0.0.1 ; this is a comment // -// The text "; this is comment" is returned in Token.comment . Comments inside the +// The text "; this is comment" is returned in Token.comment . Comments inside the // RR are discarded. Comments on a line by themselves are discarded too. func ParseZone(r io.Reader, origin, file string) chan Token { return parseZoneHelper(r, origin, file, 10000) @@ -776,7 +776,7 @@ func classToInt(token string) (uint16, bool) { return uint16(class), true } -// Extract the rr number from TYPExxx +// Extract the rr number from TYPExxx func typeToInt(token string) (uint16, bool) { typ, ok := strconv.Atoi(token[4:]) if ok != nil { @@ -816,7 +816,7 @@ func stringToTtl(token string) (uint32, bool) { return s + i, true } -// Parse LOC records' [.][mM] into a +// Parse LOC records' [.][mM] into a // mantissa exponent format. Token should contain the entire // string (i.e. no spaces allowed) func stringToCm(token string) (e, m uint8, ok bool) { @@ -866,7 +866,7 @@ func appendOrigin(name, origin string) string { return name + "." + origin } -// LOC record helper function +// LOC record helper function func locCheckNorth(token string, latitude uint32) (uint32, bool) { switch token { case "n", "N": @@ -877,7 +877,7 @@ func locCheckNorth(token string, latitude uint32) (uint32, bool) { return latitude, false } -// LOC record helper function +// LOC record helper function func locCheckEast(token string, longitude uint32) (uint32, bool) { switch token { case "e", "E":