Module: Tunnels
- Defined in:
- lib/tunnels.rb,
lib/tunnels/version.rb
Overview
most of code is from [thin-glazed](github.com/freelancing-god/thin-glazed). Copyright © 2012, Thin::Glazed was a Rails Camp New Zealand project, and is developed and maintained by Pat Allan. It is released under the open MIT Licence.
Defined Under Namespace
Classes: HttpClient, HttpProxy, HttpsProxy
Constant Summary collapse
- VERSION =
"1.2.2"
Class Method Summary collapse
Class Method Details
.parse_host_str(str) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/tunnels.rb', line 22 def self.parse_host_str(str) raise ArgumentError, 'arg must not be empty' if str.empty? parts = str.split(':') if parts.size == 1 ['127.0.0.1', parts[0].to_i] else [parts[0], parts[1].to_i] end end |
.run!(from = '127.0.0.1:443', to = '127.0.0.1:80') ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tunnels.rb', line 8 def self.run!(from = '127.0.0.1:443', to = '127.0.0.1:80') from_host, from_port = parse_host_str(from) to_host, to_port = parse_host_str(to) puts "#{from_host}:#{from_port} --(--)--> #{to_host}:#{to_port}" EventMachine.run do EventMachine.start_server(from_host, from_port, HttpsProxy, to_port) puts "Ready :)" end rescue => e puts e. puts "Maybe you should run on `sudo`" end |