mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 11:16:00 +02:00
Create Whois Records for subzones
This commit is contained in:
parent
21d246cc3e
commit
7953b3f8df
2 changed files with 73 additions and 1 deletions
|
@ -8,10 +8,11 @@ class UpdateWhoisRecordJob < Que::Job
|
|||
when 'blocked' then BlockedDomain
|
||||
when 'domain' then Domain
|
||||
when 'disputed' then Dispute.active
|
||||
when 'zone' then DNS::Zone
|
||||
end
|
||||
|
||||
Array(names).each do |name|
|
||||
record = klass.find_by(name: name)
|
||||
record = klass == DNS::Zone ? klass.find_by(origin: name) : klass.find_by(name: name)
|
||||
if record
|
||||
send "update_#{type}", record
|
||||
else
|
||||
|
@ -36,6 +37,10 @@ class UpdateWhoisRecordJob < Que::Job
|
|||
update_reserved(record)
|
||||
end
|
||||
|
||||
def update_zone(record)
|
||||
update_reserved(record)
|
||||
end
|
||||
|
||||
# 1. deleting own
|
||||
# 2. trying to regenerate reserved in order domain is still in the list
|
||||
def delete_domain(name)
|
||||
|
@ -60,6 +65,10 @@ class UpdateWhoisRecordJob < Que::Job
|
|||
remove_status_from_whois(domain_name: name, domain_status: 'disputed')
|
||||
end
|
||||
|
||||
def delete_zone(name)
|
||||
WhoisRecord.where(name: name).destroy_all
|
||||
end
|
||||
|
||||
def remove_status_from_whois(domain_name:, domain_status:)
|
||||
Whois::Record.where(name: domain_name).each do |r|
|
||||
r.json['status'] = r.json['status'].delete_if { |status| status == domain_status }
|
||||
|
|
|
@ -3,6 +3,8 @@ module DNS
|
|||
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, :master_nameserver, presence: true
|
||||
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
|
||||
validates :origin, uniqueness: true
|
||||
after_save :update_whois_record, if: :subzone?
|
||||
after_destroy :update_whois_record, if: :subzone?
|
||||
|
||||
before_destroy do
|
||||
throw(:abort) if used?
|
||||
|
@ -43,5 +45,66 @@ module DNS
|
|||
def to_partial_path
|
||||
'zone'
|
||||
end
|
||||
|
||||
def subzone?
|
||||
origin.include? '.'
|
||||
end
|
||||
|
||||
def update_whois_record
|
||||
UpdateWhoisRecordJob.enqueue origin, 'zone'
|
||||
end
|
||||
|
||||
def generate_data
|
||||
wr = Whois::Record.find_or_initialize_by(name: origin)
|
||||
wr.json = generate_json
|
||||
wr.save
|
||||
end
|
||||
|
||||
def generate_json
|
||||
h = HashWithIndifferentAccess.new
|
||||
|
||||
h[:disclaimer] = Setting.registry_whois_disclaimer if Setting.registry_whois_disclaimer
|
||||
h[:name] = origin
|
||||
h[:status] = ['ok (paid and in zone)']
|
||||
h[:registered] = created_at.try(:to_s, :iso8601)
|
||||
h[:changed] = updated_at.try(:to_s, :iso8601)
|
||||
h[:expire] = nil
|
||||
h[:outzone] = nil
|
||||
h[:delete] = nil
|
||||
|
||||
h[:registrant] = Setting.registry_juridical_name
|
||||
h[:registrant_kind] = 'org'
|
||||
h[:registrant_reg_no] = Setting.registry_reg_no
|
||||
h[:registrant_ident_country_code] = Setting.registry_country_code
|
||||
|
||||
h[:email] = Setting.registry_email
|
||||
h[:registrant_changed] = nil
|
||||
h[:registrant_disclosed_attributes] = %w[name email],
|
||||
|
||||
contact = {
|
||||
name: Setting.registry_invoice_contact,
|
||||
email: Setting.registry_email,
|
||||
changed: nil,
|
||||
disclosed_attributes: %w[name email],
|
||||
}
|
||||
|
||||
h[:admin_contacts] = [contact]
|
||||
|
||||
h[:tech_contacts] = [contact]
|
||||
|
||||
# update registar triggers when adding new attributes
|
||||
h[:registrar] = Setting.registry_juridical_name
|
||||
h[:registrar_website] = Setting.registry_url
|
||||
h[:registrar_phone] = Setting.registry_phone
|
||||
h[:registrar_changed] = nil
|
||||
|
||||
h[:nameservers] = [master_nameserver]
|
||||
h[:nameservers_changed] = nil
|
||||
|
||||
h[:dnssec_keys] = []
|
||||
h[:dnssec_changed] = nil
|
||||
|
||||
h
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue