reverse-tunnel 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/Gemfile +6 -0
- data/Guardfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +99 -0
- data/Rakefile +4 -0
- data/bin/reverse-tunnel +5 -0
- data/lib/reverse-tunnel.rb +35 -0
- data/lib/reverse-tunnel/cli.rb +170 -0
- data/lib/reverse-tunnel/client.rb +304 -0
- data/lib/reverse-tunnel/message.rb +140 -0
- data/lib/reverse-tunnel/server.rb +406 -0
- data/lib/reverse-tunnel/version.rb +3 -0
- data/reverse-tunnel.gemspec +33 -0
- data/spec/reverse-tunnel/cli_spec.rb +118 -0
- data/spec/reverse-tunnel/client/api_server_spec.rb +72 -0
- data/spec/reverse-tunnel/client_spec.rb +79 -0
- data/spec/reverse-tunnel/message_spec.rb +55 -0
- data/spec/reverse-tunnel/server/api_server_spec.rb +125 -0
- data/spec/reverse-tunnel/server/tunnels_spec.rb +66 -0
- data/spec/reverse-tunnel/server_spec.rb +57 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/log.rb +9 -0
- data/tasks/rspec.rake +2 -0
- metadata +280 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ReverseTunnel::Server::Tunnels do
|
4
|
+
|
5
|
+
describe "#create_token" do
|
6
|
+
|
7
|
+
it "should be very long" do
|
8
|
+
subject.create_token.size.should >= 28
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#available_local_port" do
|
14
|
+
|
15
|
+
before do
|
16
|
+
subject.local_port_range = 1000..1001
|
17
|
+
subject.stub :used_local_ports => 1000
|
18
|
+
subject.available_local_port.should == 1001
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#create" do
|
24
|
+
|
25
|
+
it "should create a default token when no specified" do
|
26
|
+
subject.stub :create_token => "dummy"
|
27
|
+
subject.create.token.should == "dummy"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should use available local port when no specified" do
|
31
|
+
subject.stub :available_local_port => 123
|
32
|
+
subject.create.local_port.should == 123
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should add tunnel" do
|
36
|
+
tunnel = subject.create "token" => "test"
|
37
|
+
subject.find("test").should == tunnel
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#destroy" do
|
43
|
+
|
44
|
+
let(:tunnel) { subject.create }
|
45
|
+
|
46
|
+
it "should remove tunnel" do
|
47
|
+
subject.destroy tunnel.token
|
48
|
+
subject.find(tunnel.token).should be_nil
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should close tunnel" do
|
52
|
+
tunnel.should_receive(:close)
|
53
|
+
subject.destroy tunnel.token
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should return removed tunnel" do
|
57
|
+
subject.destroy(tunnel.token).should == tunnel
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should return nil if no tunnel is found" do
|
61
|
+
subject.destroy("dummy").should be_nil
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ReverseTunnel::Server do
|
4
|
+
|
5
|
+
describe "#server_host" do
|
6
|
+
|
7
|
+
it "should be '0.0.0.0' by default" do
|
8
|
+
subject.server_host.should == '0.0.0.0'
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#server_port" do
|
14
|
+
|
15
|
+
it "should be 4893 by default" do
|
16
|
+
subject.server_port.should == 4893
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#start_server" do
|
22
|
+
it "should use server_host and server_port" do
|
23
|
+
subject.server_host = "localhost"
|
24
|
+
subject.server_port = 123
|
25
|
+
|
26
|
+
EventMachine.should_receive(:start_server).with("localhost", 123, anything, anything)
|
27
|
+
subject.start_server
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#api_host" do
|
32
|
+
|
33
|
+
it "should be '127.0.0.1' by default" do
|
34
|
+
subject.api_host.should == '127.0.0.1'
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#api_port" do
|
40
|
+
|
41
|
+
it "should be 4894 by default" do
|
42
|
+
subject.api_port.should == 4894
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#start_api" do
|
48
|
+
it "should use api_host and api_port" do
|
49
|
+
subject.api_host = "localhost"
|
50
|
+
subject.api_port = 123
|
51
|
+
|
52
|
+
EventMachine.should_receive(:start_server).with("localhost", 123, anything, anything)
|
53
|
+
subject.start_api
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter "/spec/"
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'reverse-tunnel'
|
8
|
+
include ReverseTunnel
|
9
|
+
|
10
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
|
14
|
+
|
15
|
+
end
|
data/spec/support/log.rb
ADDED
data/tasks/rspec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: reverse-tunnel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alban Peignier
|
9
|
+
- Florent Peyraud
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: eventmachine
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: msgpack
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: eventmachine_httpserver
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: json
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: trollop
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
type: :runtime
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: SyslogLogger
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: rspec
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ! '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
type: :development
|
136
|
+
prerelease: false
|
137
|
+
version_requirements: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
name: guard
|
145
|
+
requirement: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ! '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
type: :development
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: guard-rspec
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
type: :development
|
168
|
+
prerelease: false
|
169
|
+
version_requirements: !ruby/object:Gem::Requirement
|
170
|
+
none: false
|
171
|
+
requirements:
|
172
|
+
- - ! '>='
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
- !ruby/object:Gem::Dependency
|
176
|
+
name: rake
|
177
|
+
requirement: !ruby/object:Gem::Requirement
|
178
|
+
none: false
|
179
|
+
requirements:
|
180
|
+
- - ! '>='
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
type: :development
|
184
|
+
prerelease: false
|
185
|
+
version_requirements: !ruby/object:Gem::Requirement
|
186
|
+
none: false
|
187
|
+
requirements:
|
188
|
+
- - ! '>='
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
- !ruby/object:Gem::Dependency
|
192
|
+
name: rest-client
|
193
|
+
requirement: !ruby/object:Gem::Requirement
|
194
|
+
none: false
|
195
|
+
requirements:
|
196
|
+
- - ! '>='
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '0'
|
199
|
+
type: :development
|
200
|
+
prerelease: false
|
201
|
+
version_requirements: !ruby/object:Gem::Requirement
|
202
|
+
none: false
|
203
|
+
requirements:
|
204
|
+
- - ! '>='
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
207
|
+
description: Create easily a tunnel to forward connection (like a ssh) to the client
|
208
|
+
host
|
209
|
+
email:
|
210
|
+
- alban@tryphon.eu
|
211
|
+
- florent@tryphon.eu
|
212
|
+
executables:
|
213
|
+
- reverse-tunnel
|
214
|
+
extensions: []
|
215
|
+
extra_rdoc_files: []
|
216
|
+
files:
|
217
|
+
- .gitignore
|
218
|
+
- Gemfile
|
219
|
+
- Guardfile
|
220
|
+
- LICENSE.txt
|
221
|
+
- README.md
|
222
|
+
- Rakefile
|
223
|
+
- bin/reverse-tunnel
|
224
|
+
- lib/reverse-tunnel.rb
|
225
|
+
- lib/reverse-tunnel/cli.rb
|
226
|
+
- lib/reverse-tunnel/client.rb
|
227
|
+
- lib/reverse-tunnel/message.rb
|
228
|
+
- lib/reverse-tunnel/server.rb
|
229
|
+
- lib/reverse-tunnel/version.rb
|
230
|
+
- reverse-tunnel.gemspec
|
231
|
+
- spec/reverse-tunnel/cli_spec.rb
|
232
|
+
- spec/reverse-tunnel/client/api_server_spec.rb
|
233
|
+
- spec/reverse-tunnel/client_spec.rb
|
234
|
+
- spec/reverse-tunnel/message_spec.rb
|
235
|
+
- spec/reverse-tunnel/server/api_server_spec.rb
|
236
|
+
- spec/reverse-tunnel/server/tunnels_spec.rb
|
237
|
+
- spec/reverse-tunnel/server_spec.rb
|
238
|
+
- spec/spec_helper.rb
|
239
|
+
- spec/support/log.rb
|
240
|
+
- tasks/rspec.rake
|
241
|
+
homepage: http://projects.tryphon.eu/projects/reverse-tunnel
|
242
|
+
licenses: []
|
243
|
+
post_install_message:
|
244
|
+
rdoc_options: []
|
245
|
+
require_paths:
|
246
|
+
- lib
|
247
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
248
|
+
none: false
|
249
|
+
requirements:
|
250
|
+
- - ! '>='
|
251
|
+
- !ruby/object:Gem::Version
|
252
|
+
version: '0'
|
253
|
+
segments:
|
254
|
+
- 0
|
255
|
+
hash: -1765288854633900914
|
256
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
257
|
+
none: false
|
258
|
+
requirements:
|
259
|
+
- - ! '>='
|
260
|
+
- !ruby/object:Gem::Version
|
261
|
+
version: '0'
|
262
|
+
segments:
|
263
|
+
- 0
|
264
|
+
hash: -1765288854633900914
|
265
|
+
requirements: []
|
266
|
+
rubyforge_project:
|
267
|
+
rubygems_version: 1.8.23
|
268
|
+
signing_key:
|
269
|
+
specification_version: 3
|
270
|
+
summary: Forward a tcp connection to client host
|
271
|
+
test_files:
|
272
|
+
- spec/reverse-tunnel/cli_spec.rb
|
273
|
+
- spec/reverse-tunnel/client/api_server_spec.rb
|
274
|
+
- spec/reverse-tunnel/client_spec.rb
|
275
|
+
- spec/reverse-tunnel/message_spec.rb
|
276
|
+
- spec/reverse-tunnel/server/api_server_spec.rb
|
277
|
+
- spec/reverse-tunnel/server/tunnels_spec.rb
|
278
|
+
- spec/reverse-tunnel/server_spec.rb
|
279
|
+
- spec/spec_helper.rb
|
280
|
+
- spec/support/log.rb
|