This commit is contained in:
OlegPhenomenon 2025-08-10 02:06:02 +00:00 committed by GitHub
commit dd46ad5d9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 3 deletions

View file

@ -31,6 +31,7 @@ class Nameserver < ApplicationRecord
before_validation :normalize_attributes before_validation :normalize_attributes
before_validation :check_puny_symbols before_validation :check_puny_symbols
before_validation :check_label_length before_validation :check_label_length
before_validation :check_presence_of_dnssec_keys
delegate :name, to: :domain, prefix: true delegate :name, to: :domain, prefix: true
@ -55,6 +56,36 @@ class Nameserver < ApplicationRecord
} }
end end
def check_presence_of_dnssec_keys
r = NameserverValidator.run(domain_name: domain, nameserver: self)
return if r[:result]
text = parse_result(r, self)
add_epp_error(2302, self, self.hostname, text)
end
def parse_result(result, nameserver)
text = ''
case result[:reason]
when 'answer'
text = "DNS Server **#{nameserver.hostname}** not responding"
when 'serial'
text = "Serial number for nameserver hostname **#{nameserver.hostname}** of #{nameserver.domain.name} doesn't present in zone. SOA validation failed."
when 'cname'
text = "Warning: SOA record expected but CNAME found instead. This setup can lead to unexpected errors when using the domain: hostname - **#{nameserver.hostname}** of #{nameserver.domain.name}"
when 'not found'
text = "Seems nameserver hostname **#{nameserver.hostname}** doesn't exist"
when 'exception'
text = "Something went wrong, exception reason: **#{result[:error_info]}**"
when 'domain'
text = "#{domain.name} zone is not in nameserver**#{nameserver.hostname}**"
when 'glup record'
text = "Hostname #{nameserver.hostname} didn't resovle by glue record to #{domain.name}"
end
text
end
def failed_validation? def failed_validation?
return false if validation_counter.nil? return false if validation_counter.nil?

View file

@ -11,11 +11,9 @@ module NameserverValidator
result_response = validate(domain_name: domain_name, hostname: nameserver.hostname) result_response = validate(domain_name: domain_name, hostname: nameserver.hostname)
unless result_response[:result] && result_response[:reason] == :exception unless result_response[:result] && result_response[:reason] == :exception
if result_response[:error_info].to_s.include? "Nameserver invalid!" if result_response[:error_info].to_s.include? 'Nameserver invalid!'
if nameserver.ipv4.present? if nameserver.ipv4.present?
result_response = validate(domain_name: domain_name, hostname: nameserver.ipv4) result_response = validate(domain_name: domain_name, hostname: nameserver.ipv4)
# elsif nameserver.ipv6.present?
# result_response = validate(domain_name: domain_name, hostname: nameserver.ipv6)
end end
return { result: false, reason: 'glup record' } unless result_response[:result] return { result: false, reason: 'glup record' } unless result_response[:result]