Run gofmt
This commit is contained in:
1 parent
58c8945b32
commit
56859a9c30
6 files changed
+29
-31
No files matched your search
+1
-1
@@ -87,7 +87,7 @@ func addrToIPv4(addr string) (IPv4, error) {
|
|||||||
// Parse a reverse address (eg, "11.12.13.10.in-addr.arpa.") and return the corresponding IPv4 (eg, "10.13.12.11")
|
// Parse a reverse address (eg, "11.12.13.10.in-addr.arpa.") and return the corresponding IPv4 (eg, "10.13.12.11")
|
||||||
func raddrToIPv4(addr string) (IPv4, error) {
|
func raddrToIPv4(addr string) (IPv4, error) {
|
||||||
l := len(addr)
|
l := len(addr)
|
||||||
if l < rdnsDomainLen + 1 {
|
if l < rdnsDomainLen+1 {
|
||||||
return IPv4{}, &net.ParseError{"too short reverse IP address", addr}
|
return IPv4{}, &net.ParseError{"too short reverse IP address", addr}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-20
@@ -1,30 +1,30 @@
|
|||||||
package nameserver
|
package nameserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "github.com/weaveworks/weave/common"
|
. "github.com/weaveworks/weave/common"
|
||||||
wt "github.com/weaveworks/weave/testing"
|
wt "github.com/weaveworks/weave/testing"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAddrs(t *testing.T) {
|
func TestAddrs(t *testing.T) {
|
||||||
InitDefaultLogging(testing.Verbose())
|
InitDefaultLogging(testing.Verbose())
|
||||||
|
|
||||||
ip, err := addrToIPv4("10.13.12.11")
|
ip, err := addrToIPv4("10.13.12.11")
|
||||||
wt.AssertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
wt.AssertTrue(t, net.ParseIP("10.13.12.11").Equal(ip.toNetIP()), "IP")
|
wt.AssertTrue(t, net.ParseIP("10.13.12.11").Equal(ip.toNetIP()), "IP")
|
||||||
|
|
||||||
ip, err = raddrToIPv4("11.12.13.10.in-addr.arpa.")
|
ip, err = raddrToIPv4("11.12.13.10.in-addr.arpa.")
|
||||||
wt.AssertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
wt.AssertTrue(t, net.ParseIP("10.13.12.11").Equal(ip.toNetIP()), "IP")
|
wt.AssertTrue(t, net.ParseIP("10.13.12.11").Equal(ip.toNetIP()), "IP")
|
||||||
|
|
||||||
// some malformed addresses
|
// some malformed addresses
|
||||||
ip, err = addrToIPv4("10.13.12")
|
ip, err = addrToIPv4("10.13.12")
|
||||||
wt.AssertTrue(t, err != nil, "when parsing malformed address")
|
wt.AssertTrue(t, err != nil, "when parsing malformed address")
|
||||||
ip, err = addrToIPv4("10.13.AA.12")
|
ip, err = addrToIPv4("10.13.AA.12")
|
||||||
wt.AssertTrue(t, err != nil, "when parsing malformed address")
|
wt.AssertTrue(t, err != nil, "when parsing malformed address")
|
||||||
ip, err = raddrToIPv4("11.12.13.10.in-axxx.arpa.")
|
ip, err = raddrToIPv4("11.12.13.10.in-axxx.arpa.")
|
||||||
wt.AssertTrue(t, err != nil, "when parsing malformed address")
|
wt.AssertTrue(t, err != nil, "when parsing malformed address")
|
||||||
ip, err = raddrToIPv4("11.12.13.10.in-addr")
|
ip, err = raddrToIPv4("11.12.13.10.in-addr")
|
||||||
wt.AssertTrue(t, err != nil, "when parsing malformed address")
|
wt.AssertTrue(t, err != nil, "when parsing malformed address")
|
||||||
}
|
}
|
||||||
@@ -51,9 +51,9 @@ func (r Response) Equal(r2 *Response) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type responseInfo struct {
|
type responseInfo struct {
|
||||||
timeout time.Time // if no answer by this time, give up
|
timeout time.Time // if no answer by this time, give up
|
||||||
insistent bool // insistent queries are not removed on the first reply
|
insistent bool // insistent queries are not removed on the first reply
|
||||||
ch chan<- *Response
|
ch chan<- *Response
|
||||||
}
|
}
|
||||||
|
|
||||||
// Represents one query that we have sent for one name.
|
// Represents one query that we have sent for one name.
|
||||||
@@ -161,9 +161,9 @@ func (c *MDNSClient) SendQuery(name string, querytype uint16, insistent bool, re
|
|||||||
c.inflight[name] = query
|
c.inflight[name] = query
|
||||||
}
|
}
|
||||||
info := &responseInfo{
|
info := &responseInfo{
|
||||||
ch: responseCh,
|
ch: responseCh,
|
||||||
timeout: time.Now().Add(mDNSTimeout),
|
timeout: time.Now().Add(mDNSTimeout),
|
||||||
insistent: insistent,
|
insistent: insistent,
|
||||||
}
|
}
|
||||||
// Invariant on responseInfos: they are in ascending order of
|
// Invariant on responseInfos: they are in ascending order of
|
||||||
// timeout. Since we use a fixed interval from Now(), this
|
// timeout. Since we use a fixed interval from Now(), this
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ func (s *MDNSServer) Stop() error {
|
|||||||
return s.srv.Shutdown()
|
return s.srv.Shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (s *MDNSServer) Zone() Zone {
|
func (s *MDNSServer) Zone() Zone {
|
||||||
return s.zone
|
return s.zone
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ type mockedZone struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewMockedZone(zr ZoneRecord) *mockedZone { return &mockedZone{record: zr} }
|
func NewMockedZone(zr ZoneRecord) *mockedZone { return &mockedZone{record: zr} }
|
||||||
func (mz mockedZone) Domain() string { return DefaultLocalDomain }
|
func (mz mockedZone) Domain() string { return DefaultLocalDomain }
|
||||||
func (mz mockedZone) LookupName(name string) ([]ZoneRecord, error) {
|
func (mz mockedZone) LookupName(name string) ([]ZoneRecord, error) {
|
||||||
Debug.Printf("[mocked zone]: LookupName: returning record %s", mz.record)
|
Debug.Printf("[mocked zone]: LookupName: returning record %s", mz.record)
|
||||||
mz.NumLookupsName += 1
|
mz.NumLookupsName += 1
|
||||||
@@ -51,4 +51,3 @@ func (mz mockedZone) ObserveInaddr(inaddr string, observer ZoneRecordObserver) e
|
|||||||
notImplWarn()
|
notImplWarn()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
+1
-1
@@ -55,7 +55,7 @@ func main() {
|
|||||||
InitDefaultLogging(debug)
|
InitDefaultLogging(debug)
|
||||||
Info.Printf("WeaveDNS version %s\n", version) // first thing in log: the version
|
Info.Printf("WeaveDNS version %s\n", version) // first thing in log: the version
|
||||||
|
|
||||||
var zone = weavedns.NewZoneDb(localDomain)
|
var zone = weavedns.NewZoneDb(domain)
|
||||||
|
|
||||||
if watch {
|
if watch {
|
||||||
err := updater.Start(apiPath, zone)
|
err := updater.Start(apiPath, zone)
|
||||||
|
|||||||
Reference in new issue
Block a user