Module: Tunnelss

Extended by:
ConfigureWithPow
Defined in:
lib/tunnelss.rb,
lib/tunnelss/version.rb

Overview

[Tunnels](github.com/rchampourlier/tunnelss)

LICENSE

MIT License

COPYRIGHTS / CREDITS

Most of the code is from [tunnels](github.com/jugyo/tunnels) which was a simpler version designed to tunnel HTTPS to HTTP, without performing automatic certificate configuration.

[tunnels](github.com/jugyo/tunnels) Copyright © 2012 jugyo, released under the MIT license.

TUNNELS COPYRIGHTS / CREDITS

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

Modules: ConfigureWithPow Classes: HttpClient, HttpProxy, HttpsProxy

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Methods included from ConfigureWithPow

configure_with_pow, pow_present?

Class Method Details

.parse_host_str(str) ⇒ Object

Raises:

  • (ArgumentError)


46
47
48
49
50
51
52
53
54
# File 'lib/tunnelss.rb', line 46

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



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tunnelss.rb', line 30

def self.run!(from = '127.0.0.1:443', to = '127.0.0.1:80')
  configure_with_pow if pow_present?

  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.message
  puts "Maybe you should run on `sudo`"
end