hoof 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,6 +24,10 @@ Then change your /etc/nsswitch.conf like this:
24
24
 
25
25
  <tt>hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 hoof</tt>
26
26
 
27
+ Then set port redirecting up:
28
+
29
+ <tt>hoof route</tt>
30
+
27
31
  === Application
28
32
 
29
33
  Next step - initialize hoof for application:
@@ -40,7 +44,7 @@ Hoof has basic cli for controlling.
40
44
 
41
45
  Use <tt>hoof</tt> executable to start daemon. Read <tt>hoof help</tt>
42
46
 
43
- Start your browser and go to http://app.dev:3001
47
+ Start your browser and go to http://app.dev
44
48
 
45
49
 
46
50
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hoof}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["pyromaniac"]
@@ -27,7 +27,8 @@ module Hoof
27
27
  trap("TERM") { stop }
28
28
  trap("INT") { stop }
29
29
 
30
- EventMachine::start_server "127.0.0.1", 3001, Hoof::HttpServer
30
+ EventMachine::start_server "127.0.0.1", http_port, Hoof::HttpServer
31
+ EventMachine::start_server "127.0.0.1", https_port, Hoof::HttpServer
31
32
  EventMachine::start_server sock, Hoof::ControlServer
32
33
  end
33
34
  end
@@ -41,4 +42,12 @@ module Hoof
41
42
  '/tmp/hoof.sock'
42
43
  end
43
44
 
45
+ def self.http_port
46
+ 26080
47
+ end
48
+
49
+ def self.https_port
50
+ 26443
51
+ end
52
+
44
53
  end
@@ -41,6 +41,22 @@ module Hoof
41
41
  control 'status'
42
42
  end
43
43
 
44
+ desc "route", "Redirects http ports to hoof default ports with iptables"
45
+ def route
46
+ exec <<-E
47
+ sudo iptables -t nat -I OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports #{Hoof.http_port} &&
48
+ sudo iptables -t nat -I OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to-ports #{Hoof.https_port}
49
+ E
50
+ end
51
+
52
+ desc "unroute", "Destroys hoof iptables redirecting rules"
53
+ def unroute
54
+ exec <<-E
55
+ sudo iptables -t nat -D OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports #{Hoof.http_port} &&
56
+ sudo iptables -t nat -D OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to-ports #{Hoof.https_port}
57
+ E
58
+ end
59
+
44
60
  private
45
61
 
46
62
  def daemon *argv
@@ -9,28 +9,20 @@ module Hoof
9
9
  close_connection and return unless host =~ /.dev$/
10
10
 
11
11
  name = host.gsub(/.dev$/, '')
12
- path = parser.path.split('?', 2)[0]
13
-
14
12
  application = Hoof.find name
15
13
 
16
14
  if application
17
- if application.static_file? path
18
- puts "Serve static #{host}#{parser.path}"
19
- send_data application.serve_static(path)
20
- close_connection_after_writing
21
- else
22
- begin
23
- application.start
24
- puts "Serve #{host}#{parser.path}"
25
- EventMachine.defer(proc {
26
- application.serve data
27
- }, proc { |result|
28
- send_data result
29
- close_connection_after_writing
30
- })
31
- rescue
32
- puts "Failed to serve #{name}"
33
- end
15
+ begin
16
+ application.start
17
+ puts "Serve #{host}#{parser.path}"
18
+ EventMachine.defer(proc {
19
+ application.serve data
20
+ }, proc { |result|
21
+ send_data result
22
+ close_connection_after_writing
23
+ })
24
+ rescue
25
+ puts "Failed to serve #{name}"
34
26
  end
35
27
  else
36
28
  close_connection
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoof
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - pyromaniac