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