hoof 0.0.4 → 0.0.5
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/README.rdoc +4 -11
- data/VERSION +1 -1
- data/ext/Makefile +6 -0
- data/hoof.gemspec +2 -2
- data/lib/hoof/cli.rb +11 -7
- data/lib/hoof/control_server.rb +1 -1
- data/lib/hoof/http_server.rb +14 -11
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
Linux version of https://github.com/37signals/pow/
|
4
4
|
|
5
|
+
|
5
6
|
== Installation
|
6
7
|
|
7
8
|
=== Gem
|
@@ -10,23 +11,15 @@ At first - install gem
|
|
10
11
|
|
11
12
|
<tt>gem install hoof</tt>
|
12
13
|
|
13
|
-
=== NSS extension
|
14
|
-
|
15
|
-
Second step - you should compile and install libnss_hoof.so.
|
16
|
-
|
17
|
-
Compile: cd /to/your/gems/installation/path/gems/hoof-x.x.x/ext and +make+
|
14
|
+
=== NSS extension and port forwarding
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
<tt>cd /lib; sudo ln -sf /to/your/gems/installation/path/gems/hoof-x.x.x/ext/libnss_hoof.so.2</tt>
|
16
|
+
<tt>hoof install</tt>
|
22
17
|
|
23
18
|
Then change your /etc/nsswitch.conf like this:
|
24
19
|
|
25
20
|
<tt>hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 hoof</tt>
|
26
21
|
|
27
|
-
|
28
|
-
|
29
|
-
<tt>hoof route</tt>
|
22
|
+
!!Do not forget restart browser!!
|
30
23
|
|
31
24
|
=== Application
|
32
25
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/ext/Makefile
CHANGED
data/hoof.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{hoof}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["pyromaniac"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-17}
|
13
13
|
s.default_executable = %q{hoof}
|
14
14
|
s.description = %q{Hoof is linux variant of pow. It's based on nss, eventmachine and unicorn}
|
15
15
|
s.email = %q{kinwizard@gmail.com}
|
data/lib/hoof/cli.rb
CHANGED
@@ -36,22 +36,26 @@ module Hoof
|
|
36
36
|
append_to_file 'Gemfile', "\ngem 'unicorn'"
|
37
37
|
end
|
38
38
|
|
39
|
-
desc
|
39
|
+
desc 'status', 'Lists hoof applications'
|
40
40
|
def status
|
41
41
|
control 'status'
|
42
42
|
end
|
43
43
|
|
44
|
-
desc
|
45
|
-
def
|
46
|
-
|
44
|
+
desc 'install [TARGET]', 'Redirects http ports to hoof default ports with iptables'
|
45
|
+
def install target = ''
|
46
|
+
ext = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'ext'))
|
47
|
+
puts "Successfully installed NSS library" if system "cd #{ext} && make && sudo make install"
|
48
|
+
puts "Successfully added iptables rules" if system <<-E
|
47
49
|
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
50
|
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
51
|
E
|
50
52
|
end
|
51
53
|
|
52
|
-
desc
|
53
|
-
def
|
54
|
-
|
54
|
+
desc 'uninstall [TARGET]', 'Destroys hoof iptables redirecting rules'
|
55
|
+
def uninstall target = ''
|
56
|
+
ext = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'ext'))
|
57
|
+
puts "Successfully uninstalled NSS library" if system "cd #{ext} && sudo make uninstall && make clean"
|
58
|
+
puts "Successfully removed iptables rules" if system <<-E
|
55
59
|
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
60
|
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
61
|
E
|
data/lib/hoof/control_server.rb
CHANGED
data/lib/hoof/http_server.rb
CHANGED
@@ -2,17 +2,18 @@ module Hoof
|
|
2
2
|
class HttpServer < EventMachine::Connection
|
3
3
|
|
4
4
|
def receive_data data
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
begin
|
6
|
+
parser = Http::Parser.new
|
7
|
+
parser.parse data
|
8
8
|
|
9
|
-
|
9
|
+
host = parser.headers["HOST"].gsub(/:\d+$/, '')
|
10
10
|
|
11
|
-
|
12
|
-
application = Hoof.find name
|
11
|
+
close_connection and return unless host =~ /.dev$/
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
name = host.gsub(/.dev$/, '')
|
14
|
+
application = Hoof.find name
|
15
|
+
|
16
|
+
if application
|
16
17
|
application.start
|
17
18
|
puts "Serve #{host}#{parser.path}"
|
18
19
|
EventMachine.defer(proc {
|
@@ -21,10 +22,12 @@ module Hoof
|
|
21
22
|
send_data result
|
22
23
|
close_connection_after_writing
|
23
24
|
})
|
24
|
-
|
25
|
-
|
25
|
+
else
|
26
|
+
close_connection
|
26
27
|
end
|
27
|
-
|
28
|
+
rescue => e
|
29
|
+
puts e.message
|
30
|
+
puts e.backtrace.join("\n")
|
28
31
|
close_connection
|
29
32
|
end
|
30
33
|
end
|
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:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- pyromaniac
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-17 00:00:00 +04:00
|
19
19
|
default_executable: hoof
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|