gofmt
This commit is contained in:
parent
2e0a4a5e34
commit
131f6962d1
|
@ -8,11 +8,11 @@
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"net"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Wraps the contents of the /etc/resolv.conf.
|
// Wraps the contents of the /etc/resolv.conf.
|
||||||
|
|
14
dnssec.go
14
dnssec.go
|
@ -33,8 +33,8 @@ const (
|
||||||
ECCGOST = 12
|
ECCGOST = 12
|
||||||
ECDSAP256SHA256 = 13
|
ECDSAP256SHA256 = 13
|
||||||
ECDSAP384SHA384 = 14
|
ECDSAP384SHA384 = 14
|
||||||
PRIVATEDNS = 253 // Private (experimental keys)
|
PRIVATEDNS = 253 // Private (experimental keys)
|
||||||
PRIVATEOID = 254
|
PRIVATEOID = 254
|
||||||
)
|
)
|
||||||
|
|
||||||
// DNSSEC hashing algorithm codes.
|
// DNSSEC hashing algorithm codes.
|
||||||
|
@ -307,9 +307,9 @@ func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset RRset) error {
|
||||||
signeddata = append(signeddata, wire...)
|
signeddata = append(signeddata, wire...)
|
||||||
|
|
||||||
sigbuf := s.sigBuf() // Get the binary signature data
|
sigbuf := s.sigBuf() // Get the binary signature data
|
||||||
if s.Algorithm == PRIVATEDNS {
|
if s.Algorithm == PRIVATEDNS {
|
||||||
// remove the domain name and assume its our
|
// remove the domain name and assume its our
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s.Algorithm {
|
switch s.Algorithm {
|
||||||
case RSASHA1, RSASHA1NSEC3SHA1, RSASHA256, RSASHA512, RSAMD5:
|
case RSASHA1, RSASHA1NSEC3SHA1, RSASHA256, RSASHA512, RSAMD5:
|
||||||
|
@ -515,6 +515,6 @@ var alg_str = map[uint8]string{
|
||||||
ECCGOST: "ECC-GOST",
|
ECCGOST: "ECC-GOST",
|
||||||
ECDSAP256SHA256: "ECDSAP256SHA256",
|
ECDSAP256SHA256: "ECDSAP256SHA256",
|
||||||
ECDSAP384SHA384: "ECDSAP384SHA384",
|
ECDSAP384SHA384: "ECDSAP384SHA384",
|
||||||
PRIVATEDNS: "PRIVATEDNS",
|
PRIVATEDNS: "PRIVATEDNS",
|
||||||
PRIVATEOID: "PRIVATEOID",
|
PRIVATEOID: "PRIVATEOID",
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSecure(t *testing.T) {
|
func TestSecure(t *testing.T) {
|
||||||
|
|
|
@ -47,12 +47,12 @@ func TestUpdateDelete(t *testing.T) {
|
||||||
if e != nil {
|
if e != nil {
|
||||||
t.Log("Failed: " + e.Error())
|
t.Log("Failed: " + e.Error())
|
||||||
t.Fail()
|
t.Fail()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if r != nil && r.Rcode != RcodeSuccess {
|
if r != nil && r.Rcode != RcodeSuccess {
|
||||||
t.Log("Failed: " + r.String())
|
t.Log("Failed: " + r.String())
|
||||||
t.Fail()
|
t.Fail()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.Log(r.String())
|
t.Log(r.String())
|
||||||
}
|
}
|
||||||
|
|
2
edns.go
2
edns.go
|
@ -1,8 +1,8 @@
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EDNS0 Option codes.
|
// EDNS0 Option codes.
|
||||||
|
|
10
keygen.go
10
keygen.go
|
@ -1,13 +1,13 @@
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"math/big"
|
|
||||||
"strconv"
|
|
||||||
"crypto/rsa"
|
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"crypto/rsa"
|
||||||
|
"io"
|
||||||
|
"math/big"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Empty interface that is used as a wrapper around all possible
|
// Empty interface that is used as a wrapper around all possible
|
||||||
|
@ -22,7 +22,7 @@ type PrivateKey interface{}
|
||||||
// bits should be set to the size of the algorithm.
|
// bits should be set to the size of the algorithm.
|
||||||
func (r *RR_DNSKEY) Generate(bits int) (PrivateKey, error) {
|
func (r *RR_DNSKEY) Generate(bits int) (PrivateKey, error) {
|
||||||
switch r.Algorithm {
|
switch r.Algorithm {
|
||||||
case RSAMD5, RSASHA1, RSASHA256, RSASHA1NSEC3SHA1:
|
case RSAMD5, RSASHA1, RSASHA256, RSASHA1NSEC3SHA1:
|
||||||
if bits < 512 || bits > 4096 {
|
if bits < 512 || bits > 4096 {
|
||||||
return nil, ErrKeySize
|
return nil, ErrKeySize
|
||||||
}
|
}
|
||||||
|
|
4
msg.go
4
msg.go
|
@ -347,13 +347,13 @@ func packStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok bool)
|
||||||
msg[off+1] = byte(fv.Index(13).Uint())
|
msg[off+1] = byte(fv.Index(13).Uint())
|
||||||
msg[off+2] = byte(fv.Index(14).Uint())
|
msg[off+2] = byte(fv.Index(14).Uint())
|
||||||
msg[off+3] = byte(fv.Index(15).Uint())
|
msg[off+3] = byte(fv.Index(15).Uint())
|
||||||
off += net.IPv4len
|
off += net.IPv4len
|
||||||
case net.IPv4len:
|
case net.IPv4len:
|
||||||
msg[off] = byte(fv.Index(0).Uint())
|
msg[off] = byte(fv.Index(0).Uint())
|
||||||
msg[off+1] = byte(fv.Index(1).Uint())
|
msg[off+1] = byte(fv.Index(1).Uint())
|
||||||
msg[off+2] = byte(fv.Index(2).Uint())
|
msg[off+2] = byte(fv.Index(2).Uint())
|
||||||
msg[off+3] = byte(fv.Index(3).Uint())
|
msg[off+3] = byte(fv.Index(3).Uint())
|
||||||
off += net.IPv4len
|
off += net.IPv4len
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
case "AAAA":
|
case "AAAA":
|
||||||
|
|
2
nsec3.go
2
nsec3.go
|
@ -1,9 +1,9 @@
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha1"
|
||||||
"hash"
|
"hash"
|
||||||
"strings"
|
"strings"
|
||||||
"crypto/sha1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type saltWireFmt struct {
|
type saltWireFmt struct {
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
// "os"
|
// "os"
|
||||||
// "time"
|
// "time"
|
||||||
// "bufio"
|
// "bufio"
|
||||||
|
"crypto/rsa"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"crypto/rsa"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSign(t *testing.T) {
|
func TestSign(t *testing.T) {
|
||||||
|
|
26
types.go
26
types.go
|
@ -684,10 +684,10 @@ func (rr *RR_NSEC3PARAM) String() string {
|
||||||
// saltString converts a NSECX salt to uppercase and
|
// saltString converts a NSECX salt to uppercase and
|
||||||
// returns "-" when it is empty
|
// returns "-" when it is empty
|
||||||
func saltString(s string) string {
|
func saltString(s string) string {
|
||||||
if len(s) == 0 {
|
if len(s) == 0 {
|
||||||
return "-"
|
return "-"
|
||||||
}
|
}
|
||||||
return strings.ToUpper(s)
|
return strings.ToUpper(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// See RFC 4408.
|
// See RFC 4408.
|
||||||
|
@ -807,26 +807,26 @@ func (rr *RR_TSIG) String() string {
|
||||||
// Translate the RRSIG's incep. and expir. time to the correct date.
|
// Translate the RRSIG's incep. and expir. time to the correct date.
|
||||||
// Taking into account serial arithmetic (RFC 1982)
|
// Taking into account serial arithmetic (RFC 1982)
|
||||||
func timeToDate(t uint32) string {
|
func timeToDate(t uint32) string {
|
||||||
//utc := time.Now().Unix()
|
//utc := time.Now().Unix()
|
||||||
//mod := (int64(t) - utc) / Year68
|
//mod := (int64(t) - utc) / Year68
|
||||||
|
|
||||||
// If needed assume wrap around(s)
|
// If needed assume wrap around(s)
|
||||||
return ""
|
return ""
|
||||||
/* TODO: new time api
|
/* TODO: new time api
|
||||||
ti := time.Unix(int64(t),0).Unix() + (mod * Year68) // abs()? TODO
|
ti := time.Unix(int64(t),0).Unix() + (mod * Year68) // abs()? TODO
|
||||||
return ti.Format("20060102150405")
|
return ti.Format("20060102150405")
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate the TSIG time signed into a date. There is no
|
// Translate the TSIG time signed into a date. There is no
|
||||||
// need for RFC1982 calculations as this date is 48 bits
|
// need for RFC1982 calculations as this date is 48 bits
|
||||||
func tsigTimeToDate(t uint64) string {
|
func tsigTimeToDate(t uint64) string {
|
||||||
// only use the lower 48 bits, TODO(mg), check for 48 bit size
|
// only use the lower 48 bits, TODO(mg), check for 48 bit size
|
||||||
return ""
|
return ""
|
||||||
/*
|
/*
|
||||||
ti := time.Unix(int64(t), 0).Unix()
|
ti := time.Unix(int64(t), 0).Unix()
|
||||||
return ti.Format("20060102150405")
|
return ti.Format("20060102150405")
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map of constructors for each RR wire type.
|
// Map of constructors for each RR wire type.
|
||||||
|
|
|
@ -53,7 +53,7 @@ func (u *Msg) Additional() []RR {
|
||||||
// NewUpdate creates a new DNS update packet, which is a normal DNS message.
|
// NewUpdate creates a new DNS update packet, which is a normal DNS message.
|
||||||
func NewUpdate(zone string, class uint16) *Msg {
|
func NewUpdate(zone string, class uint16) *Msg {
|
||||||
u := new(Msg)
|
u := new(Msg)
|
||||||
u.MsgHdr.Response = false
|
u.MsgHdr.Response = false
|
||||||
u.MsgHdr.Opcode = OpcodeUpdate
|
u.MsgHdr.Opcode = OpcodeUpdate
|
||||||
u.Question = make([]Question, 1)
|
u.Question = make([]Question, 1)
|
||||||
u.Question[0] = Question{zone, TypeSOA, class}
|
u.Question[0] = Question{zone, TypeSOA, class}
|
||||||
|
|
16
zparse.go
16
zparse.go
|
@ -7,9 +7,9 @@ package dns
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
// "net"
|
// "net"
|
||||||
"time"
|
|
||||||
"strings"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const _IOBUF = MaxMsgSize
|
const _IOBUF = MaxMsgSize
|
||||||
|
@ -63,12 +63,12 @@ func dateToTime(s string) (uint32, error) {
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return 0, e
|
return 0, e
|
||||||
}
|
}
|
||||||
return 0, nil
|
return 0, nil
|
||||||
/*
|
/*
|
||||||
mod := t.Seconds() / Year68
|
mod := t.Seconds() / Year68
|
||||||
ti := uint32(t.Seconds() - (mod * Year68))
|
ti := uint32(t.Seconds() - (mod * Year68))
|
||||||
return ti, nil
|
return ti, nil
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the rdata fields as a string slice.
|
// Return the rdata fields as a string slice.
|
||||||
|
|
Loading…
Reference in New Issue