From efb7c0f1bcdf28444c7fa59f838340a41abeb0c8 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Thu, 26 Mar 2015 10:54:46 +0000 Subject: [PATCH] gofmt --- nameserver/cache.go | 2 +- nameserver/cache_test.go | 14 +++++++------- nameserver/dns.go | 8 ++++---- nameserver/http.go | 6 +++--- nameserver/zone.go | 4 ++-- weavedns/main.go | 12 ++++++------ weaver/main.go | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/nameserver/cache.go b/nameserver/cache.go index 0ef1c46c..bf24d4c4 100644 --- a/nameserver/cache.go +++ b/nameserver/cache.go @@ -19,7 +19,7 @@ var ( ) const ( - defPendingTimeout int = 5 // timeout for a resolution + defPendingTimeout int = 5 // timeout for a resolution ) type entryStatus uint8 diff --git a/nameserver/cache_test.go b/nameserver/cache_test.go index 77814dbc..f5549df9 100644 --- a/nameserver/cache_test.go +++ b/nameserver/cache_test.go @@ -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") diff --git a/nameserver/dns.go b/nameserver/dns.go index 93b545b7..fe98ca6c 100644 --- a/nameserver/dns.go +++ b/nameserver/dns.go @@ -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 { diff --git a/nameserver/http.go b/nameserver/http.go index fee47cb1..aa07ab2d 100644 --- a/nameserver/http.go +++ b/nameserver/http.go @@ -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) { diff --git a/nameserver/zone.go b/nameserver/zone.go index f4c78149..522c6e35 100644 --- a/nameserver/zone.go +++ b/nameserver/zone.go @@ -1,12 +1,12 @@ package nameserver import ( + "bytes" + "fmt" "github.com/miekg/dns" . "github.com/zettio/weave/common" "net" "sync" - "bytes" - "fmt" ) const ( diff --git a/weavedns/main.go b/weavedns/main.go index 452dfc0f..5a8ac3ef 100644 --- a/weavedns/main.go +++ b/weavedns/main.go @@ -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) diff --git a/weaver/main.go b/weaver/main.go index 8004c1c6..83194b89 100644 --- a/weaver/main.go +++ b/weaver/main.go @@ -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)"