Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b0fdc477a |
@@ -116,8 +116,7 @@ func (r *Resolver) retryTCP(
|
|||||||
// specifies a port is dialled as written, which is what makes a
|
// specifies a port is dialled as written, which is what makes a
|
||||||
// nameserver listening somewhere other than 53 reachable.
|
// nameserver listening somewhere other than 53 reachable.
|
||||||
func nameserverAddr(nsIP string) string {
|
func nameserverAddr(nsIP string) string {
|
||||||
_, _, err := net.SplitHostPort(nsIP)
|
if _, _, err := net.SplitHostPort(nsIP); err == nil {
|
||||||
if err == nil {
|
|
||||||
return nsIP
|
return nsIP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,16 +73,13 @@ func startNameserver(
|
|||||||
) string {
|
) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
var lc net.ListenConfig
|
conn, err := net.ListenPacket("udp", "127.0.0.1:0")
|
||||||
|
|
||||||
conn, err := lc.ListenPacket(t.Context(), "udp", "127.0.0.1:0")
|
|
||||||
require.NoError(t, err, "binding loopback nameserver")
|
require.NoError(t, err, "binding loopback nameserver")
|
||||||
|
|
||||||
stopped := make(chan struct{})
|
stopped := make(chan struct{})
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
_ = conn.Close()
|
_ = conn.Close()
|
||||||
|
|
||||||
<-stopped
|
<-stopped
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -123,8 +120,7 @@ func serveNameserver(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = conn.WriteTo(wire, from)
|
if _, err := conn.WriteTo(wire, from); err != nil {
|
||||||
if err != nil {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,9 +131,7 @@ func serveNameserver(
|
|||||||
func unservedAddr(t *testing.T) string {
|
func unservedAddr(t *testing.T) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
var lc net.ListenConfig
|
conn, err := net.ListenPacket("udp", "127.0.0.1:0")
|
||||||
|
|
||||||
conn, err := lc.ListenPacket(t.Context(), "udp", "127.0.0.1:0")
|
|
||||||
require.NoError(t, err, "binding loopback port")
|
require.NoError(t, err, "binding loopback port")
|
||||||
|
|
||||||
addr := conn.LocalAddr().String()
|
addr := conn.LocalAddr().String()
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ type mockPortChecker struct {
|
|||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
openAll bool
|
openAll bool
|
||||||
err error
|
err error
|
||||||
|
calls int
|
||||||
seen []portCall
|
seen []portCall
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +96,7 @@ func (m *mockPortChecker) CheckPort(
|
|||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
|
m.calls++
|
||||||
m.seen = append(m.seen, portCall{address: address, port: port})
|
m.seen = append(m.seen, portCall{address: address, port: port})
|
||||||
|
|
||||||
if m.err != nil {
|
if m.err != nil {
|
||||||
@@ -111,6 +113,13 @@ func (m *mockPortChecker) setOpenAll(open bool) {
|
|||||||
m.openAll = open
|
m.openAll = open
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *mockPortChecker) callCount() int {
|
||||||
|
m.mu.Lock()
|
||||||
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
|
return m.calls
|
||||||
|
}
|
||||||
|
|
||||||
// checkedKeys returns the distinct "address:port" pairs the checker
|
// checkedKeys returns the distinct "address:port" pairs the checker
|
||||||
// was asked about, sorted, in the same form as the state store's
|
// was asked about, sorted, in the same form as the state store's
|
||||||
// port keys so the two can be compared directly.
|
// port keys so the two can be compared directly.
|
||||||
@@ -139,6 +148,7 @@ type mockTLSChecker struct {
|
|||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
cert *tlscheck.CertificateInfo
|
cert *tlscheck.CertificateInfo
|
||||||
err error
|
err error
|
||||||
|
calls int
|
||||||
seen []tlsCall
|
seen []tlsCall
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +160,7 @@ func (m *mockTLSChecker) CheckCertificate(
|
|||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
|
m.calls++
|
||||||
m.seen = append(
|
m.seen = append(
|
||||||
m.seen, tlsCall{address: address, hostname: hostname},
|
m.seen, tlsCall{address: address, hostname: hostname},
|
||||||
)
|
)
|
||||||
@@ -174,6 +185,13 @@ func (m *mockTLSChecker) setCert(cert *tlscheck.CertificateInfo) {
|
|||||||
m.cert = cert
|
m.cert = cert
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *mockTLSChecker) callCount() int {
|
||||||
|
m.mu.Lock()
|
||||||
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
|
return m.calls
|
||||||
|
}
|
||||||
|
|
||||||
// checkedKeys returns the distinct certificate keys the checker was
|
// checkedKeys returns the distinct certificate keys the checker was
|
||||||
// asked about, sorted, in the state store's "address:port:hostname"
|
// asked about, sorted, in the state store's "address:port:hostname"
|
||||||
// form so the two can be compared directly.
|
// form so the two can be compared directly.
|
||||||
|
|||||||
Reference in New Issue
Block a user