InvalidRR + s/InvalidZone/DomainNotFound/ + domain regex with final ".".
parent
01a1dbc522
commit
9be374b492
|
@ -78,5 +78,13 @@ class DNSManager::Response
|
|||
end
|
||||
end
|
||||
DNSManager.responses << RRAdded
|
||||
|
||||
IPC::JSON.message InvalidRR, 20 do
|
||||
# For now, Error is just an alias on String.
|
||||
property errors : Array(Storage::Zone::Error)
|
||||
def initialize(@errors)
|
||||
end
|
||||
end
|
||||
DNSManager.responses << InvalidRR
|
||||
end
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ class DNSManager::Storage
|
|||
rr.get_errors.tap do |errors|
|
||||
unless errors.empty?
|
||||
Baguette::Log.warning "add RR with errors: #{errors}"
|
||||
return Response::InvalidZone.new errors
|
||||
return Response::InvalidRR.new errors
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -201,7 +201,7 @@ class DNSManager::Storage
|
|||
rr.get_errors.tap do |errors|
|
||||
unless errors.empty?
|
||||
Baguette::Log.warning "update RR with errors: #{errors}"
|
||||
return Response::InvalidZone.new errors
|
||||
return Response::InvalidRR.new errors
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -233,9 +233,7 @@ class DNSManager::Storage
|
|||
|
||||
# Zone must exist.
|
||||
zone = zones_by_domain.get? domain
|
||||
unless zone
|
||||
return Response::InvalidZone.new ["Domain not found."]
|
||||
end
|
||||
return Response::DomainNotFound.new unless zone
|
||||
|
||||
# User must own the zone.
|
||||
unless user_data.domains.includes?(domain) || user_data.admin
|
||||
|
|
|
@ -332,7 +332,7 @@ class DNSManager::Storage::Zone
|
|||
|
||||
# This regex only is "good enough for now".
|
||||
def self.is_domain_valid?(domain) : Bool
|
||||
if domain =~ /^(((?!-))(xn--|_{1,1})?[a-z0-9-]{0,61}[a-z0-9]{1,1}\.)*((xn--)?[a-z0-9][a-z0-9\-]{0,60}[a-z0-9]|(xn--)?[a-z0-9]{1,60})\.[a-z]{2,}$/
|
||||
if domain =~ /^(((?!-))(xn--|_{1,1})?[a-z0-9-]{0,61}[a-z0-9]{1,1}\.)*((xn--)?[a-z0-9][a-z0-9\-]{0,60}[a-z0-9]|(xn--)?[a-z0-9]{1,60})\.[a-z]{2,}\.?$/
|
||||
true
|
||||
else
|
||||
false
|
||||
|
|
Loading…
Reference in New Issue