|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
require 'resolv' |
|
|
|
|
|
|
|
|
|
class Domain < ActiveRecord::Base |
|
|
|
|
set_inheritance_column "sti_disabled" |
|
|
|
|
nilify_blanks |
|
|
|
@ -43,6 +45,16 @@ class Domain < ActiveRecord::Base
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
validate :domain_ownership, :on => :create |
|
|
|
|
def domain_ownership # at least one NS is among ours |
|
|
|
|
Resolv::DNS.open do |dns| |
|
|
|
|
ress = dns.getresources name, Resolv::DNS::Resource::IN::NS |
|
|
|
|
if (Settings.ns & ress.map{|r| r.name.to_s}).blank? |
|
|
|
|
errors.add :base, "You must delegate #{name} to one of our NS servers before adding it" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def slave?; self.type == 'SLAVE' end |
|
|
|
|
|
|
|
|
|
before_create do |
|
|
|
|