radd 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9fddd23ad9d4e45fcfef31f6e5d976b13511fc6089a3f77267395ff8d62bfb6
4
- data.tar.gz: 530c66e7a340a9709de98025c4cc697b50d1358371d7ef7e351cd756a30611f8
3
+ metadata.gz: f979c2d87f1f25eb5c780da9d4d5ecb0543c299bee5d7e73a046825357759d1f
4
+ data.tar.gz: 8f92e1c1018b4a5ea9f86e138f3a439e4bd76eaadbfe4ab78a91ecc15d12b33f
5
5
  SHA512:
6
- metadata.gz: f0a3ff47b7c18794df7a34972dacc6ec4434c9dc1b749797655518e79d5509fbc4d01326d34906c3904c22498663cce5224d4214b593cf91588398c3c29ab6cf
7
- data.tar.gz: 431664ea22d21ba782c577c940746bfd43083855054cf60befb9b6414d52d3ba281524448eb8639b19a77549440749f43a0528564c6fa0e22992146eaf00175b
6
+ metadata.gz: b7e11faf5690621e6027d2356c7ee403488fabf29caa0d5007a2e8d6b8ed8319f3b3ce8373e2f0f97905516f0eea9c263f824da406b067ab188ce0c8936d9fdf
7
+ data.tar.gz: 64f91eb6deccbaf8932960b620f65b1f87807c19d7a6492e44a8fa836608cfefe226b25ffde0d3bdec69434742e38bd3e5086bd1f251f11e5c17e451aa2e449f
data/lib/radd/config.rb CHANGED
@@ -22,8 +22,8 @@ module Radd
22
22
  raise ConfigurationError, 'invalid TTL' if config['ttl'] && config['ttl'] < 1
23
23
  @ttl = config['ttl'] || 300
24
24
  raise ConfigurationError, 'master name missing' unless config['mname']
25
- @mname = config['mname']
26
- @rname = config['rname'] || "hostmaster.#{domain}"
25
+ @mname = config['mname'].split('.').freeze
26
+ @rname = encode_email(config['rname'] || "hostmaster@#{domain}").freeze
27
27
  db_path = Pathname.new(config['db'] || 'radd.sqlite3')
28
28
  db_path = Radd.root + db_path unless db_path.absolute?
29
29
  @db = db_path
@@ -39,6 +39,13 @@ module Radd
39
39
  def valid_ip?(ip)
40
40
  !!(ip && ip.match(Resolv::IPv4::Regex))
41
41
  end
42
+
43
+ private
44
+
45
+ def encode_email(email)
46
+ addr, domain = email.split('@')
47
+ [addr, *domain.split('.')]
48
+ end
42
49
  end
43
-
50
+
44
51
  end
@@ -1,17 +1,21 @@
1
- class Radd::Nameserver < Async::DNS::Server
2
- def initialize
3
- super(Async::DNS::Endpoint.for(Radd.dns_host, port: Radd.dns_port))
4
- end
5
-
6
- def process(name, resource_class, transaction)
7
- name = name.downcase
8
- case resource_class
9
- when Resolv::DNS::Resource::IN::A
10
- ip = Radd.domain == name ? Radd.ip : Radd.query(name)
11
- return transaction.respond!(ip, ttl: Radd.ttl) if ip
12
- when Resolv::DNS::Resource::IN::SOA
13
- return transaction.respond!(Radd.mname, Radd.rname, Radd.serial, 10800, 1800, 604800, 1800)
1
+ module Radd
2
+ class Nameserver < Async::DNS::Server
3
+
4
+ def initialize
5
+ super(Async::DNS::Endpoint.for(Radd.dns_host, port: Radd.dns_port))
6
+ end
7
+
8
+ def process(name, resource_class, transaction)
9
+ name = name.downcase
10
+ # NOTE: do not use case..when, as resource classes are not identical
11
+ if Resolv::DNS::Resource::IN::A == resource_class
12
+ ip = Radd.domain == name ? Radd.ip : Radd.query(name)
13
+ return transaction.respond!(ip, ttl: Radd.ttl) if ip
14
+ elsif resource_class <= Resolv::DNS::Resource::SOA && Radd.domain == name
15
+ # mname, rname, serial, refresh, retry_, expire, minimum
16
+ return transaction.respond!(Radd.mname, Radd.rname, Radd.serial, 10800, 1800, 604800, 1800)
17
+ end
18
+ transaction.fail!(:NXDomain)
14
19
  end
15
- transaction.fail!(:NXDomain)
16
20
  end
17
21
  end
data/lib/radd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Radd
2
- VERSION = '1.4.0'
2
+ VERSION = '1.4.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Grosser