mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
added notify class and mail action for inform
This commit is contained in:
parent
b25ef62d78
commit
ca9ca115eb
5 changed files with 54 additions and 1 deletions
|
@ -28,10 +28,23 @@ class ValidateDnssecJob < ApplicationJob
|
||||||
domain.nameservers.each do |n|
|
domain.nameservers.each do |n|
|
||||||
validate(hostname: n.hostname, domain: domain)
|
validate(hostname: n.hostname, domain: domain)
|
||||||
|
|
||||||
|
notify_contacts(domain)
|
||||||
logger.info "----------------------------"
|
logger.info "----------------------------"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify_contacts(domain)
|
||||||
|
flag = domain.dnskeys.any? { |k| k.validation_datetime.present? }
|
||||||
|
|
||||||
|
return if flag
|
||||||
|
|
||||||
|
text = "DNSKEYS for #{domain.name} are invalid!"
|
||||||
|
logger.info text
|
||||||
|
ContactNotification.notify_registrar(domain: domain, text: text)
|
||||||
|
ContactNotification.notify_tech_contact(domain: domain)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def validate(hostname:, domain:, type: 'DNSKEY', klass: 'IN')
|
def validate(hostname:, domain:, type: 'DNSKEY', klass: 'IN')
|
||||||
resolver = prepare_validator(hostname)
|
resolver = prepare_validator(hostname)
|
||||||
answer = resolver.query(domain.name, type, klass)
|
answer = resolver.query(domain.name, type, klass)
|
||||||
|
@ -51,16 +64,21 @@ class ValidateDnssecJob < ApplicationJob
|
||||||
|
|
||||||
def compare_dnssec_data(response_container:, domain:)
|
def compare_dnssec_data(response_container:, domain:)
|
||||||
domain.dnskeys.each do |key|
|
domain.dnskeys.each do |key|
|
||||||
next unless key.flags.to_s == '257'
|
next unless key.flags.to_s == '257' || key.validation_datetime.nil?
|
||||||
|
|
||||||
flag = make_magic(response_container: response_container, dnskey: key)
|
flag = make_magic(response_container: response_container, dnskey: key)
|
||||||
text = "#{key.flags} - #{key.protocol} - #{key.alg} - #{key.public_key}"
|
text = "#{key.flags} - #{key.protocol} - #{key.alg} - #{key.public_key}"
|
||||||
if flag
|
if flag
|
||||||
|
key.validation_datetime = Time.zone.now
|
||||||
|
key.save
|
||||||
|
|
||||||
logger.info text + " ------->> succesfully!"
|
logger.info text + " ------->> succesfully!"
|
||||||
else
|
else
|
||||||
logger.info text + " ------->> not found in zone!"
|
logger.info text + " ------->> not found in zone!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_magic(response_container:, dnskey:)
|
def make_magic(response_container:, dnskey:)
|
||||||
|
|
16
app/mailers/contact_inform_mailer.rb
Normal file
16
app/mailers/contact_inform_mailer.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
class ContactInformMailer < ApplicationMailer
|
||||||
|
helper_method :address_processing
|
||||||
|
|
||||||
|
def notify(contact:, subject:)
|
||||||
|
@contact = email
|
||||||
|
@subject = subject
|
||||||
|
|
||||||
|
mail(to: contact.email, subject: subject)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def address_processing
|
||||||
|
Contact.address_processing?
|
||||||
|
end
|
||||||
|
end
|
17
app/services/contact_notification.rb
Normal file
17
app/services/contact_notification.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
module ContactNotification
|
||||||
|
extend self
|
||||||
|
|
||||||
|
def notify_registrar(domain:, text:)
|
||||||
|
domain.registrar.notifications.create(text: text)
|
||||||
|
end
|
||||||
|
|
||||||
|
def notify_tech_contact(domain:)
|
||||||
|
text = "DNSKEYS for #{domain.name} are invalid!"
|
||||||
|
domain.tech_domain_contacts.each do |tech|
|
||||||
|
contact = Contact.find(tech.id)
|
||||||
|
|
||||||
|
ContactInformMailer.notify(contact: contact, subject: text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
1
app/views/mailers/contact_inform_mailer/notify.html.erb
Normal file
1
app/views/mailers/contact_inform_mailer/notify.html.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<p>DNSKEYS for <%= @domain.name %> are invalid!</p>
|
1
app/views/mailers/contact_inform_mailer/notify.text.erb
Normal file
1
app/views/mailers/contact_inform_mailer/notify.text.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<p>DNSKEYS for <%= @domain.name %> are invalid!</p>
|
Loading…
Add table
Add a link
Reference in a new issue