dyndyndong 0.0.1 → 0.0.2
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.
- data/bin/dyndyndong +34 -2
- data/lib/dyndyndong.rb +3 -1
- data/lib/dyndyndong/client.rb +3 -1
- data/lib/dyndyndong/daemon.rb +3 -1
- data/lib/dyndyndong/dyndyndong.rb +3 -1
- data/lib/dyndyndong/services.rb +12 -7
- data/lib/dyndyndong/services/afraid.rb +3 -1
- data/lib/dyndyndong/services/dyndns.rb +34 -24
- data/lib/dyndyndong/services/no-ip.rb +47 -0
- data/lib/dyndyndong/services/zoneedit.rb +60 -0
- data/lib/dyndyndong/version.rb +4 -2
- metadata +7 -5
data/bin/dyndyndong
CHANGED
@@ -29,6 +29,9 @@ def help
|
|
29
29
|
DynDynDong v#{DynDynDong::VERSION} is distributed under the GNU Affero General Public License.
|
30
30
|
|
31
31
|
USAGE: #{$0} [-d|-h|-1] [-c <config file>] [-D <delay>] [-s <service> <service args>]
|
32
|
+
-l|--logfile Set the logfile (default /var/log/dyndyndong.log).
|
33
|
+
-P|--pidfile Set pidfile (default /var/run/dyndyndong.pid).
|
34
|
+
-- Null action, to breaks parsing of a service.
|
32
35
|
-d|--daemon Run DynDynDong as a daemon (default no).
|
33
36
|
-h|--help Show this help.
|
34
37
|
-D|--delay Set time to wait between two cycles (default 600).
|
@@ -52,6 +55,8 @@ end
|
|
52
55
|
|
53
56
|
CONFIG = '/etc/dyndyndong.conf'
|
54
57
|
DEFAULT_CONFIG = CONFIG.dup
|
58
|
+
PIDFILE = '/var/run/dyndyndong.pid'
|
59
|
+
LOGFILE = '/var/log/dyndyndong.log'
|
55
60
|
oneshot = daemon = false
|
56
61
|
|
57
62
|
i, SERVICES = 0, {
|
@@ -63,8 +68,26 @@ i, SERVICES = 0, {
|
|
63
68
|
while i < ARGV.size
|
64
69
|
parsed = false
|
65
70
|
case ARGV[i]
|
71
|
+
when '--'
|
72
|
+
parsed = true
|
73
|
+
when /^-l/, '--logfile'
|
74
|
+
if %w{-l --logfile}.include?(ARGV[i])
|
75
|
+
LOGFILE.replace ARGV[i += 1]
|
76
|
+
else
|
77
|
+
LOGFILE.replace ARGV[i].gsub(/^-l/, '')
|
78
|
+
end
|
79
|
+
STDERR.reopen(File.open(LOGFILE))
|
80
|
+
STDOUT.reopen(STDERR)
|
81
|
+
parsed = true
|
82
|
+
when /^-P/, '--pidfile'
|
83
|
+
if %w{-P --pidfile}.include?(ARGV[i])
|
84
|
+
PIDFILE.replace ARGV[i += 1]
|
85
|
+
else
|
86
|
+
PIDFILE.replace ARGV[i].gsub(/^-P/, '')
|
87
|
+
end
|
88
|
+
parsed = true
|
66
89
|
when '-d', '--daemon'
|
67
|
-
daemon = true
|
90
|
+
daemon = parsed = true
|
68
91
|
when '-h', '--help'
|
69
92
|
help
|
70
93
|
when /^-D/, '--delay'
|
@@ -209,7 +232,16 @@ else
|
|
209
232
|
end
|
210
233
|
|
211
234
|
if DAEMONIZE
|
212
|
-
|
235
|
+
Daemons.daemonize
|
236
|
+
|
237
|
+
File.open(PIDFILE) {|f|
|
238
|
+
f.write(Process.pid.to_s)
|
239
|
+
}
|
240
|
+
|
241
|
+
STDOUT.reopen(File.open(LOGFILE))
|
242
|
+
STDERR.reopen(STDOUT)
|
243
|
+
|
244
|
+
DynDynDong::Client.start_loop
|
213
245
|
else
|
214
246
|
if oneshot
|
215
247
|
DynDynDong::Client.start
|
data/lib/dyndyndong.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#--
|
1
2
|
# Copyleft shura. [shura1991@gmail.com]
|
2
3
|
#
|
3
4
|
# This file is part of DynDynDong.
|
@@ -13,7 +14,8 @@
|
|
13
14
|
# GNU Affero General Public License for more details.
|
14
15
|
#
|
15
16
|
# You should have received a copy of the GNU Affero General Public License
|
16
|
-
# along with
|
17
|
+
# along with dyndyndong. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
17
19
|
|
18
20
|
require 'dyndyndong/client'
|
19
21
|
require 'dyndyndong/daemon'
|
data/lib/dyndyndong/client.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#--
|
1
2
|
# Copyleft shura. [shura1991@gmail.com]
|
2
3
|
#
|
3
4
|
# This file is part of DynDynDong.
|
@@ -13,7 +14,8 @@
|
|
13
14
|
# GNU Affero General Public License for more details.
|
14
15
|
#
|
15
16
|
# You should have received a copy of the GNU Affero General Public License
|
16
|
-
# along with
|
17
|
+
# along with dyndyndong. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
17
19
|
|
18
20
|
require 'dyndyndong/services'
|
19
21
|
require 'dyndyndong/dyndyndong'
|
data/lib/dyndyndong/daemon.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#--
|
1
2
|
# Copyleft shura. [shura1991@gmail.com]
|
2
3
|
#
|
3
4
|
# This file is part of DynDynDong.
|
@@ -13,7 +14,8 @@
|
|
13
14
|
# GNU Affero General Public License for more details.
|
14
15
|
#
|
15
16
|
# You should have received a copy of the GNU Affero General Public License
|
16
|
-
# along with
|
17
|
+
# along with dyndyndong. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
17
19
|
|
18
20
|
require 'dyndyndong/client'
|
19
21
|
require 'daemons'
|
@@ -1,3 +1,4 @@
|
|
1
|
+
#--
|
1
2
|
# Copyleft shura. [shura1991@gmail.com]
|
2
3
|
#
|
3
4
|
# This file is part of DynDynDong.
|
@@ -13,7 +14,8 @@
|
|
13
14
|
# GNU Affero General Public License for more details.
|
14
15
|
#
|
15
16
|
# You should have received a copy of the GNU Affero General Public License
|
16
|
-
# along with
|
17
|
+
# along with dyndyndong. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
17
19
|
|
18
20
|
module DynDynDong
|
19
21
|
def self.delay
|
data/lib/dyndyndong/services.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#--
|
1
2
|
# Copyleft shura. [shura1991@gmail.com]
|
2
3
|
#
|
3
4
|
# This file is part of DynDynDong.
|
@@ -13,7 +14,10 @@
|
|
13
14
|
# GNU Affero General Public License for more details.
|
14
15
|
#
|
15
16
|
# You should have received a copy of the GNU Affero General Public License
|
16
|
-
# along with
|
17
|
+
# along with dyndyndong. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
19
|
+
|
20
|
+
$DEBUG = true
|
17
21
|
|
18
22
|
module DynDynDong
|
19
23
|
|
@@ -28,24 +32,24 @@ class Service
|
|
28
32
|
|
29
33
|
def fetch
|
30
34
|
begin
|
31
|
-
prefetch if
|
35
|
+
prefetch if self.respond_to?(:prefetch)
|
32
36
|
rescue Exception => e
|
33
37
|
STDERR.puts("Prefetch error: #{e}, skipping...")
|
34
38
|
return
|
35
39
|
end
|
36
40
|
|
37
41
|
@hosts.each {|args|
|
38
|
-
STDOUT.write("Aliasing #{args.first}...")
|
42
|
+
STDOUT.write("Aliasing #{args.is_a?(Array) ? args.first : args}...")
|
39
43
|
begin
|
40
44
|
res = alias_host(*args)
|
41
|
-
STDOUT.write("\r--- #{args.first} \n\t#{res.gsub(/\n/, "\n\t")}\n")
|
45
|
+
STDOUT.write("\r--- #{args.is_a?(Array) ? args.first : args} \n\t#{res.gsub(/\n/, "\n\t")}\n")
|
42
46
|
rescue Exception => e
|
43
47
|
STDERR.puts("\tFetch error: #{e}, skipping...")
|
44
48
|
end
|
45
49
|
}
|
46
50
|
|
47
51
|
begin
|
48
|
-
postfetch if self.
|
52
|
+
postfetch if self.respond_to?(:postfetch)
|
49
53
|
rescue Exception => e
|
50
54
|
STDERR.puts("Postfetch error: #{e}")
|
51
55
|
end
|
@@ -87,5 +91,6 @@ end
|
|
87
91
|
|
88
92
|
end
|
89
93
|
|
90
|
-
|
91
|
-
require
|
94
|
+
%w{afraid dyndns zoneedit}.each {|s|
|
95
|
+
require "dyndyndong/services/#{s}"
|
96
|
+
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
#--
|
1
2
|
# Copyleft shura. [shura1991@gmail.com]
|
2
3
|
#
|
3
4
|
# This file is part of DynDynDong.
|
@@ -13,7 +14,8 @@
|
|
13
14
|
# GNU Affero General Public License for more details.
|
14
15
|
#
|
15
16
|
# You should have received a copy of the GNU Affero General Public License
|
16
|
-
# along with
|
17
|
+
# along with dyndyndong. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
17
19
|
|
18
20
|
require 'net/http'
|
19
21
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
#--
|
1
2
|
# Copyleft shura. [shura1991@gmail.com]
|
2
3
|
#
|
3
4
|
# This file is part of DynDynDong.
|
@@ -13,27 +14,31 @@
|
|
13
14
|
# GNU Affero General Public License for more details.
|
14
15
|
#
|
15
16
|
# You should have received a copy of the GNU Affero General Public License
|
16
|
-
# along with
|
17
|
+
# along with dyndyndong. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
17
19
|
|
18
20
|
require 'net/http'
|
21
|
+
require 'resolv'
|
19
22
|
|
20
23
|
module DynDynDong
|
21
24
|
|
22
25
|
class DynDNS < Service
|
23
|
-
MSGTABLE
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
def MSGTABLE(x)
|
27
|
+
{
|
28
|
+
'badauth' => 'The username and password pair do not match a real user.',
|
29
|
+
'!donator' => 'Option available only to credited users.',
|
30
|
+
'good' => 'The update was successful, and the hostname is now updated.',
|
31
|
+
'nochg' => 'The update changed no settings, and is considered abusive.',
|
32
|
+
'notfqdn' => 'The hostname specified is not a fully-qualified domain name.',
|
33
|
+
'nohost' => 'The hostname specified does not exist in this user account.',
|
34
|
+
'numhost' => 'Too many hosts specified in an update.',
|
35
|
+
'abuse' => 'The hostname specified is blocked for update abuse.',
|
36
|
+
'badagent' => 'The user agent was not sent or HTTP method is not permitted.',
|
37
|
+
'good 127.0.0.1' => 'Request was ignored because of agent that does not follow our specifications.',
|
38
|
+
'dnserr' => 'DNS error encountered.',
|
39
|
+
'911' => 'There is a problem or scheduled maintenance on our side.'
|
40
|
+
}[x]
|
41
|
+
end
|
37
42
|
|
38
43
|
def initialize(*args)
|
39
44
|
@user = nil
|
@@ -78,24 +83,29 @@ class DynDNS < Service
|
|
78
83
|
def alias_host(h, ip, offline = false)
|
79
84
|
return "Nothing to update." if ip == @ip
|
80
85
|
|
81
|
-
Net::HTTP.start(
|
86
|
+
Net::HTTP.start(update_host) {|http|
|
82
87
|
req = Net::HTTP::Get.new('/nic/update?hostname=%s&myip=%s&offline=%s' % [
|
83
|
-
URI.escape(h), @ip, (offline
|
88
|
+
URI.escape(h), @ip, offline?(offline)])
|
84
89
|
req.basic_auth @user, @pass
|
85
90
|
x = http.request(req).body.gsub(/#{Regexp.escape(@ip)}/, '').strip
|
86
|
-
MSGTABLE
|
91
|
+
self::MSGTABLE(x)
|
87
92
|
}
|
88
93
|
end
|
89
94
|
|
90
95
|
private
|
96
|
+
def update_host
|
97
|
+
'members.dyndns.org'
|
98
|
+
end
|
99
|
+
|
100
|
+
def offline?(offline)
|
101
|
+
offline ? 'YES' : 'NOCHG'
|
102
|
+
end
|
103
|
+
|
91
104
|
def getip(h = nil)
|
92
105
|
if h
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
else
|
97
|
-
return addr
|
98
|
-
end
|
106
|
+
hosts = ""
|
107
|
+
Resolv.new.each_address(h){|ho| hosts = ho }
|
108
|
+
return hosts
|
99
109
|
end
|
100
110
|
str = Net::HTTP.get(URI.parse('http://checkip.dyndns.org/')).
|
101
111
|
match(/<body>(.+?)<\/body>/)[1] rescue ""
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#--
|
2
|
+
# Copyleft shura. [shura1991@gmail.com]
|
3
|
+
#
|
4
|
+
# This file is part of DynDynDong.
|
5
|
+
#
|
6
|
+
# DynDynDong is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Affero General Public License as published
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DynDynDong is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Affero General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Affero General Public License
|
17
|
+
# along with dyndyndong. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
19
|
+
|
20
|
+
module DynDynDong
|
21
|
+
|
22
|
+
class NoIp < DynDNS
|
23
|
+
def MSGTABLE(x)
|
24
|
+
{
|
25
|
+
'good' => 'DNS hostname update successful.',
|
26
|
+
'nochg' => 'IP address is current, no update performed.',
|
27
|
+
'nohost' => 'Hostname supplied does not exist under specified account.',
|
28
|
+
'badauth' => 'Invalid username password combination.',
|
29
|
+
'badagent' => 'Client disabled.',
|
30
|
+
'!donator' => 'An update request was sent including a feature that is not available to that particular user such as offline options.',
|
31
|
+
'abuse' => 'Username is blocked due to abuse.',
|
32
|
+
'911' => 'A fatal error on our side such as a database outage.'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def update_host
|
39
|
+
'dynupdate.no-ip.com'
|
40
|
+
end
|
41
|
+
|
42
|
+
def offline?(offline)
|
43
|
+
super(offline).gsub(/CHG$/, '')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#--
|
2
|
+
# Copyleft shura. [shura1991@gmail.com]
|
3
|
+
#
|
4
|
+
# This file is part of DynDynDong.
|
5
|
+
#
|
6
|
+
# DynDynDong is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Affero General Public License as published
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DynDynDong is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Affero General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Affero General Public License
|
17
|
+
# along with dyndyndong. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
19
|
+
|
20
|
+
module DynDynDong
|
21
|
+
|
22
|
+
class ZoneEdit < Service
|
23
|
+
def initialize(*args)
|
24
|
+
@user = nil
|
25
|
+
@pass = nil
|
26
|
+
super(*args)
|
27
|
+
end
|
28
|
+
|
29
|
+
def username(u)
|
30
|
+
@user = u.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
def password(p)
|
34
|
+
@pass = p.to_s
|
35
|
+
end
|
36
|
+
|
37
|
+
alias username= username
|
38
|
+
alias password= password
|
39
|
+
|
40
|
+
def host(h)
|
41
|
+
@hosts << h.to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
def prefetch
|
45
|
+
if !(@user and @pass)
|
46
|
+
raise "username or password ungiven"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def alias_host(h)
|
51
|
+
Net::HTTP.start('dynamic.zoneedit.com') {|http|
|
52
|
+
req = Net::HTTP::Get.new('/auth/dynamic.html?host=%s' % [URI.escape(h)])
|
53
|
+
req.basic_auth @user, @pass
|
54
|
+
http.request(req)
|
55
|
+
"DONE"
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
data/lib/dyndyndong/version.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#--
|
1
2
|
# Copyleft shura. [shura1991@gmail.com]
|
2
3
|
#
|
3
4
|
# This file is part of DynDynDong.
|
@@ -13,10 +14,11 @@
|
|
13
14
|
# GNU Affero General Public License for more details.
|
14
15
|
#
|
15
16
|
# You should have received a copy of the GNU Affero General Public License
|
16
|
-
# along with
|
17
|
+
# along with dyndyndong. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
17
19
|
|
18
20
|
module DynDynDong
|
19
21
|
|
20
|
-
VERSION = '0.0.
|
22
|
+
VERSION = '0.0.2'
|
21
23
|
|
22
24
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- shura
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-15 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -40,13 +40,15 @@ extra_rdoc_files: []
|
|
40
40
|
|
41
41
|
files:
|
42
42
|
- lib/dyndyndong.rb
|
43
|
+
- lib/dyndyndong/dyndyndong.rb
|
43
44
|
- lib/dyndyndong/services.rb
|
44
|
-
- lib/dyndyndong/
|
45
|
+
- lib/dyndyndong/services/zoneedit.rb
|
45
46
|
- lib/dyndyndong/services/dyndns.rb
|
46
47
|
- lib/dyndyndong/services/afraid.rb
|
47
|
-
- lib/dyndyndong/
|
48
|
+
- lib/dyndyndong/services/no-ip.rb
|
48
49
|
- lib/dyndyndong/daemon.rb
|
49
50
|
- lib/dyndyndong/client.rb
|
51
|
+
- lib/dyndyndong/version.rb
|
50
52
|
- bin/dyndyndong
|
51
53
|
has_rdoc: true
|
52
54
|
homepage: http://github.com/shurizzle/DynDynDong
|