ddns 0.1.1 → 0.1.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.
Files changed (3) hide show
  1. data/bin/ddns +7 -1
  2. data/bin/ddns.orig +80 -0
  3. metadata +13 -10
data/bin/ddns CHANGED
@@ -8,12 +8,18 @@ require 'resolv'
8
8
  require 'socket'
9
9
 
10
10
  LOGGER = Logger.new($stderr)
11
+ default_gaddress = nil
12
+
13
+ begin
14
+ default_gaddress = IPSocket.getaddress(Socket.gethostname)
15
+ rescue SocketError
16
+ end
11
17
 
12
18
  options = {
13
19
  :hostname => Socket.gethostname,
14
20
  :address => '0.0.0.0',
15
21
  :port => 10053,
16
- :gaddress => IPSocket.getaddress(Socket.gethostname),
22
+ :gaddress => default_gaddress,
17
23
  :gport => 10870,
18
24
  :sock => '/tmp/ddns.sock',
19
25
  :resolver => Resolv::DNS.new,
data/bin/ddns.orig ADDED
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'fileutils'
4
+ require 'drb/drb'
5
+ require 'ddns-server'
6
+ require 'optparse'
7
+ require 'resolv'
8
+ require 'socket'
9
+
10
+ LOGGER = Logger.new($stderr)
11
+ default_gaddress = nil
12
+
13
+ begin
14
+ default_gaddress = IPSocket.getaddress(Socket.gethostname)
15
+ rescue SocketError
16
+ end
17
+
18
+ options = {
19
+ :hostname => Socket.gethostname,
20
+ :address => '0.0.0.0',
21
+ :port => 10053,
22
+ :gaddress => default_gaddress,
23
+ :gport => 10870,
24
+ :sock => '/tmp/ddns.sock',
25
+ :resolver => Resolv::DNS.new,
26
+ :daemon => false,
27
+ :logger => LOGGER,
28
+ :loglevel => Logger::INFO
29
+ }
30
+
31
+ opts = OptionParser.new
32
+ opts.on('-H', '--hostname HOST', "Own hostname (default #{options[:hostname]})") {|v| options[:hostname] = v }
33
+ opts.on('-A', '--address ADDRESS' "Name service ip address (default #{options[:address]})") {|v| options[:address] = v }
34
+ opts.on('-P', '--port PORT', Integer, "Name service port (default #{options[:port]})") {|v| options[:port] = v }
35
+ opts.on('-a', '--gaddress ADDRESS' "Gossip service ip address (default #{options[:gaddress]})") {|v| options[:gaddress] = v }
36
+ opts.on('-p', '--gport PORT', Integer, "Gossip service port (default #{options[:gport]})") {|v| options[:gport] = v }
37
+ opts.on('-S', '--socket SOCK', "Socket file path (default #{options[:sock]})") {|v| options[:sock] = v }
38
+ opts.on('-d', '--daemon COMMAND', "Directive of daemonize (start|stop|restart|status)") {|v| options[:daemon] = v }
39
+ opts.on('-r', '--resolver CONF', "Default resolver (default /etc/resolv.conf)") {|v| options[:resolver] = Resolv::DNS.new(v) }
40
+ opts.on('-N', '--no-resolver', "Not use default resolver") {|v| options[:resolver] = nil }
41
+
42
+ opts.on('-L', '--loglevel LEVEL',
43
+ [:fatal, :error, :warn, :info, :debug], "Log level (default info)") {|v| options[:loglevel] = Logger.const_get(v.to_s.upcase) }
44
+
45
+ opts.on('-i', '--initial NODES', "Initial access node list (ex 10.0.0.1,10.0.0.2)") do |v|
46
+ options[:initial_nodes] = v.split(/\s*,\s*/)
47
+ end
48
+
49
+ opts.on('-h', '--help', "Display this help") { $stdout.puts opts.help ; exit 1 }
50
+
51
+ begin
52
+ opts.parse!(ARGV)
53
+ rescue => e
54
+ $stderr.puts e.message
55
+ $stdout.puts opts.help
56
+ exit 1
57
+ end
58
+
59
+ #RGossip.debug = true
60
+ RGossip.port = options[:gport]
61
+ DDNS::Attributes.new(options)
62
+
63
+ LOGGER.info("Name service at #{options[:address]}:#{options[:port]}")
64
+ LOGGER.info("Gossip service at #{options[:gaddress]}:#{options[:gport]}")
65
+ LOGGER.info("Hostname: #{options[:hostname]}")
66
+
67
+ if options[:daemon]
68
+ ARGV.unshift options[:daemon]
69
+ DDNS.daemonize
70
+ else
71
+ begin
72
+ at_exit { FileUtils.rm_f(options[:sock]) }
73
+ $DDNS_GOSSIP = DRb.start_service("drbunix:#{options[:sock]}", $DDNS_ATTR.gossip)
74
+ rescue => e
75
+ $stderr.puts(e.message)
76
+ end
77
+
78
+ DDNS.run
79
+ end
80
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddns
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - winebarrel
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-23 00:00:00 Z
18
+ date: 2011-05-25 00:00:00 +09:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rubydns
@@ -41,12 +42,12 @@ dependencies:
41
42
  requirements:
42
43
  - - ">="
43
44
  - !ruby/object:Gem::Version
44
- hash: 9
45
+ hash: 23
45
46
  segments:
46
47
  - 0
47
- - 1
48
- - 9
49
- version: 0.1.9
48
+ - 2
49
+ - 0
50
+ version: 0.2.0
50
51
  type: :runtime
51
52
  version_requirements: *id002
52
53
  description:
@@ -60,9 +61,11 @@ extra_rdoc_files: []
60
61
 
61
62
  files:
62
63
  - README
63
- - bin/ddnsctl
64
64
  - bin/ddns
65
+ - bin/ddns.orig
66
+ - bin/ddnsctl
65
67
  - lib/ddns-server.rb
68
+ has_rdoc: true
66
69
  homepage: https://bitbucket.org/winebarrel/ddns
67
70
  licenses: []
68
71
 
@@ -92,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
95
  requirements: []
93
96
 
94
97
  rubyforge_project:
95
- rubygems_version: 1.8.1
98
+ rubygems_version: 1.4.2
96
99
  signing_key:
97
100
  specification_version: 3
98
101
  summary: Distributed name server