Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa3da062a2 |
@@ -116,7 +116,8 @@ 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 {
|
||||||
if _, _, err := net.SplitHostPort(nsIP); err == nil {
|
_, _, err := net.SplitHostPort(nsIP)
|
||||||
|
if err == nil {
|
||||||
return nsIP
|
return nsIP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,13 +73,16 @@ func startNameserver(
|
|||||||
) string {
|
) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
conn, err := net.ListenPacket("udp", "127.0.0.1:0")
|
var lc net.ListenConfig
|
||||||
|
|
||||||
|
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
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -120,7 +123,8 @@ func serveNameserver(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := conn.WriteTo(wire, from); err != nil {
|
_, err = conn.WriteTo(wire, from)
|
||||||
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,7 +135,9 @@ func serveNameserver(
|
|||||||
func unservedAddr(t *testing.T) string {
|
func unservedAddr(t *testing.T) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
conn, err := net.ListenPacket("udp", "127.0.0.1:0")
|
var lc net.ListenConfig
|
||||||
|
|
||||||
|
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,7 +84,6 @@ type mockPortChecker struct {
|
|||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
openAll bool
|
openAll bool
|
||||||
err error
|
err error
|
||||||
calls int
|
|
||||||
seen []portCall
|
seen []portCall
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +95,6 @@ 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 {
|
||||||
@@ -113,13 +111,6 @@ 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.
|
||||||
@@ -148,7 +139,6 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +150,6 @@ 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},
|
||||||
)
|
)
|
||||||
@@ -185,13 +174,6 @@ 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