Merge pull request #1076 from internetee/improve-epp-domain-info

Handle blocked and reserved domains in EPP domain:info
This commit is contained in:
Timo Võhmar 2019-02-27 19:56:45 +02:00 committed by GitHub
commit 35957d2d84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 122 additions and 45 deletions

View file

@ -4,43 +4,53 @@ class Epp::DomainsController < EppController
skip_authorization_check only: :info
def info
if Domain.release_to_auction
domain_name = DNS::DomainName.new(params[:parsed_frame].at_css('name').text.strip.downcase)
domain_name = DNS::DomainName.new(params[:parsed_frame].at_css('name').text.strip.downcase)
if Domain.release_to_auction
if domain_name.at_auction?
@name = domain_name
@status = 'At auction'
render_epp_response '/epp/domains/info_auction'
render_epp_response '/epp/domains/info/unregistered_domain'
return
elsif domain_name.awaiting_payment?
@name = domain_name
@status = 'Awaiting payment'
render_epp_response '/epp/domains/info_auction'
render_epp_response '/epp/domains/info/unregistered_domain'
return
elsif domain_name.pending_registration?
@name = domain_name
@status = 'Reserved'
render_epp_response '/epp/domains/info_auction'
render_epp_response '/epp/domains/info/unregistered_domain'
return
end
end
find_domain
find_password
authorize! :info, @domain, @password
if domain_name.registered?
find_domain
find_password
authorize! :info, @domain, @password
@hosts = params[:parsed_frame].css('name').first['hosts'] || 'all'
@hosts = params[:parsed_frame].css('name').first['hosts'] || 'all'
case @hosts
when 'del'
@nameservers = @domain.delegated_nameservers.sort
when 'sub'
@nameservers = @domain.subordinate_nameservers.sort
when 'all'
@nameservers = @domain.nameservers.sort
case @hosts
when 'del'
@nameservers = @domain.delegated_nameservers.sort
when 'sub'
@nameservers = @domain.subordinate_nameservers.sort
when 'all'
@nameservers = @domain.nameservers.sort
end
render_epp_response '/epp/domains/info/registered_domain'
elsif domain_name.blocked?
@name = domain_name
@status = 'Blocked'
render_epp_response '/epp/domains/info/unregistered_domain'
elsif domain_name.reserved?
@name = domain_name
@status = 'Reserved'
render_epp_response '/epp/domains/info/unregistered_domain'
end
render_epp_response '/epp/domains/info'
end
def create

View file

@ -53,14 +53,6 @@ module DNS
Whois::Record.refresh(self)
end
def to_s
name
end
private
attr_reader :name
def registered?
Domain.find_by_idn(name)
end
@ -69,6 +61,18 @@ module DNS
BlockedDomain.where(name: name).any?
end
def reserved?
ReservedDomain.where(name: name).any?
end
def to_s
name
end
private
attr_reader :name
def zone_with_same_origin?
DNS::Zone.where(origin: name).any?
end

View file

@ -5,7 +5,7 @@ xml.epp_head do
end
xml.resData do
xml.tag!('domain:infData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
xml.tag! 'domain:infData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd' do
xml.tag!('domain:name', @domain.name)
xml.tag!('domain:roid', @domain.roid)
@domain.statuses.each do |s|
@ -27,32 +27,32 @@ xml.epp_head do
@nameservers.each do |x|
xml.tag!('domain:hostAttr') do
xml.tag!('domain:hostName', x.hostname)
x.ipv4.each{|ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v4') } if x.ipv4.present?
x.ipv6.each{|ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v6') } if x.ipv6.present?
if x.ipv4.present?
x.ipv4.each { |ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v4') }
end
if x.ipv6.present?
x.ipv6.each { |ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v6') }
end
end
end
end
end
## TODO Find out what this domain:host is all about
xml.tag!('domain:clID', @domain.registrar.code)
xml.tag!('domain:crID', @domain.cr_id)
xml.tag!('domain:crDate', @domain.created_at.try(:iso8601))
if @domain.updated_at > @domain.created_at
upID = @domain.updator.try(:registrar)
upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar?
xml.tag!('domain:upID', upID) if upID.present? # optional upID
updator = @domain.updator.try(:registrar)
updator = updator.code if updator.present?
xml.tag!('domain:upID', updator) if updator.present?
xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601))
end
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
# TODO Make domain transferrable
#xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at
if can? :view_password, @domain, @password
xml.tag!('domain:authInfo') do
xml.tag!('domain:pw', @domain.transfer_code)
@ -62,10 +62,11 @@ xml.epp_head do
end
if @domain.dnskeys.any?
ds_data = Setting.ds_data_allowed ? @domain.dnskeys.find_all { |key| key.ds_digest.present? } : []
key_data = Setting.key_data_allowed ? @domain.dnskeys.find_all { |key| key.public_key.present? } : []
ds_data = Setting.ds_data_allowed ?
@domain.dnskeys.find_all { |key| key.ds_digest.present? } : []
key_data = Setting.key_data_allowed ?
@domain.dnskeys.find_all { |key| key.public_key.present? } : []
# is there any reason to include <extension> without <secDNS:infData>
xml.extension do
def tag_key_data(xml, key)
xml.tag!('secDNS:keyData') do

View file

@ -1,16 +1,16 @@
xml.epp_head do
xml.response do
xml.result('code' => '1000') do
xml.result code: '1000' do
xml.msg 'Command completed successfully'
end
xml.resData do
xml.tag! 'domain:infData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd' do
xml.tag!('domain:name', @name)
xml.tag!('domain:status', 's' => @status)
xml.tag! 'domain:name', @name
xml.tag! 'domain:status', 's' => @status
end
end
render('epp/shared/trID', builder: xml)
render 'epp/shared/trID', builder: xml
end
end
end