tunnels 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -5
- data/bin/tunnels +14 -1
- data/lib/tunnels/version.rb +1 -1
- data/lib/tunnels.rb +16 -2
- data/spec/spec_helper.rb +6 -0
- data/spec/tunnels_spec.rb +24 -0
- data/tunnels.gemspec +2 -0
- metadata +31 -5
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Tunnels
|
2
2
|
=======
|
3
3
|
|
4
|
-
![image](http://i.imgur.com/
|
4
|
+
![image](http://i.imgur.com/Ej5dz.png)
|
5
5
|
|
6
6
|
Tunnels is a proxy to http from https.
|
7
7
|
|
@@ -17,15 +17,19 @@ Run
|
|
17
17
|
|
18
18
|
$ sudo tunnels
|
19
19
|
|
20
|
+
If you are using rvm:
|
21
|
+
|
22
|
+
$ rvmsudo tunnels
|
23
|
+
|
20
24
|
By default, proxy to 80 port from 443 port.
|
21
25
|
|
22
|
-
specify
|
26
|
+
specify "http" port and "https" port:
|
23
27
|
|
24
|
-
$ sudo tunnels
|
28
|
+
$ sudo tunnels 443 3000
|
25
29
|
|
26
|
-
|
30
|
+
or
|
27
31
|
|
28
|
-
$ sudo tunnels
|
32
|
+
$ sudo tunnels 127.0.0.1:443 127.0.0.1:3000
|
29
33
|
|
30
34
|
Copyright
|
31
35
|
---------
|
data/bin/tunnels
CHANGED
@@ -1,3 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'tunnels'
|
3
|
-
|
3
|
+
unless ARGV.size == 0 || ARGV.size == 2
|
4
|
+
puts <<-D
|
5
|
+
Usage:
|
6
|
+
tunnels [from to]
|
7
|
+
|
8
|
+
Examples:
|
9
|
+
tunnels 443 3000
|
10
|
+
tunnels localhost:443 localhost:3000
|
11
|
+
|
12
|
+
D
|
13
|
+
exit!
|
14
|
+
end
|
15
|
+
|
16
|
+
Tunnels.run!(*ARGV)
|
data/lib/tunnels/version.rb
CHANGED
data/lib/tunnels.rb
CHANGED
@@ -5,9 +5,13 @@ require "eventmachine"
|
|
5
5
|
# 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.
|
6
6
|
|
7
7
|
module Tunnels
|
8
|
-
def self.run!(
|
8
|
+
def self.run!(from = '127.0.0.1:443', to = '127.0.0.1:80')
|
9
|
+
from_host, from_port = parse_host_str(from)
|
10
|
+
to_host, to_port = parse_host_str(to)
|
11
|
+
puts "#{from_host}:#{from_port} --(--)--> #{to_host}:#{to_port}"
|
12
|
+
|
9
13
|
EventMachine.run do
|
10
|
-
EventMachine.start_server(
|
14
|
+
EventMachine.start_server(from_host, from_port, HttpsProxy, to_port)
|
11
15
|
puts "Ready :)"
|
12
16
|
end
|
13
17
|
rescue => e
|
@@ -15,6 +19,16 @@ module Tunnels
|
|
15
19
|
puts "Maybe you should run on `sudo`"
|
16
20
|
end
|
17
21
|
|
22
|
+
def self.parse_host_str(str)
|
23
|
+
raise ArgumentError, 'arg must not be empty' if str.empty?
|
24
|
+
parts = str.split(':')
|
25
|
+
if parts.size == 1
|
26
|
+
['127.0.0.1', parts[0].to_i]
|
27
|
+
else
|
28
|
+
[parts[0], parts[1].to_i]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
18
32
|
class HttpClient < EventMachine::Connection
|
19
33
|
attr_reader :proxy
|
20
34
|
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# to stub
|
4
|
+
def EventMachine.run(&block)
|
5
|
+
block.call
|
6
|
+
end
|
7
|
+
|
8
|
+
describe Tunnels do
|
9
|
+
describe '.run!' do
|
10
|
+
context 'with no args' do
|
11
|
+
it 'works' do
|
12
|
+
mock(EventMachine).start_server('127.0.0.1', 443, Tunnels::HttpsProxy, 80)
|
13
|
+
Tunnels.run!
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with args' do
|
18
|
+
it 'works' do
|
19
|
+
mock(EventMachine).start_server('127.0.0.1', 443, Tunnels::HttpsProxy, 80)
|
20
|
+
Tunnels.run!('127.0.0.1:443', '127.0.0.1:80')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/tunnels.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tunnels
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-08 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70272751148400 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70272751148400
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rr
|
27
|
+
requirement: &70272751147980 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70272751147980
|
14
36
|
- !ruby/object:Gem::Dependency
|
15
37
|
name: eventmachine
|
16
|
-
requirement: &
|
38
|
+
requirement: &70272751147480 !ruby/object:Gem::Requirement
|
17
39
|
none: false
|
18
40
|
requirements:
|
19
41
|
- - ! '>='
|
@@ -21,7 +43,7 @@ dependencies:
|
|
21
43
|
version: '0'
|
22
44
|
type: :runtime
|
23
45
|
prerelease: false
|
24
|
-
version_requirements: *
|
46
|
+
version_requirements: *70272751147480
|
25
47
|
description: This tunnels https to http.
|
26
48
|
email:
|
27
49
|
- jugyo.org@gmail.com
|
@@ -36,6 +58,8 @@ files:
|
|
36
58
|
- bin/tunnels
|
37
59
|
- lib/tunnels.rb
|
38
60
|
- lib/tunnels/version.rb
|
61
|
+
- spec/spec_helper.rb
|
62
|
+
- spec/tunnels_spec.rb
|
39
63
|
- tunnels.gemspec
|
40
64
|
homepage: https://github.com/jugyo/tunnels
|
41
65
|
licenses: []
|
@@ -61,4 +85,6 @@ rubygems_version: 1.8.10
|
|
61
85
|
signing_key:
|
62
86
|
specification_version: 3
|
63
87
|
summary: https --(--)--> http
|
64
|
-
test_files:
|
88
|
+
test_files:
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/tunnels_spec.rb
|