Browse Source

protect hostnames, readme

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
fab319a23e
  1. 2
      README
  2. 11
      app/models/a.rb
  3. 6
      config/settings.sample.yml

2
README

@ -1,4 +1,4 @@
## Simple DNS
## Entry DNS
A DNS users frontend.

11
app/models/a.rb

@ -17,6 +17,17 @@ class A < Record
attr_accessor :host_domain
validates :host_domain, :inclusion => {:in => Settings.host_domains}, :allow_blank => true
validate do
if Settings.host_domains.include?(domain.name)
for hostname in Settings.protected_hostnames
if name =~ /^#{hostname}/i
errors[:name] << "cannot be used, please try another"
break
end
end
end
end
before_validation do
if host_domain.present? && Settings.host_domains.include?(host_domain)
self.domain_id = Domain.find_by_name(host_domain).try(:id)

6
config/settings.sample.yml

@ -8,3 +8,9 @@ ns:
default_prio: 10
host_domains:
- entrydns.org
protected_hostnames:
- www
- mail
- smtp
- imap
- ns[0-9]*

Loading…
Cancel
Save