Skip to content

Commit

Permalink
Fix data race condition in test
Browse files Browse the repository at this point in the history
  • Loading branch information
juniorz committed Dec 5, 2020
1 parent daa47db commit 8b06a64
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/dnsforward/dnsforward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,10 @@ func TestBlockedDNSRebinding(t *testing.T) {
{Name: "192-168-1-250.nip.io.", Qtype: dns.TypeA, Qclass: dns.ClassINET},
}

s.Lock()
s.conf.RebindingProtectionEnabled = true
s.Unlock()

reply, err := dns.Exchange(&req, addr.String())
if err != nil {
t.Fatalf("Couldn't talk to server %s: %s", addr, err)
Expand All @@ -776,7 +779,10 @@ func TestBlockedDNSRebinding(t *testing.T) {
t.Fatalf("DNS server %s returned wrong answer instead of 0.0.0.0: %v", addr, a.A)
}

s.Lock()
s.conf.RebindingProtectionEnabled = false
s.Unlock()

reply, err = dns.Exchange(&req, addr.String())
if err != nil {
t.Fatalf("Couldn't talk to server %s: %s", addr, err)
Expand All @@ -795,10 +801,13 @@ func TestBlockedDNSRebinding(t *testing.T) {
t.Fatalf("DNS server %s returned wrong answer instead of 192.168.1.250: %v", addr, a.A)
}

s.Lock()
s.conf.RebindingProtectionEnabled = true
s.rebinding, _ = newRebindChecker([]string{
"||nip.io^",
})
s.Unlock()

reply, err = dns.Exchange(&req, addr.String())
if err != nil {
t.Fatalf("Couldn't talk to server %s: %s", addr, err)
Expand Down

0 comments on commit 8b06a64

Please sign in to comment.