hoof 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- Install: just symlink maked libnss_hoof.so.2 to /lib/libnss_hoof.so.2. Like this:
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
- Then set port redirecting up:
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.4
1
+ 0.0.5
@@ -11,3 +11,9 @@ libnss_hoof.so.2: $(OBJ)
11
11
 
12
12
  clean:
13
13
  rm -f *.o *~ libnss_hoof.so.2
14
+
15
+ install:
16
+ ln -sf $(CURDIR)/libnss_hoof.so.2 /lib
17
+
18
+ uninstall:
19
+ rm /lib/libnss_hoof.so.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hoof}
8
- s.version = "0.0.4"
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-16}
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}
@@ -36,22 +36,26 @@ module Hoof
36
36
  append_to_file 'Gemfile', "\ngem 'unicorn'"
37
37
  end
38
38
 
39
- desc "status", "Lists hoof applications"
39
+ desc 'status', 'Lists hoof applications'
40
40
  def status
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
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 "unroute", "Destroys hoof iptables redirecting rules"
53
- def unroute
54
- exec <<-E
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
@@ -2,7 +2,7 @@ module Hoof
2
2
  class ControlServer < EventMachine::Connection
3
3
 
4
4
  def receive_data data
5
- p "comand #{data}"
5
+ puts "Comand #{data}"
6
6
  result = send data
7
7
  send_data result
8
8
  close_connection_after_writing
@@ -2,17 +2,18 @@ module Hoof
2
2
  class HttpServer < EventMachine::Connection
3
3
 
4
4
  def receive_data data
5
- parser = Http::Parser.new
6
- parser.parse data
7
- host = parser.headers["HOST"].gsub(/:\d+$/, '')
5
+ begin
6
+ parser = Http::Parser.new
7
+ parser.parse data
8
8
 
9
- close_connection and return unless host =~ /.dev$/
9
+ host = parser.headers["HOST"].gsub(/:\d+$/, '')
10
10
 
11
- name = host.gsub(/.dev$/, '')
12
- application = Hoof.find name
11
+ close_connection and return unless host =~ /.dev$/
13
12
 
14
- if application
15
- begin
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
- rescue
25
- puts "Failed to serve #{name}"
25
+ else
26
+ close_connection
26
27
  end
27
- else
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
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-16 00:00:00 +04:00
18
+ date: 2011-05-17 00:00:00 +04:00
19
19
  default_executable: hoof
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency