rtunnel 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +1 -0
- data/README.markdown +2 -2
- data/lib/rtunnel/client.rb +3 -2
- data/lib/rtunnel/socket_factory.rb +6 -6
- data/test/test_socket_factory.rb +10 -0
- metadata +50 -97
- data/rtunnel.gemspec +0 -51
data/Manifest
CHANGED
data/README.markdown
CHANGED
@@ -56,7 +56,7 @@ ports that clients can open up on the rtunnel server.
|
|
56
56
|
restricts clients to using ports 3000-3999 for reverse tunnels.
|
57
57
|
|
58
58
|
|
59
|
-
RTunnel
|
59
|
+
<a name="about">RTunnel?</a>
|
60
60
|
-
|
61
61
|
|
62
62
|
This client/server allow you to reverse tunnel traffic. Reverse tunneling is useful if you want to run a server behind a NAT and you do not have the ability to use port forwarding. The specific reason I created this program was to reduce the pain of Facebook App development on a crappy internet connection that drops often. ssh -R was not cutting it.
|
@@ -81,4 +81,4 @@ With tunneling, usually your connections are made in the same direction you crea
|
|
81
81
|
|
82
82
|
**Why not just use ssh -R?**
|
83
83
|
|
84
|
-
The same thing can be achieved with ssh -R, so why not just use it? A lot of ssh servers don't have the GatewayPorts sshd option set up to allow you to reverse tunnel. If you are not in control of the server and it is not setup correctly then you are SOL. RTunnel does not require you are in control of the server. ssh -R also has other annoyances. When your connection drops and you try to re-initiate the reverse tunnel sometimes you get an 'address already in use error' because the old tunnel process is still laying around. This may require you to kill the existing sshd process. RTunnel does not have this problem.
|
84
|
+
The same thing can be achieved with ssh -R, so why not just use it? A lot of ssh servers don't have the GatewayPorts sshd option set up to allow you to reverse tunnel. If you are not in control of the server and it is not setup correctly then you are SOL. RTunnel does not require you are in control of the server. ssh -R also has other annoyances. When your connection drops and you try to re-initiate the reverse tunnel sometimes you get an 'address already in use error' because the old tunnel process is still laying around. This may require you to kill the existing sshd process. RTunnel does not have this problem.
|
data/lib/rtunnel/client.rb
CHANGED
@@ -23,14 +23,15 @@ class RTunnel::Client
|
|
23
23
|
def start
|
24
24
|
return if @server_connection
|
25
25
|
@control_host = SocketFactory.host_from_address @control_address
|
26
|
+
@control_bind_host = SocketFactory.bind_host_from_address @control_address
|
26
27
|
@control_port = SocketFactory.port_from_address @control_address
|
27
28
|
connect_to_server
|
28
29
|
end
|
29
30
|
|
30
31
|
def connect_to_server
|
31
32
|
D "Connecting to #{@control_host} port #{@control_port}"
|
32
|
-
@server_connection = EventMachine.
|
33
|
-
|
33
|
+
@server_connection = EventMachine.bind_connect @control_bind_host, nil, @control_host, @control_port,
|
34
|
+
Client::ServerConnection, self
|
34
35
|
end
|
35
36
|
|
36
37
|
def stop
|
@@ -2,12 +2,8 @@ require 'socket'
|
|
2
2
|
|
3
3
|
module RTunnel::SocketFactory
|
4
4
|
def self.split_address(address)
|
5
|
-
|
6
|
-
|
7
|
-
[address[0, port_index + 1], address[port_index + 2, address.length]]
|
8
|
-
else
|
9
|
-
[address, nil]
|
10
|
-
end
|
5
|
+
address =~ /\A(.+?[^:])(?::([^:].+?[^:])(?::([^:].+?[^:]))?)?\Z/
|
6
|
+
[$1, $2, $3]
|
11
7
|
end
|
12
8
|
|
13
9
|
def self.host_from_address(address)
|
@@ -17,6 +13,10 @@ module RTunnel::SocketFactory
|
|
17
13
|
def self.port_from_address(address)
|
18
14
|
address and (port_string = split_address(address)[1]) and port_string.to_i
|
19
15
|
end
|
16
|
+
|
17
|
+
def self.bind_host_from_address(address)
|
18
|
+
address and split_address(address)[2]
|
19
|
+
end
|
20
20
|
|
21
21
|
def self.inbound?(options)
|
22
22
|
options[:inbound] or [:in_port, :in_host, :in_addr].any? { |k| options[k] }
|
data/test/test_socket_factory.rb
CHANGED
@@ -28,6 +28,16 @@ class SocketFactoryTest < Test::Unit::TestCase
|
|
28
28
|
assert_equal nil, SF.port_from_address('fe80::1%lo0')
|
29
29
|
assert_equal 19020, SF.port_from_address('fe80::1%lo0:19020')
|
30
30
|
end
|
31
|
+
|
32
|
+
def test_bind_host_from_address
|
33
|
+
assert_equal nil, SF.bind_host_from_address('127.0.0.1')
|
34
|
+
assert_equal nil, SF.bind_host_from_address('127.0.0.1:1234')
|
35
|
+
assert_equal nil, SF.bind_host_from_address('fe80::1%lo0')
|
36
|
+
assert_equal nil, SF.bind_host_from_address('fe80::1%lo0:19020')
|
37
|
+
assert_equal '127.0.0.1', SF.bind_host_from_address('127.0.0.1:1234:127.0.0.1')
|
38
|
+
assert_equal '192.168.1.1', SF.bind_host_from_address('fe80::1%lo0:19020:192.168.1.1')
|
39
|
+
assert_equal 'fe80::1%eth1', SF.bind_host_from_address('fe80::1%lo0:19020:fe80::1%eth1')
|
40
|
+
end
|
31
41
|
|
32
42
|
def test_inbound
|
33
43
|
assert SF.inbound?(:in_port => 1)
|
metadata
CHANGED
@@ -1,105 +1,65 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtunnel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 13
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- coderrr
|
14
|
+
- costan
|
8
15
|
autorequire:
|
9
16
|
bindir: bin
|
10
17
|
cert_chain: []
|
11
18
|
|
12
|
-
date:
|
19
|
+
date: 2010-06-26 00:00:00 +07:00
|
13
20
|
default_executable:
|
14
21
|
dependencies:
|
15
22
|
- !ruby/object:Gem::Dependency
|
16
23
|
name: eventmachine
|
17
|
-
|
18
|
-
|
19
|
-
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
20
27
|
requirements:
|
21
28
|
- - ">="
|
22
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 43
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
- 12
|
34
|
+
- 2
|
23
35
|
version: 0.12.2
|
24
|
-
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
25
38
|
- !ruby/object:Gem::Dependency
|
26
39
|
name: net-ssh
|
27
|
-
|
28
|
-
|
29
|
-
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
30
43
|
requirements:
|
31
44
|
- - ">="
|
32
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 7
|
47
|
+
segments:
|
48
|
+
- 2
|
49
|
+
- 0
|
50
|
+
- 4
|
33
51
|
version: 2.0.4
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
type: :development
|
38
|
-
version_requirement:
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 3.0.1
|
44
|
-
version:
|
45
|
-
- !ruby/object:Gem::Dependency
|
46
|
-
name: rspec
|
47
|
-
type: :development
|
48
|
-
version_requirement:
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 1.1.11
|
54
|
-
version:
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: simple-daemon
|
57
|
-
type: :development
|
58
|
-
version_requirement:
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - ">="
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: 0.1.2
|
64
|
-
version:
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: thin
|
67
|
-
type: :development
|
68
|
-
version_requirement:
|
69
|
-
version_requirements: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - ">="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: 1.0.0
|
74
|
-
version:
|
75
|
-
description: Reverse tunnel server and client.
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
54
|
+
description: ""
|
76
55
|
email: coderrr.contact@gmail.com
|
77
56
|
executables:
|
78
57
|
- rtunnel_client
|
79
58
|
- rtunnel_server
|
80
59
|
extensions: []
|
81
60
|
|
82
|
-
extra_rdoc_files:
|
83
|
-
|
84
|
-
- LICENSE
|
85
|
-
- README.markdown
|
86
|
-
- bin/rtunnel_client
|
87
|
-
- bin/rtunnel_server
|
88
|
-
- lib/rtunnel.rb
|
89
|
-
- lib/rtunnel/client.rb
|
90
|
-
- lib/rtunnel/command_protocol.rb
|
91
|
-
- lib/rtunnel/commands.rb
|
92
|
-
- lib/rtunnel/core.rb
|
93
|
-
- lib/rtunnel/crypto.rb
|
94
|
-
- lib/rtunnel/frame_protocol.rb
|
95
|
-
- lib/rtunnel/io_extensions.rb
|
96
|
-
- lib/rtunnel/leak.rb
|
97
|
-
- lib/rtunnel/rtunnel_client_cmd.rb
|
98
|
-
- lib/rtunnel/rtunnel_server_cmd.rb
|
99
|
-
- lib/rtunnel/server.rb
|
100
|
-
- lib/rtunnel/socket_factory.rb
|
101
|
-
- lib/rtunnel/connection_id.rb
|
102
|
-
- lib/rtunnel/command_processor.rb
|
61
|
+
extra_rdoc_files: []
|
62
|
+
|
103
63
|
files:
|
104
64
|
- CHANGELOG
|
105
65
|
- LICENSE
|
@@ -149,46 +109,39 @@ files:
|
|
149
109
|
- tests/_ab_test.rb
|
150
110
|
- tests/_stress_test.rb
|
151
111
|
- tests/lo_http_server.rb
|
152
|
-
- rtunnel.gemspec
|
153
112
|
has_rdoc: true
|
154
113
|
homepage: http://github.com/coderrr/rtunnel
|
114
|
+
licenses: []
|
115
|
+
|
155
116
|
post_install_message:
|
156
|
-
rdoc_options:
|
157
|
-
|
158
|
-
- --inline-source
|
159
|
-
- --title
|
160
|
-
- Rtunnel
|
161
|
-
- --main
|
162
|
-
- README.markdown
|
117
|
+
rdoc_options: []
|
118
|
+
|
163
119
|
require_paths:
|
164
120
|
- lib
|
165
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
166
123
|
requirements:
|
167
124
|
- - ">="
|
168
125
|
- !ruby/object:Gem::Version
|
126
|
+
hash: 3
|
127
|
+
segments:
|
128
|
+
- 0
|
169
129
|
version: "0"
|
170
|
-
version:
|
171
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
172
132
|
requirements:
|
173
133
|
- - ">="
|
174
134
|
- !ruby/object:Gem::Version
|
175
|
-
|
176
|
-
|
135
|
+
hash: 3
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
version: "0"
|
177
139
|
requirements: []
|
178
140
|
|
179
|
-
rubyforge_project:
|
180
|
-
rubygems_version: 1.3.
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 1.3.7
|
181
143
|
signing_key:
|
182
|
-
specification_version:
|
144
|
+
specification_version: 3
|
183
145
|
summary: Reverse tunnel server and client.
|
184
|
-
test_files:
|
185
|
-
|
186
|
-
- test/test_frame_protocol.rb
|
187
|
-
- test/test_connection_id.rb
|
188
|
-
- test/test_tunnel.rb
|
189
|
-
- test/test_socket_factory.rb
|
190
|
-
- test/test_client.rb
|
191
|
-
- test/test_crypto.rb
|
192
|
-
- test/test_io_extensions.rb
|
193
|
-
- test/test_command_protocol.rb
|
194
|
-
- test/test_server.rb
|
146
|
+
test_files: []
|
147
|
+
|
data/rtunnel.gemspec
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{rtunnel}
|
5
|
-
s.version = "0.4.0"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["coderrr"]
|
9
|
-
s.date = %q{2009-01-26}
|
10
|
-
s.description = %q{Reverse tunnel server and client.}
|
11
|
-
s.email = %q{coderrr.contact@gmail.com}
|
12
|
-
s.executables = ["rtunnel_client", "rtunnel_server"]
|
13
|
-
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.markdown", "bin/rtunnel_client", "bin/rtunnel_server", "lib/rtunnel.rb", "lib/rtunnel/client.rb", "lib/rtunnel/command_protocol.rb", "lib/rtunnel/commands.rb", "lib/rtunnel/core.rb", "lib/rtunnel/crypto.rb", "lib/rtunnel/frame_protocol.rb", "lib/rtunnel/io_extensions.rb", "lib/rtunnel/leak.rb", "lib/rtunnel/rtunnel_client_cmd.rb", "lib/rtunnel/rtunnel_server_cmd.rb", "lib/rtunnel/server.rb", "lib/rtunnel/socket_factory.rb", "lib/rtunnel/connection_id.rb", "lib/rtunnel/command_processor.rb"]
|
14
|
-
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README.markdown", "Rakefile", "bin/rtunnel_client", "bin/rtunnel_server", "lib/rtunnel.rb", "lib/rtunnel/client.rb", "lib/rtunnel/command_protocol.rb", "lib/rtunnel/commands.rb", "lib/rtunnel/core.rb", "lib/rtunnel/crypto.rb", "lib/rtunnel/frame_protocol.rb", "lib/rtunnel/io_extensions.rb", "lib/rtunnel/leak.rb", "lib/rtunnel/rtunnel_client_cmd.rb", "lib/rtunnel/rtunnel_server_cmd.rb", "lib/rtunnel/server.rb", "lib/rtunnel/socket_factory.rb", "lib/rtunnel/connection_id.rb", "lib/rtunnel/command_processor.rb", "spec/client_spec.rb", "spec/cmds_spec.rb", "spec/integration_spec.rb", "spec/server_spec.rb", "spec/spec_helper.rb", "test/command_stubs.rb", "test/protocol_mocks.rb", "test/scenario_connection.rb", "test/test_client.rb", "test/test_command_protocol.rb", "test/test_commands.rb", "test/test_crypto.rb", "test/test_frame_protocol.rb", "test/test_io_extensions.rb", "test/test_server.rb", "test/test_socket_factory.rb", "test/test_tunnel.rb", "test/test_connection_id.rb", "test_data/known_hosts", "test_data/ssh_host_rsa_key", "test_data/random_rsa_key", "test_data/ssh_host_dsa_key", "test_data/authorized_keys2", "tests/_ab_test.rb", "tests/_stress_test.rb", "tests/lo_http_server.rb", "rtunnel.gemspec"]
|
15
|
-
s.has_rdoc = true
|
16
|
-
s.homepage = %q{http://github.com/coderrr/rtunnel}
|
17
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rtunnel", "--main", "README.markdown"]
|
18
|
-
s.require_paths = ["lib"]
|
19
|
-
s.rubyforge_project = %q{coderrr}
|
20
|
-
s.rubygems_version = %q{1.3.1}
|
21
|
-
s.summary = %q{Reverse tunnel server and client.}
|
22
|
-
s.test_files = ["test/test_commands.rb", "test/test_frame_protocol.rb", "test/test_connection_id.rb", "test/test_tunnel.rb", "test/test_socket_factory.rb", "test/test_client.rb", "test/test_crypto.rb", "test/test_io_extensions.rb", "test/test_command_protocol.rb", "test/test_server.rb"]
|
23
|
-
|
24
|
-
if s.respond_to? :specification_version then
|
25
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
|
-
s.specification_version = 2
|
27
|
-
|
28
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
|
-
s.add_runtime_dependency(%q<eventmachine>, [">= 0.12.2"])
|
30
|
-
s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.4"])
|
31
|
-
s.add_development_dependency(%q<echoe>, [">= 3.0.1"])
|
32
|
-
s.add_development_dependency(%q<rspec>, [">= 1.1.11"])
|
33
|
-
s.add_development_dependency(%q<simple-daemon>, [">= 0.1.2"])
|
34
|
-
s.add_development_dependency(%q<thin>, [">= 1.0.0"])
|
35
|
-
else
|
36
|
-
s.add_dependency(%q<eventmachine>, [">= 0.12.2"])
|
37
|
-
s.add_dependency(%q<net-ssh>, [">= 2.0.4"])
|
38
|
-
s.add_dependency(%q<echoe>, [">= 3.0.1"])
|
39
|
-
s.add_dependency(%q<rspec>, [">= 1.1.11"])
|
40
|
-
s.add_dependency(%q<simple-daemon>, [">= 0.1.2"])
|
41
|
-
s.add_dependency(%q<thin>, [">= 1.0.0"])
|
42
|
-
end
|
43
|
-
else
|
44
|
-
s.add_dependency(%q<eventmachine>, [">= 0.12.2"])
|
45
|
-
s.add_dependency(%q<net-ssh>, [">= 2.0.4"])
|
46
|
-
s.add_dependency(%q<echoe>, [">= 3.0.1"])
|
47
|
-
s.add_dependency(%q<rspec>, [">= 1.1.11"])
|
48
|
-
s.add_dependency(%q<simple-daemon>, [">= 0.1.2"])
|
49
|
-
s.add_dependency(%q<thin>, [">= 1.0.0"])
|
50
|
-
end
|
51
|
-
end
|