This commit is contained in:
Adam Harrison committed 2015-03-26 10:54:46 +00:00
1 parent 066d8001dd
commit efb7c0f1bc
7 files changed
+24 -24

No files matched your search

+1 -1
View File
@@ -19,7 +19,7 @@ var (
)
const (
defPendingTimeout int = 5 // timeout for a resolution
defPendingTimeout int = 5 // timeout for a resolution
)
type entryStatus uint8
+7 -7
View File
@@ -108,7 +108,7 @@ func TestCacheEntries(t *testing.T) {
t.Logf("Received '%s'", resp.Answer[0])
wt.AssertType(t, resp.Answer[0], (*dns.A)(nil), "DNS record")
ttlGet2 := resp.Answer[0].Header().Ttl
wt.AssertEqualInt(t, int(ttlGet1 - ttlGet2), 1, "TTL difference")
wt.AssertEqualInt(t, int(ttlGet1-ttlGet2), 1, "TTL difference")
timeGet3 := timeGet1.Add(time.Duration(localTTL) * time.Second)
t.Logf("Checking that a third Get(), after %d second, gets no result", localTTL)
@@ -124,9 +124,9 @@ func TestCacheEntries(t *testing.T) {
l.Put(questionMsg, replyTemp, 0, time.Now())
lenBefore := l.Len()
l.Remove(question)
wt.AssertEqualInt(t, l.Len(), lenBefore - 1, "cache length")
wt.AssertEqualInt(t, l.Len(), lenBefore-1, "cache length")
l.Remove(question) // do it again: should have no effect...
wt.AssertEqualInt(t, l.Len(), lenBefore - 1, "cache length")
wt.AssertEqualInt(t, l.Len(), lenBefore-1, "cache length")
resp, err = l.Get(questionMsg, minUdpSize, timeGet1)
wt.AssertNoErr(t, err)
@@ -149,7 +149,7 @@ func TestCacheEntries(t *testing.T) {
wt.AssertEqualString(t, resp.Answer[0].(*dns.A).A.String(), "10.0.1.3", "IP address")
wt.AssertEqualInt(t, int(resp.Answer[0].Header().Ttl), int(localTTL), "TTL")
resp, err = l.Get(questionMsg, minUdpSize, timePut3.Add(time.Duration(localTTL - 1) * time.Second))
resp, err = l.Get(questionMsg, minUdpSize, timePut3.Add(time.Duration(localTTL-1)*time.Second))
wt.AssertNoErr(t, err)
wt.AssertTrue(t, resp != nil, "reponse from the Get()")
t.Logf("Received '%s'", resp.Answer[0])
@@ -159,13 +159,13 @@ func TestCacheEntries(t *testing.T) {
t.Logf("Checking we get empty replies when they are expired...")
lenBefore = l.Len()
resp, err = l.Get(questionMsg, minUdpSize, timePut3.Add(time.Duration(localTTL) * time.Second))
resp, err = l.Get(questionMsg, minUdpSize, timePut3.Add(time.Duration(localTTL)*time.Second))
wt.AssertNoErr(t, err)
if resp != nil {
t.Logf("Received '%s'", resp.Answer[0])
t.Fatalf("ERROR: Did NOT expect a reponse from the Get()")
}
wt.AssertEqualInt(t, l.Len(), lenBefore - 1, "cache length (after getting an expired entry)")
wt.AssertEqualInt(t, l.Len(), lenBefore-1, "cache length (after getting an expired entry)")
questionMsg2 := new(dns.Msg)
questionMsg2.SetQuestion("some.other.name", dns.TypeA)
@@ -200,7 +200,7 @@ func TestCacheEntries(t *testing.T) {
wt.AssertNil(t, resp, "Get() response with CacheNoLocalReplies")
wt.AssertNotNil(t, err, "Get() error with CacheNoLocalReplies")
timeExpiredGet3 := timePut3.Add(time.Second * time.Duration(negLocalTTL + 1))
timeExpiredGet3 := timePut3.Add(time.Second * time.Duration(negLocalTTL+1))
t.Logf("Checking that we get an expired response after %f seconds", timeExpiredGet3.Sub(timePut3).Seconds())
resp, err = l.Get(questionMsg3, minUdpSize, timeExpiredGet3)
wt.AssertNil(t, resp, "expired Get() response with CacheNoLocalReplies")
+4 -4
View File
@@ -6,10 +6,10 @@ import (
)
const (
localTTL uint32 = 30 // somewhat arbitrary; we don't expect anyone downstream to cache results
negLocalTTL = 30 // TTL for negative local resolutions
minUdpSize = 512
maxUdpSize = 65535
localTTL uint32 = 30 // somewhat arbitrary; we don't expect anyone downstream to cache results
negLocalTTL = 30 // TTL for negative local resolutions
minUdpSize = 512
maxUdpSize = 65535
)
func makeHeader(r *dns.Msg, q *dns.Question) *dns.RR_Header {
+3 -3
View File
@@ -2,13 +2,13 @@ package nameserver
import (
"fmt"
"github.com/gorilla/mux"
"github.com/miekg/dns"
. "github.com/zettio/weave/common"
"io"
"log"
"net"
"net/http"
"github.com/gorilla/mux"
)
func httpErrorAndLog(level *log.Logger, w http.ResponseWriter, msg string,
@@ -22,8 +22,8 @@ func ListenHttp(version string, server *DNSServer, domain string, db Zone, port
muxRouter := mux.NewRouter()
muxRouter.Methods("GET").Path("/status").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, fmt.Sprintln("weave DNS", version))
io.WriteString(w, server.Status())
io.WriteString(w, fmt.Sprintln("weave DNS", version))
io.WriteString(w, server.Status())
})
muxRouter.Methods("PUT").Path("/name/{id:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+2 -2
View File
@@ -1,12 +1,12 @@
package nameserver
import (
"bytes"
"fmt"
"github.com/miekg/dns"
. "github.com/zettio/weave/common"
"net"
"sync"
"bytes"
"fmt"
)
const (
+6 -6
View File
@@ -79,11 +79,11 @@ func main() {
}
srvConfig := weavedns.DNSServerConfig{
Port: dnsPort,
CacheLen: cacheLen,
LocalDomain: localDomain,
Timeout: timeout,
UdpBufLen: udpbuf,
Port: dnsPort,
CacheLen: cacheLen,
LocalDomain: localDomain,
Timeout: timeout,
UdpBufLen: udpbuf,
}
if len(fallback) > 0 {
@@ -94,7 +94,7 @@ func main() {
srvConfig.UpstreamCfg = &dns.ClientConfig{Servers: []string{fallbackHost}, Port: fallbackPort}
Debug.Printf("DNS fallback at %s:%s", fallbackHost, fallbackPort)
}
srv, err := weavedns.NewDNSServer(srvConfig, zone, iface)
if err != nil {
Error.Fatal("Failed to initialize the WeaveDNS server", err)
+1 -1
View File
@@ -6,6 +6,7 @@ import (
"flag"
"fmt"
"github.com/davecheney/profile"
"github.com/gorilla/mux"
weavenet "github.com/zettio/weave/net"
weave "github.com/zettio/weave/router"
"io"
@@ -16,7 +17,6 @@ import (
"os/signal"
"runtime"
"syscall"
"github.com/gorilla/mux"
)
var version = "(unreleased version)"