ddnsupdate 0.1.0 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/HISTORY +4 -0
  2. data/bin/ddnsupdate +2 -2
  3. data/lib/ddnsupdate.rb +23 -7
  4. metadata +39 -21
data/HISTORY CHANGED
@@ -1,5 +1,9 @@
1
1
  DDNS Update History
2
2
  ===================
3
3
 
4
+ Version 0.1.5 (2011-09-08)
5
+ * Some DNS don't answer to SOA requests for hosts/subdomains (AEX I'm looking at you!) so we try domains recursively
6
+ Version 0.1.1 (2011-09-08)
7
+ * Don't output anything if nothing updated (will add a silent mode later)
4
8
  Version 0.1.0 (2011-09-08)
5
9
  * First release.
data/bin/ddnsupdate CHANGED
@@ -40,8 +40,8 @@ EOS
40
40
  Trollop::die "missing key" if cmd_opts[:key].nil?
41
41
 
42
42
  ip = (cmd_opts[:remote] && determine_remote_ip) || determine_local_ip
43
- update(cmd_opts[:host], ip, cmd_opts[:key], cmd_opts[:wild])
44
- puts "Host updated with ip #{ip}"
43
+
44
+ puts "Host updated with ip #{ip}" if update(cmd_opts[:host], ip, cmd_opts[:key], cmd_opts[:wild])
45
45
  when "gen"
46
46
  cmd_opts = Trollop::options do
47
47
  banner <<-EOS
data/lib/ddnsupdate.rb CHANGED
@@ -13,13 +13,25 @@ module DDNSUpdate
13
13
  end
14
14
 
15
15
  def self.determine_soa(zone)
16
- soa = %x{dig -t SOA #{zone.gsub(/\.$/, "")} +noquestion +nostats +nocmd +noqr +nocomments +noadditional +nottlid}
17
- #Split lines into an array, filtering out comments and blanks
18
- soa = soa.split("\n").delete_if { |el| el.start_with?(";") || el.empty? }
19
- #Split remaining line into whitespace delimited fields
20
- soa = soa[0].split(/\s/)
21
- #Find the field we actually want, stripping the trailing dot
22
- soa[soa.index("SOA") + 1].gsub(/\.$/, "")
16
+ current = zone.gsub(/\.$/, "")
17
+ soa = nil
18
+ while soa.nil? and !current.empty?
19
+ soa = %x{dig -t SOA #{current} +noquestion +nostats +nocmd +noqr +nocomments +noadditional +nottlid}
20
+ if not soa.nil?
21
+ #Split lines into an array, filtering out comments and blanks
22
+ soa = soa.split("\n").delete_if { |el| el.start_with?(";") || el.empty? }
23
+ #Split remaining line into whitespace delimited fields
24
+ if not soa.empty?
25
+ soa = soa[0].split(/\s/)
26
+ #Find the field we actually want, stripping the trailing dot
27
+ soa = soa[soa.index("SOA") + 1].gsub(/\.$/, "")
28
+ else
29
+ soa = nil
30
+ end
31
+ end
32
+ current.sub! /^.*?\./, ""
33
+ end
34
+ return soa
23
35
  end
24
36
 
25
37
  def self.determine_current_ip(zone, soa=nil)
@@ -44,6 +56,7 @@ module DDNSUpdate
44
56
 
45
57
  def self.update(zone, ip, key, wild = false)
46
58
  soa = determine_soa(zone)
59
+ raise UpdateError, "can't find SOA for #{zone}" if soa.nil?
47
60
  curip = determine_current_ip(zone, soa)
48
61
 
49
62
  if curip != ip
@@ -71,6 +84,9 @@ module DDNSUpdate
71
84
  err = stderr.read
72
85
  raise UpdateError, err unless err.empty?
73
86
  end
87
+ true
88
+ else
89
+ false
74
90
  end
75
91
  end
76
92
  end
metadata CHANGED
@@ -1,50 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ddnsupdate
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 5
9
+ version: 0.1.5
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Hugues Lismonde
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2011-09-08 00:00:00.000000000Z
16
+
17
+ date: 2011-09-08 00:00:00 +02:00
18
+ default_executable:
13
19
  dependencies: []
20
+
14
21
  description:
15
22
  email: hugues@epic.net
16
- executables:
23
+ executables:
17
24
  - ddnsupdate
18
25
  extensions: []
26
+
19
27
  extra_rdoc_files: []
20
- files:
28
+
29
+ files:
21
30
  - HISTORY
22
31
  - LICENSE
23
32
  - README.md
24
33
  - bin/ddnsupdate
25
34
  - lib/ddnsupdate.rb
35
+ has_rdoc: true
26
36
  homepage: https://github.com/epicagency/ddnsupdate/
27
37
  licenses: []
38
+
28
39
  post_install_message:
29
40
  rdoc_options: []
30
- require_paths:
41
+
42
+ require_paths:
31
43
  - lib
32
- required_ruby_version: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ segments:
49
+ - 1
50
+ - 8
51
+ - 6
37
52
  version: 1.8.6
38
- required_rubygems_version: !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ version: "0"
44
60
  requirements: []
61
+
45
62
  rubyforge_project:
46
- rubygems_version: 1.8.10
63
+ rubygems_version: 1.3.6
47
64
  signing_key:
48
65
  specification_version: 3
49
66
  summary: Performs dynamic dns updates
50
67
  test_files: []
68
+