From 3611c4d458602148e3ffa3b4b8c110eb56a934bc Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 5 May 2012 17:37:48 +0200 Subject: [PATCH] fmt --- dnssec.go | 10 +++++----- keygen.go | 6 +++--- kscan.go | 6 +++--- msg.go | 12 ++++++------ parse_test.go | 6 ++---- tsig.go | 2 +- zscan_rr.go | 6 +++--- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/dnssec.go b/dnssec.go index 360eeb49..4e41dfa1 100644 --- a/dnssec.go +++ b/dnssec.go @@ -106,7 +106,7 @@ func (k *RR_DNSKEY) KeyTag() uint16 { // item in the pubkey. We could do this faster by looking directly // at the base64 values. But I'm lazy. modulus, _ := packBase64([]byte(k.PublicKey)) - if (len(modulus) > 1) { + if len(modulus) > 1 { x, _ := unpackUint16(modulus, len(modulus)-2) keytag = int(x) } @@ -279,7 +279,7 @@ func (s *RR_RRSIG) Sign(k PrivateKey, rrset []RR) error { if err != nil { return err } - signature := []byte{0x4D} // T value, here the ASCII M for Miek (not used in DNSSEC) + signature := []byte{0x4D} // T value, here the ASCII M for Miek (not used in DNSSEC) signature = append(signature, r1.Bytes()...) signature = append(signature, s1.Bytes()...) s.Signature = unpackBase64(signature) @@ -545,11 +545,11 @@ func (k *RR_DNSKEY) publicKeyDSA() *dsa.PublicKey { pubkey.Parameters.Q = big.NewInt(0) pubkey.Parameters.Q.SetBytes(keybuf[1:21]) // +/- 1 ? pubkey.Parameters.P = big.NewInt(0) - pubkey.Parameters.P.SetBytes(keybuf[22:22+size]) + pubkey.Parameters.P.SetBytes(keybuf[22 : 22+size]) pubkey.Parameters.G = big.NewInt(0) - pubkey.Parameters.G.SetBytes(keybuf[22+size+1:22+size*2]) + pubkey.Parameters.G.SetBytes(keybuf[22+size+1 : 22+size*2]) pubkey.Y = big.NewInt(0) - pubkey.Y.SetBytes(keybuf[22+size*2+1:22+size*3]) + pubkey.Y.SetBytes(keybuf[22+size*2+1 : 22+size*3]) return pubkey } diff --git a/keygen.go b/keygen.go index b472d9bd..9028e44c 100644 --- a/keygen.go +++ b/keygen.go @@ -1,11 +1,11 @@ package dns import ( + "crypto/dsa" "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "crypto/rsa" - "crypto/dsa" "math/big" "strconv" ) @@ -125,7 +125,7 @@ func (r *RR_DNSKEY) PrivateKeyString(p PrivateKey) (s string) { "Exponent2: " + exponent2 + "\n" + "Coefficient: " + coefficient + "\n" case *ecdsa.PrivateKey: - algorithm := strconv.Itoa(int(r.Algorithm)) + " (" + Alg_str[r.Algorithm] + ")" + algorithm := strconv.Itoa(int(r.Algorithm)) + " (" + Alg_str[r.Algorithm] + ")" private := unpackBase64(t.D.Bytes()) s = _FORMAT + "Algorithm: " + algorithm + "\n" + @@ -136,7 +136,7 @@ func (r *RR_DNSKEY) PrivateKeyString(p PrivateKey) (s string) { subprime := unpackBase64(t.PublicKey.Parameters.Q.Bytes()) base := unpackBase64(t.PublicKey.Parameters.G.Bytes()) priv := unpackBase64(t.X.Bytes()) - pub := unpackBase64(t.PublicKey.Y.Bytes()) + pub := unpackBase64(t.PublicKey.Y.Bytes()) s = _FORMAT + "Algorithm: " + algorithm + "\n" + "Prime(p): " + prime + "\n" + diff --git a/kscan.go b/kscan.go index c41e16b4..2efd8353 100644 --- a/kscan.go +++ b/kscan.go @@ -1,9 +1,9 @@ package dns import ( + "crypto/dsa" "crypto/ecdsa" "crypto/rsa" - "crypto/dsa" "io" "math/big" "strings" @@ -155,8 +155,8 @@ func readPrivateKeyECDSA(m map[string]string) (PrivateKey, error) { } func readPrivateKeyGOST(m map[string]string) (PrivateKey, error) { -// p := new(ecdsa.PrivateKey) -// p.D = big.NewInt(0) + // p := new(ecdsa.PrivateKey) + // p.D = big.NewInt(0) // Need to check if we have everything for k, v := range m { switch k { diff --git a/msg.go b/msg.go index a5953a72..71a38a6b 100644 --- a/msg.go +++ b/msg.go @@ -80,12 +80,12 @@ type MsgHdr struct { // The layout of a DNS message. type Msg struct { MsgHdr - Compress bool // If true, the message will be compressed when converted to wire format. - RemoteAddr net.Addr // The remote address. Either the server or the client connecting. - Question []Question // Holds the RR(s) of the question section. - Answer []RR // Holds the RR(s) of the answer section. - Ns []RR // Holds the RR(s) of the authority section. - Extra []RR // Holds the RR(s) of the additional section. + Compress bool // If true, the message will be compressed when converted to wire format. + RemoteAddr net.Addr // The remote address. Either the server or the client connecting. + Question []Question // Holds the RR(s) of the question section. + Answer []RR // Holds the RR(s) of the answer section. + Ns []RR // Holds the RR(s) of the authority section. + Extra []RR // Holds the RR(s) of the additional section. } // Map of strings for each RR wire type. diff --git a/parse_test.go b/parse_test.go index 069175f2..b6ad21ac 100644 --- a/parse_test.go +++ b/parse_test.go @@ -253,10 +253,8 @@ func TestParseNSEC(t *testing.T) { func TestParseLOC(t *testing.T) { lt := map[string]string{ - "SW1A2AA.find.me.uk. LOC 51 30 12.748 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m": - "SW1A2AA.find.me.uk.\t3600\tIN\tLOC\t51 30 12.748 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m", - "SW1A2AA.find.me.uk. LOC 51 0 0.0 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m": - "SW1A2AA.find.me.uk.\t3600\tIN\tLOC\t51 00 0.000 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m", + "SW1A2AA.find.me.uk. LOC 51 30 12.748 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m": "SW1A2AA.find.me.uk.\t3600\tIN\tLOC\t51 30 12.748 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m", + "SW1A2AA.find.me.uk. LOC 51 0 0.0 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m": "SW1A2AA.find.me.uk.\t3600\tIN\tLOC\t51 00 0.000 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m", } for i, o := range lt { rr, e := NewRR(i) diff --git a/tsig.go b/tsig.go index 8bac6d21..eb85a481 100644 --- a/tsig.go +++ b/tsig.go @@ -250,7 +250,7 @@ func tsigBuffer(msgbuf []byte, rr *RR_TSIG, requestMAC string, timersOnly bool) m := new(macWireFmt) m.MACSize = uint16(len(requestMAC) / 2) m.MAC = requestMAC - buf = make([]byte, len(requestMAC)) // long enough + buf = make([]byte, len(requestMAC)) // long enough n, _ := packStruct(m, buf, 0) buf = buf[:n] } diff --git a/zscan_rr.go b/zscan_rr.go index 090bc9c5..d07edd4d 100644 --- a/zscan_rr.go +++ b/zscan_rr.go @@ -455,9 +455,9 @@ func setLOC(h RR_Header, c chan lex, f string) (RR, *ParseError) { rr := new(RR_LOC) rr.Hdr = h // Non zero defaults for LOC record, see RFC 1876, Section 3. - rr.HorizPre = 165 // 10000 - rr.VertPre = 162 // 10 - rr.Size = 18 // 1 + rr.HorizPre = 165 // 10000 + rr.VertPre = 162 // 10 + rr.Size = 18 // 1 ok := false // North l := <-c