diff --git a/Gemfile b/Gemfile index f1efa06..c80ee36 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,3 @@ source "http://rubygems.org" -gem 'rake' gemspec diff --git a/em-proxy.gemspec b/em-proxy.gemspec index c3287ec..03c545f 100644 --- a/em-proxy.gemspec +++ b/em-proxy.gemspec @@ -17,6 +17,7 @@ Gem::Specification.new do |s| s.add_development_dependency "rspec" s.add_development_dependency "em-http-request" s.add_development_dependency "ansi" + s.add_development_dependency "rake" s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") diff --git a/examples/http_bind_proxy.rb b/examples/http_bind_proxy.rb deleted file mode 100644 index cb4d8c5..0000000 --- a/examples/http_bind_proxy.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'em-proxy' -require 'http/parser' # gem install http_parser.rb -require 'uuid' # gem install uuid - -# > ruby http_bind_proxy.rb -# > curl --proxy x.x.x.x:9889 www.google.com - -host = "0.0.0.0" -port = 9889 -puts "listening on #{host}:#{port}..." - -Proxy.start(:host => host, :port => port) do |conn| - - @p = Http::Parser.new - @p.on_headers_complete = proc do |h| - session = UUID.generate - puts "New session: #{session} (#{h.inspect})" - - host, port = h['Host'].split(':') - conn.server session, :host => host, :port => (port || 80), :bind_host => conn.peer[0] - conn.relay_to_servers @buffer - - @buffer.clear - end - - @buffer = '' - - conn.on_connect do |data,b| - puts [:on_connect, data, b].inspect - end - - conn.on_data do |data| - @buffer << data - @p << data - - data - end - - conn.on_response do |backend, resp| - puts [:on_response, backend, resp].inspect - resp - end - - conn.on_finish do |backend, name| - puts [:on_finish, name].inspect - end -end diff --git a/examples/http_proxy.rb b/examples/http_proxy.rb index be28295..c11e7fd 100644 --- a/examples/http_proxy.rb +++ b/examples/http_proxy.rb @@ -4,6 +4,7 @@ # > ruby http_proxy.rb # > curl --proxy localhost:9889 www.google.com +# > curl --proxy x.x.x.x:9889 www.google.com - bind ip example host = "0.0.0.0" port = 9889 @@ -17,7 +18,8 @@ puts "New session: #{session} (#{h.inspect})" host, port = h['Host'].split(':') - conn.server session, :host => host, :port => (port || 80) + conn.server session, :host => host, :port => (port || 80) #, :bind_host => conn.peer[0] - # for bind ip + conn.relay_to_servers @buffer @buffer.clear