Commit 5d1ee52e authored by ale's avatar ale

godep update && save -r

parent 9dc3b40d
{
"ImportPath": "git.autistici.org/ale/autoradio",
"GoVersion": "go1.4",
"GoVersion": "go1.5.1",
"Packages": [
"./..."
],
......@@ -44,7 +44,7 @@
},
{
"ImportPath": "github.com/miekg/dns",
"Rev": "9de5f8465098a64dc05730a954dfa7a2f76f4353"
"Rev": "874ec871288a738d8d87fd5cec1dd71e88fdacb2"
},
{
"ImportPath": "github.com/nu7hatch/gouuid",
......@@ -52,7 +52,7 @@
},
{
"ImportPath": "github.com/ugorji/go/codec",
"Rev": "03e33114d4d60a1f37150325e15f51b0fa6fc4f6"
"Rev": "5abd4e96a45c386928ed2ca2a7ef63e2533e18ec"
}
]
}
......@@ -17,10 +17,10 @@ import (
"net/http"
"time"
"github.com/PuerkitoBio/ghost/handlers"
"github.com/PuerkitoBio/ghost/templates"
_ "github.com/PuerkitoBio/ghost/templates/amber"
_ "github.com/PuerkitoBio/ghost/templates/gotpl"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/PuerkitoBio/ghost/handlers"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/PuerkitoBio/ghost/templates"
_ "git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/PuerkitoBio/ghost/templates/amber"
_ "git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/PuerkitoBio/ghost/templates/gotpl"
"github.com/bmizerany/pat"
)
......
......@@ -7,7 +7,7 @@ import (
"strconv"
"time"
"github.com/PuerkitoBio/ghost"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/PuerkitoBio/ghost"
)
// FaviconHandlerFunc is the same as FaviconHandler, it is just a convenience
......
......@@ -10,7 +10,7 @@ import (
"strings"
"time"
"github.com/PuerkitoBio/ghost"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/PuerkitoBio/ghost"
)
const (
......
......@@ -5,7 +5,7 @@ import (
"errors"
"time"
"github.com/garyburd/redigo/redis"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/garyburd/redigo/redis"
)
var (
......
......@@ -8,9 +8,9 @@ import (
"strings"
"time"
"github.com/PuerkitoBio/ghost"
"github.com/gorilla/securecookie"
"github.com/nu7hatch/gouuid"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/PuerkitoBio/ghost"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gorilla/securecookie"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/nu7hatch/gouuid"
)
const defaultCookieName = "ghost.sid"
......
package amber
import (
"github.com/PuerkitoBio/ghost/templates"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/PuerkitoBio/ghost/templates"
"github.com/eknkc/amber"
)
......
......@@ -3,7 +3,7 @@ package gotpl
import (
"html/template"
"github.com/PuerkitoBio/ghost/templates"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/PuerkitoBio/ghost/templates"
)
// The template compiler for native Go templates.
......
......@@ -9,7 +9,7 @@ import (
"path/filepath"
"sync"
"github.com/PuerkitoBio/ghost"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/PuerkitoBio/ghost"
)
var (
......
......@@ -18,7 +18,7 @@ package main
import (
"fmt"
"github.com/aryann/difflib"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/aryann/difflib"
"html"
"html/template"
"io/ioutil"
......
......@@ -2,7 +2,7 @@ package main
import (
"fmt"
"github.com/cactus/go-statsd-client/statsd"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/cactus/go-statsd-client/statsd"
flags "github.com/jessevdk/go-flags"
"log"
"os"
......
......@@ -8,7 +8,7 @@ package etcd
import (
"errors"
"fmt"
codec1978 "github.com/ugorji/go/codec"
codec1978 "git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/ugorji/go/codec"
"net/http"
"reflect"
"runtime"
......
......@@ -7,7 +7,7 @@ import (
"strconv"
"time"
"github.com/ugorji/go/codec"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/ugorji/go/codec"
)
const (
......
......@@ -6,7 +6,7 @@ import (
"strings"
"testing"
"github.com/ugorji/go/codec"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/ugorji/go/codec"
)
func createTestNode(size int) *Node {
......
......@@ -24,7 +24,7 @@ import (
"testing"
"time"
"github.com/garyburd/redigo/redis"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/garyburd/redigo/redis"
)
var writeTests = []struct {
......
......@@ -16,7 +16,7 @@ package redis_test
import (
"fmt"
"github.com/garyburd/redigo/redis"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/garyburd/redigo/redis"
"net"
"reflect"
"sync"
......
......@@ -19,7 +19,7 @@ import (
"reflect"
"testing"
"github.com/garyburd/redigo/redis"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/garyburd/redigo/redis"
)
type valueError struct {
......
......@@ -16,7 +16,7 @@ package redis_test
import (
"fmt"
"github.com/garyburd/redigo/redis"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/garyburd/redigo/redis"
"math"
"reflect"
"testing"
......
......@@ -16,7 +16,7 @@ package redis_test
import (
"fmt"
"github.com/garyburd/redigo/redis"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/garyburd/redigo/redis"
"reflect"
"testing"
"time"
......
......@@ -16,7 +16,7 @@ package redis_test
import (
"fmt"
"github.com/garyburd/redigo/redis"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/garyburd/redigo/redis"
)
// zpop pops a value from the ZSET key using WATCH/MULTI/EXEC commands.
......
......@@ -19,7 +19,7 @@ import (
"strings"
"text/template"
"github.com/gonuts/flag"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/flag"
)
// UsageSection differentiates between sections in the usage text.
......
......@@ -3,8 +3,8 @@ package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/commander"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/flag"
)
var cmd_cmd1 = &commander.Command{
......
......@@ -3,8 +3,8 @@ package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/commander"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/flag"
)
func ex_make_cmd_cmd2() *commander.Command {
......
package main
import (
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/commander"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/flag"
)
var cmd_subcmd1 = &commander.Command{
......
......@@ -3,8 +3,8 @@ package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/commander"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/flag"
)
var cmd_subcmd1_cmd1 = &commander.Command{
......
......@@ -3,8 +3,8 @@ package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/commander"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/flag"
)
var cmd_subcmd1_cmd2 = &commander.Command{
......
package main
import (
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/commander"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/flag"
)
func ex_make_cmd_subcmd2() *commander.Command {
......
......@@ -3,8 +3,8 @@ package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/commander"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/flag"
)
func ex_make_cmd_subcmd2_cmd1() *commander.Command {
......
......@@ -3,8 +3,8 @@ package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/commander"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/flag"
)
func ex_make_cmd_subcmd2_cmd2() *commander.Command {
......
......@@ -4,7 +4,7 @@ import (
"fmt"
"os"
"github.com/gonuts/commander"
"git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/commander"
)
var g_cmd = &commander.Command{
......
......@@ -13,7 +13,7 @@ import (
"testing"
"time"
. "github.com/gonuts/flag"
. "git.autistici.org/ale/autoradio/Godeps/_workspace/src/github.com/gonuts/flag"
)
var (
......
language: go
sudo: false
go:
- 1.3
- 1.4
- 1.5
script:
- go test -short -bench=.
- go test -race -bench=.
......@@ -39,6 +39,10 @@ A not-so-up-to-date-list-that-may-be-actually-current:
* https://github.com/tianon/rawdns
* https://mesosphere.github.io/mesos-dns/
* https://pulse.turbobytes.com/
* https://play.google.com/store/apps/details?id=com.turbobytes.dig
* https://github.com/fcambus/statzone
* https://github.com/benschw/dns-clb-go
* https://github.com/corny/dnscheck for http://public-dns.tk/
Send pull request if you want to be listed here.
......@@ -82,7 +86,7 @@ Example programs can be found in the `github.com/miekg/exdns` repository.
*all of them*
* 103{4,5} - DNS standard
* 1348 - NSAP record
* 1348 - NSAP record (removed the record)
* 1982 - Serial Arithmetic
* 1876 - LOC record
* 1995 - IXFR
......@@ -139,7 +143,7 @@ Example programs can be found in the `github.com/miekg/exdns` repository.
## TODO
* privatekey.Precompute() when signing?
* Last remaining RRs: APL, ATMA, A6 and NXT.
* Missing in parsing: ISDN, UNSPEC, ATMA.
* Last remaining RRs: APL, ATMA, A6, NSAP and NXT.
* Missing in parsing: ISDN, UNSPEC, NSAP and ATMA.
* NSEC(3) cover/match/closest enclose.
* Replies with TC bit are not parsed to the end.
......@@ -42,7 +42,7 @@ type Client struct {
//
// co := &dns.Conn{Conn: c} // c is your net.Conn
// co.WriteMsg(m)
// in, err := co.ReadMsg()
// in, err := co.ReadMsg()
// co.Close()
//
func Exchange(m *Msg, a string) (r *Msg, err error) {
......
......@@ -88,7 +88,6 @@ func TestClientEDNS0(t *testing.T) {
// Validates the transmission and parsing of local EDNS0 options.
func TestClientEDNS0Local(t *testing.T) {
optStr1 := "1979:0x0707"
optStr2 := strconv.Itoa(EDNS0LOCALSTART) + ":0x0601"
......@@ -149,65 +148,19 @@ func TestClientEDNS0Local(t *testing.T) {
// Validate the local options in the reply.
got := r.Extra[1].(*OPT).Option[0].(*EDNS0_LOCAL).String()
if got != optStr1 {
t.Log("failed to get local edns0 answer; got %s, expected %s", got, optStr1)
t.Logf("failed to get local edns0 answer; got %s, expected %s", got, optStr1)
t.Fail()
t.Logf("%v\n", r)
}
got = r.Extra[1].(*OPT).Option[1].(*EDNS0_LOCAL).String()
if got != optStr2 {
t.Log("failed to get local edns0 answer; got %s, expected %s", got, optStr2)
t.Logf("failed to get local edns0 answer; got %s, expected %s", got, optStr2)
t.Fail()
t.Logf("%v\n", r)
}
}
func TestSingleSingleInflight(t *testing.T) {
HandleFunc("miek.nl.", HelloServer)
defer HandleRemove("miek.nl.")
s, addrstr, err := RunLocalUDPServer("127.0.0.1:0")
if err != nil {
t.Fatalf("Unable to run test server: %v", err)
}
defer s.Shutdown()
m := new(Msg)
m.SetQuestion("miek.nl.", TypeDNSKEY)
c := new(Client)
c.SingleInflight = true
nr := 10
ch := make(chan time.Duration)
for i := 0; i < nr; i++ {
go func() {
_, rtt, _ := c.Exchange(m, addrstr)
ch <- rtt
}()
}
i := 0
var first time.Duration
// With inflight *all* rtt are identical, and by doing actual lookups
// the changes that this is a coincidence is small.
Loop:
for {
select {
case rtt := <-ch:
if i == 0 {
first = rtt
} else {
if first != rtt {
t.Errorf("all rtts should be equal. got %d want %d", rtt, first)
}
}
i++
if i == 10 {
break Loop
}
}
}
}
// ExampleUpdateLeaseTSIG shows how to update a lease signed with TSIG.
func ExampleUpdateLeaseTSIG(t *testing.T) {
m := new(Msg)
......@@ -282,5 +235,4 @@ func TestClientConn(t *testing.T) {
if err = r.Unpack(buf); err != nil {
t.Errorf("unable to unpack message fully: %v", err)
}
}
......@@ -150,11 +150,14 @@ func (dns *Msg) IsEdns0() *OPT {
return nil
}
// IsDomainName checks if s is a valid domainname, it returns
// the number of labels and true, when a domain name is valid.
// Note that non fully qualified domain name is considered valid, in this case the
// last label is counted in the number of labels.
// When false is returned the number of labels is not defined.
// IsDomainName checks if s is a valid domain name, it returns the number of
// labels and true, when a domain name is valid. Note that non fully qualified
// domain name is considered valid, in this case the last label is counted in
// the number of labels. When false is returned the number of labels is not
// defined. Also note that this function is extremely liberal; almost any
// string is a valid domain name as the DNS is 8 bit protocol. It checks if each
// label fits in 63 characters, but there is no length check for the entire
// string s. I.e. a domain name longer than 255 characters is considered valid.
func IsDomainName(s string) (labels int, ok bool) {
_, labels, err := packDomainName(s, nil, 0, nil, false)
return labels, err == nil
......
......@@ -36,9 +36,7 @@ type RR interface {
len() int
}
// DNS resource records.
// There are many types of RRs,
// but they all share the same header.
// RR_Header is the header all DNS resource records share.
type RR_Header struct {
Name string `dns:"cdomain-name"`
Rrtype uint16
......
......@@ -6,14 +6,14 @@ import (
"crypto/dsa"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/md5"
_ "crypto/md5"
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
_ "crypto/sha1"
_ "crypto/sha256"
_ "crypto/sha512"
"encoding/asn1"
"encoding/hex"
"hash"
"io"
"math/big"
"sort"
"strings"
......@@ -42,6 +42,38 @@ const (
PRIVATEOID uint8 = 254
)
// Map for algorithm names.
var AlgorithmToString = map[uint8]string{
RSAMD5: "RSAMD5",
DH: "DH",
DSA: "DSA",
RSASHA1: "RSASHA1",
DSANSEC3SHA1: "DSA-NSEC3-SHA1",
RSASHA1NSEC3SHA1: "RSASHA1-NSEC3-SHA1",
RSASHA256: "RSASHA256",
RSASHA512: "RSASHA512",
ECCGOST: "ECC-GOST",
ECDSAP256SHA256: "ECDSAP256SHA256",
ECDSAP384SHA384: "ECDSAP384SHA384",
INDIRECT: "INDIRECT",
PRIVATEDNS: "PRIVATEDNS",
PRIVATEOID: "PRIVATEOID",
}
// Map of algorithm strings.
var StringToAlgorithm = reverseInt8(AlgorithmToString)
// Map of algorithm crypto hashes.
var AlgorithmToHash = map[uint8]crypto.Hash{
RSAMD5: crypto.MD5, // Deprecated in RFC 6725
RSASHA1: crypto.SHA1,
RSASHA1NSEC3SHA1: crypto.SHA1,
RSASHA256: crypto.SHA256,
ECDSAP256SHA256: crypto.SHA256,
ECDSAP384SHA384: crypto.SHA384,
RSASHA512: crypto.SHA512,
}
// DNSSEC hashing algorithm codes.
const (
_ uint8 = iota
......@@ -52,6 +84,18 @@ const (
SHA512 // Experimental
)
// Map for hash names.
var HashToString = map[uint8]string{
SHA1: "SHA1",
SHA256: "SHA256",
GOST94: "GOST94",
SHA384: "SHA384",
SHA512: "SHA512",
}
// Map of hash strings.
var StringToHash = reverseInt8(HashToString)
// DNSKEY flag values.
const (
SEP = 1
......@@ -168,24 +212,23 @@ func (k *DNSKEY) ToDS(h uint8) *DS {
// digest buffer
digest := append(owner, wire...) // another copy
var hash crypto.Hash
switch h {
case SHA1:
s := sha1.New()
io.WriteString(s, string(digest))
ds.Digest = hex.EncodeToString(s.Sum(nil))
hash = crypto.SHA1
case SHA256:
s := sha256.New()
io.WriteString(s, string(digest))
ds.Digest = hex.EncodeToString(s.Sum(nil))
hash = crypto.SHA256
case SHA384:
s := sha512.New384()
io.WriteString(s, string(digest))
ds.Digest = hex.EncodeToString(s.Sum(nil))
case GOST94:
/* I have no clue */
hash = crypto.SHA384
case SHA512:
hash = crypto.SHA512
default:
return nil
}
s := hash.New()
s.Write(digest)
ds.Digest = hex.EncodeToString(s.Sum(nil))
return ds
}
......@@ -212,7 +255,7 @@ func (d *DS) ToCDS() *CDS {
// There is no check if RRSet is a proper (RFC 2181) RRSet.
// If OrigTTL is non zero, it is used as-is, otherwise the TTL of the RRset
// is used as the OrigTTL.
func (rr *RRSIG) Sign(k PrivateKey, rrset []RR) error {
func (rr *RRSIG) Sign(k crypto.Signer, rrset []RR) error {
if k == nil {
return ErrPrivKey
}
......@@ -258,39 +301,66 @@ func (rr *RRSIG) Sign(k PrivateKey, rrset []RR) error {
}
signdata = append(signdata, wire...)
var h hash.Hash
switch rr.Algorithm {
case DSA, DSANSEC3SHA1:
// TODO: this seems bugged, will panic
case RSASHA1, RSASHA1NSEC3SHA1:
h = sha1.New()
case RSASHA256, ECDSAP256SHA256:
h = sha256.New()
case ECDSAP384SHA384:
h = sha512.New384()
case RSASHA512:
h = sha512.New()
case RSAMD5:
fallthrough // Deprecated in RFC 6725
default:
hash, ok := AlgorithmToHash[rr.Algorithm]
if !ok {
return ErrAlg
}
_, err = h.Write(signdata)
if err != nil {
return err
}
sighash := h.Sum(nil)
h := hash.New()
h.Write(signdata)
signature, err := k.Sign(sighash, rr.Algorithm)
signature, err := sign(k, h.Sum(nil), hash, rr.Algorithm)
if err != nil {
return err
}
rr.Signature = toBase64(signature)
return nil
}
func sign(k crypto.Signer, hashed []byte, hash crypto.Hash, alg uint8) ([]byte, error) {
signature, err := k.Sign(rand.Reader, hashed, hash)
if err != nil</