Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions mockdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ func (s *ChallSrv) GetDefaultDNSIPv6() string {
func (s *ChallSrv) AddDNSCNAMERecord(host string, value string) {
s.challMu.Lock()
defer s.challMu.Unlock()
host = dns.Fqdn(host)
value = dns.Fqdn(value)
host = dns.CanonicalName(host)
value = dns.CanonicalName(value)
s.dnsMocks.cnameRecords[host] = value
}

// GetDNSCNAMERecord returns a target host if a CNAME is set for the querying
// host and an empty string otherwise.
func (s *ChallSrv) GetDNSCNAMERecord(host string) string {
s.challMu.RLock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
defer s.challMu.RUnlock()
return s.dnsMocks.cnameRecords[host]
}
Expand All @@ -61,7 +61,7 @@ func (s *ChallSrv) GetDNSCNAMERecord(host string) string {
func (s *ChallSrv) DeleteDNSCNAMERecord(host string) {
s.challMu.Lock()
defer s.challMu.Unlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
delete(s.dnsMocks.cnameRecords, host)
}

Expand All @@ -70,7 +70,7 @@ func (s *ChallSrv) DeleteDNSCNAMERecord(host string) {
func (s *ChallSrv) AddDNSARecord(host string, addresses []string) {
s.challMu.Lock()
defer s.challMu.Unlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
s.dnsMocks.aRecords[host] = append(s.dnsMocks.aRecords[host], addresses...)
}

Expand All @@ -79,15 +79,15 @@ func (s *ChallSrv) AddDNSARecord(host string, addresses []string) {
func (s *ChallSrv) DeleteDNSARecord(host string) {
s.challMu.Lock()
defer s.challMu.Unlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
delete(s.dnsMocks.aRecords, host)
}

// GetDNSARecord returns a slice of IPv4 addresses (in string form) that will be
// returned when querying for A records for the given host.
func (s *ChallSrv) GetDNSARecord(host string) []string {
s.challMu.RLock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
defer s.challMu.RUnlock()
return s.dnsMocks.aRecords[host]
}
Expand All @@ -97,7 +97,7 @@ func (s *ChallSrv) GetDNSARecord(host string) []string {
func (s *ChallSrv) AddDNSAAAARecord(host string, addresses []string) {
s.challMu.Lock()
defer s.challMu.Unlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
s.dnsMocks.aaaaRecords[host] = append(s.dnsMocks.aaaaRecords[host], addresses...)
}

Expand All @@ -106,7 +106,7 @@ func (s *ChallSrv) AddDNSAAAARecord(host string, addresses []string) {
func (s *ChallSrv) DeleteDNSAAAARecord(host string) {
s.challMu.Lock()
defer s.challMu.Unlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
delete(s.dnsMocks.aaaaRecords, host)
}

Expand All @@ -115,7 +115,7 @@ func (s *ChallSrv) DeleteDNSAAAARecord(host string) {
func (s *ChallSrv) GetDNSAAAARecord(host string) []string {
s.challMu.RLock()
defer s.challMu.RUnlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
return s.dnsMocks.aaaaRecords[host]
}

Expand All @@ -124,7 +124,7 @@ func (s *ChallSrv) GetDNSAAAARecord(host string) []string {
func (s *ChallSrv) AddDNSCAARecord(host string, policies []MockCAAPolicy) {
s.challMu.Lock()
defer s.challMu.Unlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
s.dnsMocks.caaRecords[host] = append(s.dnsMocks.caaRecords[host], policies...)
}

Expand All @@ -133,7 +133,7 @@ func (s *ChallSrv) AddDNSCAARecord(host string, policies []MockCAAPolicy) {
func (s *ChallSrv) DeleteDNSCAARecord(host string) {
s.challMu.Lock()
defer s.challMu.Unlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
delete(s.dnsMocks.caaRecords, host)
}

Expand All @@ -142,7 +142,7 @@ func (s *ChallSrv) DeleteDNSCAARecord(host string) {
func (s *ChallSrv) GetDNSCAARecord(host string) []MockCAAPolicy {
s.challMu.RLock()
defer s.challMu.RUnlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
return s.dnsMocks.caaRecords[host]
}

Expand All @@ -151,7 +151,7 @@ func (s *ChallSrv) GetDNSCAARecord(host string) []MockCAAPolicy {
func (s *ChallSrv) AddDNSServFailRecord(host string) {
s.challMu.Lock()
defer s.challMu.Unlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
s.dnsMocks.servFailRecords[host] = true
}

Expand All @@ -160,7 +160,7 @@ func (s *ChallSrv) AddDNSServFailRecord(host string) {
func (s *ChallSrv) DeleteDNSServFailRecord(host string) {
s.challMu.Lock()
defer s.challMu.Unlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
delete(s.dnsMocks.servFailRecords, host)
}

Expand All @@ -169,6 +169,6 @@ func (s *ChallSrv) DeleteDNSServFailRecord(host string) {
func (s *ChallSrv) GetDNSServFailRecord(host string) bool {
s.challMu.RLock()
defer s.challMu.RUnlock()
host = dns.Fqdn(host)
host = dns.CanonicalName(host)
return s.dnsMocks.servFailRecords[host]
}