devdnsd 3.0.8 → 3.1.0

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.
@@ -529,7 +529,7 @@
529
529
  </div>
530
530
 
531
531
  <div id="footer">
532
- Generated on Sat Mar 8 15:25:56 2014 by
532
+ Generated on Sun Mar 9 19:54:07 2014 by
533
533
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
534
534
  0.8.7.3 (ruby-2.1.0).
535
535
  </div>
@@ -421,7 +421,7 @@ config.add_rule("match.dev", "10.0.0.1")
421
421
  </div>
422
422
 
423
423
  <div id="footer">
424
- Generated on Sat Mar 8 15:25:57 2014 by
424
+ Generated on Sun Mar 9 19:54:08 2014 by
425
425
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
426
426
  0.8.7.3 (ruby-2.1.0).
427
427
  </div>
@@ -116,7 +116,7 @@
116
116
  </div>
117
117
 
118
118
  <div id="footer">
119
- Generated on Sat Mar 8 15:25:56 2014 by
119
+ Generated on Sun Mar 9 19:54:07 2014 by
120
120
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
121
121
  0.8.7.3 (ruby-2.1.0).
122
122
  </div>
@@ -124,7 +124,7 @@
124
124
  </div>
125
125
 
126
126
  <div id="footer">
127
- Generated on Sat Mar 8 15:25:57 2014 by
127
+ Generated on Sun Mar 9 19:54:07 2014 by
128
128
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
129
129
  0.8.7.3 (ruby-2.1.0).
130
130
  </div>
@@ -2927,7 +2927,7 @@
2927
2927
  </div>
2928
2928
 
2929
2929
  <div id="footer">
2930
- Generated on Sat Mar 8 15:25:57 2014 by
2930
+ Generated on Sun Mar 9 19:54:07 2014 by
2931
2931
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2932
2932
  0.8.7.3 (ruby-2.1.0).
2933
2933
  </div>
@@ -134,7 +134,7 @@
134
134
 
135
135
  </div>
136
136
  </dt>
137
- <dd><pre class="code"><span class='int'>0</span></pre></dd>
137
+ <dd><pre class="code"><span class='int'>1</span></pre></dd>
138
138
 
139
139
  <dt id="PATCH-constant" class="">PATCH =
140
140
  <div class="docstring">
@@ -149,7 +149,7 @@
149
149
 
150
150
  </div>
151
151
  </dt>
152
- <dd><pre class="code"><span class='int'>8</span></pre></dd>
152
+ <dd><pre class="code"><span class='int'>0</span></pre></dd>
153
153
 
154
154
  <dt id="STRING-constant" class="">STRING =
155
155
  <div class="docstring">
@@ -180,7 +180,7 @@
180
180
  </div>
181
181
 
182
182
  <div id="footer">
183
- Generated on Sat Mar 8 15:25:56 2014 by
183
+ Generated on Sun Mar 9 19:54:07 2014 by
184
184
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
185
185
  0.8.7.3 (ruby-2.1.0).
186
186
  </div>
data/doc/_index.html CHANGED
@@ -237,7 +237,7 @@
237
237
  </div>
238
238
 
239
239
  <div id="footer">
240
- Generated on Sat Mar 8 15:25:56 2014 by
240
+ Generated on Sun Mar 9 19:54:06 2014 by
241
241
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
242
242
  0.8.7.3 (ruby-2.1.0).
243
243
  </div>
data/doc/file.README.html CHANGED
@@ -99,6 +99,15 @@
99
99
 
100
100
  <p><strong>You’re done!</strong></p>
101
101
 
102
+ <h2 id="dual-stack-ipv4ipv6-usage">Dual stack (IPv4/IPv6) usage</h2>
103
+
104
+ <p>If you experience slowness in resolving host from clients (Chrome, curl etc.) when you don’t specify the address type, make sure you have both a <code>A</code> and <code>AAAA</code> rules set for the same host, like this:</p>
105
+
106
+ <p><code>ruby
107
+ config.add_rule(/\.dev$/, "127.0.0.1")
108
+ config.add_rule(/\.dev$/, "::1", :AAAA)
109
+ </code></p>
110
+
102
111
  <h2 id="advanced-usage">Advanced usage</h2>
103
112
 
104
113
  <p>Just type <code>devdnsd help</code> and you’ll see all available options.</p>
@@ -166,7 +175,7 @@ This argument is ignored if you pass the block, as it assumes that the second ar
166
175
  </div></div>
167
176
 
168
177
  <div id="footer">
169
- Generated on Sat Mar 8 15:25:56 2014 by
178
+ Generated on Sun Mar 9 19:54:07 2014 by
170
179
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
171
180
  0.8.7.3 (ruby-2.1.0).
172
181
  </div>
data/doc/index.html CHANGED
@@ -99,6 +99,15 @@
99
99
 
100
100
  <p><strong>You’re done!</strong></p>
101
101
 
102
+ <h2 id="dual-stack-ipv4ipv6-usage">Dual stack (IPv4/IPv6) usage</h2>
103
+
104
+ <p>If you experience slowness in resolving host from clients (Chrome, curl etc.) when you don’t specify the address type, make sure you have both a <code>A</code> and <code>AAAA</code> rules set for the same host, like this:</p>
105
+
106
+ <p><code>ruby
107
+ config.add_rule(/\.dev$/, "127.0.0.1")
108
+ config.add_rule(/\.dev$/, "::1", :AAAA)
109
+ </code></p>
110
+
102
111
  <h2 id="advanced-usage">Advanced usage</h2>
103
112
 
104
113
  <p>Just type <code>devdnsd help</code> and you’ll see all available options.</p>
@@ -166,7 +175,7 @@ This argument is ignored if you pass the block, as it assumes that the second ar
166
175
  </div></div>
167
176
 
168
177
  <div id="footer">
169
- Generated on Sat Mar 8 15:25:56 2014 by
178
+ Generated on Sun Mar 9 19:54:07 2014 by
170
179
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
171
180
  0.8.7.3 (ruby-2.1.0).
172
181
  </div>
data/doc/method_list.html CHANGED
@@ -66,11 +66,23 @@
66
66
 
67
67
 
68
68
  <li class="r2 ">
69
+ <span class='object_link'><a href="DevDNSd/ApplicationMethods/System.html#action_restart-instance_method" title="DevDNSd::ApplicationMethods::System#action_restart (method)">#action_restart</a></span>
70
+ <small>DevDNSd::ApplicationMethods::System</small>
71
+ </li>
72
+
73
+
74
+ <li class="r1 ">
69
75
  <span class='object_link'><a href="DevDNSd/ApplicationMethods/System.html#action_start-instance_method" title="DevDNSd::ApplicationMethods::System#action_start (method)">#action_start</a></span>
70
76
  <small>DevDNSd::ApplicationMethods::System</small>
71
77
  </li>
72
78
 
73
79
 
80
+ <li class="r2 ">
81
+ <span class='object_link'><a href="DevDNSd/ApplicationMethods/System.html#action_status-instance_method" title="DevDNSd::ApplicationMethods::System#action_status (method)">#action_status</a></span>
82
+ <small>DevDNSd::ApplicationMethods::System</small>
83
+ </li>
84
+
85
+
74
86
  <li class="r1 ">
75
87
  <span class='object_link'><a href="DevDNSd/ApplicationMethods/System.html#action_stop-instance_method" title="DevDNSd::ApplicationMethods::System#action_stop (method)">#action_stop</a></span>
76
88
  <small>DevDNSd::ApplicationMethods::System</small>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Sat Mar 8 15:25:56 2014 by
106
+ Generated on Sun Mar 9 19:54:07 2014 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.7.3 (ruby-2.1.0).
109
109
  </div>
@@ -126,6 +126,31 @@ module DevDNSd
126
126
  true
127
127
  end
128
128
 
129
+ # Restarts the server in background.
130
+ #
131
+ # @return [Boolean] `true` if action succeeded, `false` otherwise.
132
+ def action_restart
133
+ action_stop
134
+ action_start
135
+ true
136
+ end
137
+
138
+ # Shows the status of the server
139
+ #
140
+ # @return [Boolean] `true` if action succeeded, `false` otherwise.
141
+ def action_status
142
+ daemon = self.class
143
+ status = RExec::Daemon::ProcessFile.status(daemon)
144
+ pid = RExec::Daemon::ProcessFile.recall(daemon).to_s
145
+ status = :crashed if status == :unknown && daemon.crashed?
146
+
147
+ if status == :running then
148
+ logger.info(replace_markers(i18n.status_running(pid)))
149
+ elsif
150
+ logger.info(replace_markers(i18n.send("status_#{status}")))
151
+ end
152
+ end
153
+
129
154
  # Adds aliases to an interface.
130
155
  #
131
156
  # @param options [Hash] The options provided by the user.
@@ -216,8 +241,7 @@ module DevDNSd
216
241
  logger.info(replace_markers(i18n.resolver_creating(resolver_path)))
217
242
 
218
243
  script = Tempfile.new("devdnsd-install-script")
219
- script.write("mkdir -p '#{File.dirname(resolver_path)}'\n")
220
- script.write("rm -rf '#{resolver_path}'\n")
244
+ script.write("mkdir -p '#{File.dirname(resolver_path)}'\nrm -rf '#{resolver_path}'\n")
221
245
  script.write("echo 'nameserver 127.0.0.1\\nport #{@config.port}' >> '#{resolver_path}'")
222
246
  script.close
223
247
 
@@ -512,7 +536,8 @@ module DevDNSd
512
536
  # @return [Object] The result of stop callbacks.
513
537
  def perform_server
514
538
  application = self
515
- RubyDNS::run_server(listen: [[:udp, @config.address, @config.port.to_integer]]) do
539
+
540
+ RubyDNS::run_server(listen: build_listen_interfaces) do
516
541
  self.logger = application.logger
517
542
 
518
543
  match(/.+/, DevDNSd::Application::ANY_CLASSES) do |transaction, match_data|
@@ -564,6 +589,14 @@ module DevDNSd
564
589
  end
565
590
 
566
591
  private
592
+ # Builds the list of listening interfaces.
593
+ #
594
+ # @return [Array] Array of addresses.
595
+ def build_listen_interfaces
596
+ port = @config.port.to_integer
597
+ @config.bind_addresses.ensure_array {|address| [:udp, address, port] }
598
+ end
599
+
567
600
  # Performs the processing of a rule.
568
601
  #
569
602
  # @param rule [Rule] The rule to process.
@@ -746,16 +779,14 @@ module DevDNSd
746
779
  @logger = nil
747
780
  @logger = get_logger
748
781
  rescue Bovem::Errors::InvalidConfiguration => e
749
- logger = Bovem::Logger.create($stderr)
750
- logger.fatal(e.message)
751
- logger.warn(replace_markers(i18n.application_create_config(path)))
782
+ log_failed_configuration(path, e)
752
783
  raise ::SystemExit
753
784
  end
754
785
  end
755
786
 
756
787
  # Creates a folder for a file.
757
788
  #
758
- # @param [String] The path of the file.
789
+ # @param path [String] The path of the file.
759
790
  def ensure_directory_for(path)
760
791
  begin
761
792
  FileUtils.mkdir_p(File.dirname(path))
@@ -764,5 +795,15 @@ module DevDNSd
764
795
  raise ::SystemExit
765
796
  end
766
797
  end
798
+
799
+ # Logs a failed configuration
800
+ #
801
+ # @param path [String] The path of the invalid file.
802
+ # @param exception [Exception] The occurred exception.
803
+ def log_failed_configuration(path, exception)
804
+ logger = Bovem::Logger.create($stderr)
805
+ logger.fatal(exception.message)
806
+ logger.warn(replace_markers(i18n.application_create_config(path)))
807
+ end
767
808
  end
768
809
  end
@@ -10,8 +10,8 @@ module DevDNSd
10
10
  # If to run the server in foreground. Default: `false`.
11
11
  property :foreground, default: false
12
12
 
13
- # The address to listen to. Default: `0.0.0.0`.
14
- property :address, default: "0.0.0.0"
13
+ # The addresses to listen to. Default: `["0.0.0.0"]`.
14
+ property :bind_addresses, default: ["0.0.0.0"]
15
15
 
16
16
  # The port to listen to. Default: `7771`.
17
17
  property :port, default: 7771
@@ -13,10 +13,10 @@ module DevDNSd
13
13
  MAJOR = 3
14
14
 
15
15
  # The minor version.
16
- MINOR = 0
16
+ MINOR = 1
17
17
 
18
18
  # The patch version.
19
- PATCH = 8
19
+ PATCH = 0
20
20
 
21
21
  # The current version number of DevDNSd.
22
22
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
data/locales/en.yml CHANGED
@@ -58,12 +58,19 @@
58
58
  application_meta_command: "COMMAND"
59
59
  application_create_config: "To execute devdnsd, please create the file {mark=bright}%1{/mark}. An empty file is sufficient."
60
60
  command_start: "Starts the server."
61
+ command_stop: "Stops the server."
62
+ command_restart: "Restarts the server."
63
+ command_status: "Shows the status of the server."
64
+ command_clean: "Cleans the system's DNS."
61
65
  command_install: "Installs the server."
62
66
  command_uninstall: "Uninstalls the server."
63
- command_stop: "Stops the server."
64
67
  command_aliases: "Adds or removes aliases to network interfaces."
65
68
  command_add: "Adds aliases."
66
69
  command_remove: "Removes aliases."
70
+ status_running: "The server is running with process ID {mark=bright}%1{/mark}."
71
+ status_stopped: "The server is stopped."
72
+ status_crashed: "The server crashed. See the log for more information."
73
+ status_unknown: "The server status is unknown."
67
74
  removing: "Removing"
68
75
  adding: "Adding"
69
76
  remove: "remove"
data/locales/it.yml CHANGED
@@ -59,12 +59,19 @@
59
59
  application_meta_command: "COMANDO"
60
60
  application_create_config: "Per eseguire devdnsd, per favore crea il file {mark=bright}%1{/mark}. Un file vuoto è sufficiente."
61
61
  command_start: "Avvia server."
62
+ command_stop: "Ferma il server."
63
+ command_restart: "Riavvia server."
64
+ command_status: "Mostra lo status del server."
65
+ command_clean: "Pulisce la cache DNS del sistema."
62
66
  command_install: "Installa il server."
63
67
  command_uninstall: "Disinstalla il server."
64
- command_stop: "Ferma il server."
65
68
  command_aliases: "Aggiunge or rimuove indirizzi dalle interfacce di rete."
66
69
  command_add: "Aggiungi indirizzi"
67
70
  command_remove: "Rimuovi indirizzi."
71
+ status_running: "Il server è in esecuzione con ID processo {mark=bright}%1{/mark}."
72
+ status_stopped: "Il server è stato fermato."
73
+ status_crashed: "Il server è terminato con errori. Guarda il log per maggiori informazioni."
74
+ status_unknown: "Lo status del server è sconosciuto."
68
75
  removing: "Rimuovo"
69
76
  adding: "Aggiungo"
70
77
  remove: "rimuovere"
@@ -192,9 +192,9 @@ describe DevDNSd::Application do
192
192
  end
193
193
 
194
194
  describe "#perform_server" do
195
- let(:application){ create_application({"log_file" => log_file, "configuration" => sample_config}) }
195
+ let(:application){ create_application({"log_file" => log_file, "configuration" => sample_config, "port" => 60771}) }
196
196
 
197
- def test_resolve(host = "match_1.dev", type = "ANY", nameserver = "127.0.0.1", port = 7771, logger = nil)
197
+ def test_resolve(host = "match_1.dev", type = "ANY", nameserver = "127.0.0.1", port = 60771, logger = nil)
198
198
  result = nil
199
199
 
200
200
  EM.run do
@@ -567,6 +567,48 @@ describe DevDNSd::Application do
567
567
  end
568
568
  end
569
569
 
570
+ describe "#action_restart" do
571
+ it "should stop and restart the server" do
572
+ expect(application).to receive(:action_stop)
573
+ expect(application).to receive(:action_start)
574
+ application.action_restart
575
+ end
576
+ end
577
+
578
+ describe "#action_status" do
579
+ it "should get the status of the daemon when running" do
580
+ expect(RExec::Daemon::ProcessFile).to receive(:status).and_return(:running)
581
+ expect(RExec::Daemon::ProcessFile).to receive(:recall).and_return(123)
582
+
583
+ expect(application.logger).to receive(:info).with("The server is running with process ID 123.")
584
+ application.action_status
585
+ end
586
+
587
+ it "should get the status of the daemon when stopped" do
588
+ expect(RExec::Daemon::ProcessFile).to receive(:status).and_return(:stopped)
589
+ expect(RExec::Daemon::ProcessFile).to receive(:recall).and_return(123)
590
+
591
+ expect(application.logger).to receive(:info).with("The server is stopped.")
592
+ application.action_status
593
+ end
594
+
595
+ it "should get the status of the daemon when crashed" do
596
+ expect(RExec::Daemon::ProcessFile).to receive(:status).and_return(:unknown)
597
+ expect(application.class).to receive(:crashed?).and_return(true)
598
+
599
+ expect(application.logger).to receive(:info).with("The server crashed. See the log for more information.")
600
+ application.action_status
601
+ end
602
+
603
+ it "should get the status of the daemon when unknown" do
604
+ expect(RExec::Daemon::ProcessFile).to receive(:status).and_return(:unknown)
605
+ expect(application.class).to receive(:crashed?).and_return(false)
606
+
607
+ expect(application.logger).to receive(:info).with("The server status is unknown.")
608
+ application.action_status
609
+ end
610
+ end
611
+
570
612
  describe "#action_install" do
571
613
  before(:each) do
572
614
  allow(application).to receive(:is_osx?).and_return(true)
@@ -11,7 +11,7 @@ describe DevDNSd::Configuration do
11
11
  describe "#initialize" do
12
12
  it "sets default arguments and rules" do
13
13
  config = DevDNSd::Configuration.new
14
- expect(config.address).to eq("0.0.0.0")
14
+ expect(config.bind_addresses).to eq(["0.0.0.0"])
15
15
  expect(config.port).to eq(7771)
16
16
  expect(config.tld).to eq("dev")
17
17
  expect(config.log_file).to eq(File.absolute_path(File.expand_path("~/.devdnsd/daemon.log")))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devdnsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.8
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shogun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-08 00:00:00.000000000 Z
11
+ date: 2014-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bovem