rtunnel 0.3.8 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. data/CHANGELOG +13 -0
  2. data/LICENSE +21 -0
  3. data/Manifest +48 -0
  4. data/README.markdown +84 -0
  5. data/Rakefile +45 -0
  6. data/bin/rtunnel_client +2 -1
  7. data/bin/rtunnel_server +2 -1
  8. data/lib/rtunnel/client.rb +308 -0
  9. data/lib/rtunnel/command_processor.rb +62 -0
  10. data/lib/rtunnel/command_protocol.rb +50 -0
  11. data/lib/rtunnel/commands.rb +233 -0
  12. data/lib/rtunnel/connection_id.rb +24 -0
  13. data/lib/rtunnel/core.rb +58 -0
  14. data/lib/rtunnel/crypto.rb +106 -0
  15. data/lib/rtunnel/frame_protocol.rb +34 -0
  16. data/lib/rtunnel/io_extensions.rb +54 -0
  17. data/lib/rtunnel/leak.rb +35 -0
  18. data/lib/rtunnel/rtunnel_client_cmd.rb +41 -0
  19. data/lib/rtunnel/rtunnel_server_cmd.rb +32 -0
  20. data/lib/rtunnel/server.rb +351 -0
  21. data/lib/rtunnel/socket_factory.rb +119 -0
  22. data/lib/rtunnel.rb +20 -0
  23. data/rtunnel.gemspec +51 -0
  24. data/spec/client_spec.rb +47 -0
  25. data/spec/cmds_spec.rb +127 -0
  26. data/spec/integration_spec.rb +105 -0
  27. data/spec/server_spec.rb +21 -0
  28. data/spec/spec_helper.rb +3 -0
  29. data/test/command_stubs.rb +77 -0
  30. data/test/protocol_mocks.rb +43 -0
  31. data/test/scenario_connection.rb +109 -0
  32. data/test/test_client.rb +48 -0
  33. data/test/test_command_protocol.rb +82 -0
  34. data/test/test_commands.rb +49 -0
  35. data/test/test_connection_id.rb +30 -0
  36. data/test/test_crypto.rb +127 -0
  37. data/test/test_frame_protocol.rb +109 -0
  38. data/test/test_io_extensions.rb +70 -0
  39. data/test/test_server.rb +70 -0
  40. data/test/test_socket_factory.rb +42 -0
  41. data/test/test_tunnel.rb +186 -0
  42. data/test_data/authorized_keys2 +4 -0
  43. data/test_data/known_hosts +4 -0
  44. data/test_data/random_rsa_key +27 -0
  45. data/test_data/ssh_host_dsa_key +12 -0
  46. data/test_data/ssh_host_rsa_key +27 -0
  47. data/tests/_ab_test.rb +16 -0
  48. data/tests/_stress_test.rb +96 -0
  49. data/tests/lo_http_server.rb +55 -0
  50. metadata +127 -31
  51. data/History.txt +0 -3
  52. data/Manifest.txt +0 -13
  53. data/README.txt +0 -362
  54. data/lib/client.rb +0 -185
  55. data/lib/cmds.rb +0 -166
  56. data/lib/core.rb +0 -53
  57. data/lib/rtunnel_client_cmd.rb +0 -25
  58. data/lib/rtunnel_server_cmd.rb +0 -20
  59. data/lib/server.rb +0 -181
  60. data/rtunnel_client.rb +0 -3
  61. data/rtunnel_server.rb +0 -3
@@ -0,0 +1,27 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEoQIBAAKCAQEAq7VciLo2wB+/2ThHXejC/kgkN205zlyS5cvN40Mqi3qvRVS7
3
+ 5X1RawDoLot8eJ9KCYqZFr2Dr73d/EQNltN7dKJoPIj1IKxoraWkyNFbhhzpYuOl
4
+ tg9oO5UBSTNLupqla7zcdj4IwCCkBYk4+TS0dwmi20buOJ0FPY5PgbzmMnUiV9ip
5
+ BqeJSdZB+TePH1gqlt7AP/6ti/0gxb2K7F69dZl/BSxMEzRCfBlTFC3f/4n8IdCu
6
+ SJvNxxY+TtRnLL5CKUhj9QaIBan6JCkdRvVOBY7wmsNT8nGDzfDFSDD3KKn93g4L
7
+ RkyMeaYlSDLxKy8PnNhjWgBNH1YNYyicsGfBKQIBIwKCAQA/xwUc13Nr7okWKtit
8
+ 2hyKVU9HyXve7y8/aPSzf1jx+l5blIBN7LfXSXrPdaNCvtJbULyEygxXN+S8yNHY
9
+ 73b/b4XNV3D9gd281x/y0WsjL09fPpyitUP435LDatL8Ks+6TXZ1D7obedaFtqAi
10
+ DEMHpH5Rch33xUsW3RY3g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hgvttFhX162oC
26
+ bRizr31NgiGtgJbHJ9QPhaLvn3mZtZAFfRaEEdZslUzqRSACww==
27
+ -----END RSA PRIVATE KEY-----
data/tests/_ab_test.rb ADDED
@@ -0,0 +1,16 @@
1
+ base_dir = File.dirname(__FILE__)
2
+ lo_server_file = File.join(base_dir, '../tests/lo_http_server.rb')
3
+ lo_port = 4000
4
+ Kernel.system "ruby #{lo_server_file} start #{lo_port}"
5
+
6
+ fork{ exec "ruby #{base_dir}/../lib/rtunnel/rtunnel_server.rb > /dev/null 2>&1" }
7
+ fork{ exec "ruby #{base_dir}/../lib/rtunnel/rtunnel_client.rb -c localhost -f 5000 -t 4000 > /dev/null" }
8
+
9
+ sleep 2
10
+
11
+ (puts "you need ab (apache bench) to run this stress test" ; exit) if %x{which ab}.empty?
12
+
13
+ Process.wait fork { exec("ab -c 500 -n 10000 http://localhost:5000/") }
14
+
15
+ puts "done, hit ^C"
16
+ sleep 999999
@@ -0,0 +1,96 @@
1
+ require 'rubygems'
2
+ require 'eventmachine'
3
+ require 'logger'
4
+ require 'stringio'
5
+
6
+ CONCURRENT_CONNECTIONS = 50
7
+ DISPLAY_RTUNNEL_OUTPUT = true
8
+ TUNNEL_PORT = 5000
9
+ HTTP_PORT = 4444
10
+
11
+ #################
12
+
13
+ TUNNEL_URI = "http://localhost:#{TUNNEL_PORT}"
14
+ srand(0) # deterministic random data
15
+ EXPECTED_DATA = Array.new(16*1024) { rand(?z).chr }*''
16
+
17
+ $pids = [$$]
18
+
19
+ def cleanup
20
+ puts $!, $@ if $!
21
+
22
+ # move the current process to the end of the kill list
23
+ $pids << $pids.delete($$)
24
+ $pids.each {|pid| Process.kill 9, pid rescue nil }
25
+
26
+ exit!
27
+ end
28
+
29
+ at_exit { cleanup }
30
+
31
+ ENV['RTUNNEL_DEBUG'] = '1' if DISPLAY_RTUNNEL_OUTPUT
32
+
33
+ base_dir = File.join(File.dirname(__FILE__), '..', 'bin')
34
+ $pids << fork{ exec "ruby", "-Ilib", "#{base_dir}/rtunnel_server" }
35
+ $pids << fork{ exec "ruby", "-Ilib", "#{base_dir}/rtunnel_client", '-c', '127.0.0.1', '-f', TUNNEL_PORT.to_s, '-t', "127.0.0.1:#{HTTP_PORT}" }
36
+
37
+ $pids << fork do
38
+ require 'thin'
39
+
40
+ app = lambda do |env|
41
+ body = env['rack.input'].string
42
+ if body != EXPECTED_DATA
43
+ p body, EXPECTED_DATA
44
+ puts "server received BAD DATA!"
45
+
46
+ cleanup
47
+ end
48
+
49
+ [200, {}, EXPECTED_DATA]
50
+ end
51
+
52
+ Thin::Server.new('localhost', HTTP_PORT, app).start
53
+ end
54
+
55
+ puts 'wait 2 secs...'
56
+ sleep 2
57
+
58
+ module Stresser
59
+ @@open_connections = 0
60
+
61
+ def post_init
62
+ @@open_connections += 1
63
+ send_data "POST / HTTP/1.0\r\nContent-Length: #{EXPECTED_DATA.size}\r\n\r\n#{EXPECTED_DATA}"
64
+ @data = ''
65
+ print '('; $stdout.flush
66
+ end
67
+
68
+ def receive_data(data)
69
+ @data << data
70
+ print '.'; $stdout.flush
71
+ end
72
+
73
+ def unbind
74
+ if @data.gsub(/\A.+\r\n\r\n/m,'') != EXPECTED_DATA
75
+ p EXPECTED_DATA, @data
76
+ puts "client received BAD DATA!"
77
+
78
+ cleanup
79
+ end
80
+
81
+ print ')'; $stdout.flush
82
+
83
+ @@open_connections -= 1
84
+ EventMachine.stop_event_loop if @@open_connections == 0
85
+ end
86
+ end
87
+
88
+ loop do
89
+ EventMachine.run do
90
+ CONCURRENT_CONNECTIONS.times do
91
+ EventMachine.connect 'localhost', TUNNEL_PORT, Stresser
92
+ end
93
+ end
94
+
95
+ puts
96
+ end
@@ -0,0 +1,55 @@
1
+ require 'net/http'
2
+ require 'socket'
3
+ require 'time'
4
+
5
+ require 'rubygems'
6
+ require 'simple-daemon'
7
+
8
+ class LoHttpServer < SimpleDaemon::Base
9
+ def send_headers(socket, status, length = 0, mime_type = 'text/html', headers = {})
10
+ reason = headers[:reason] || {200 => 'OK', 404 => 'File not found'}[status]
11
+
12
+ response_line = "HTTP/1.1 #{status} #{reason}\r\n"
13
+
14
+ response_headers = { 'Connection' => 'close', 'Server' => 'Rubylicious/1.0', 'Date' => Time.now.rfc2822,
15
+ 'Content-Type' => mime_type, 'Content-Length' => length }.merge headers
16
+
17
+ socket.write response_line
18
+ socket.write response_headers.to_a.map { |k,v| k.to_s + ': ' + v.to_s }.join("\r\n") + "\r\n\r\n"
19
+ end
20
+
21
+ def send_html(socket, html_data = "Loopback page\n")
22
+ send_headers(socket, 200, html_data.length)
23
+ socket.write html_data
24
+ socket.close
25
+ end
26
+
27
+ def run(listen_port)
28
+ listen_socket = TCPServer.new listen_port
29
+
30
+ loop do
31
+ client_socket = listen_socket.accept
32
+ Thread.new do
33
+ begin
34
+ print client_socket.readpartial(16384), "\n"
35
+ send_html client_socket
36
+ rescue
37
+ print "#{$!.class.name}: #{$!}\n"
38
+ print $!.backtrace.join("\n"), "\n"
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ SimpleDaemon::WORKING_DIRECTORY = File.dirname(__FILE__)
45
+
46
+ def self.start
47
+ port = ARGV[1] || 3000
48
+ self.new.run(port)
49
+ end
50
+
51
+ def self.stop
52
+ end
53
+ end
54
+
55
+ LoHttpServer.daemonize
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtunnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - coderrr
@@ -9,40 +9,70 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-16 00:00:00 +07:00
12
+ date: 2009-01-26 00:00:00 +07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: uuidtools
16
+ name: eventmachine
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.0.2
23
+ version: 0.12.2
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
- name: facets
26
+ name: net-ssh
27
27
  type: :runtime
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.1.2
33
+ version: 2.0.4
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
- name: hoe
37
- type: :runtime
36
+ name: echoe
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
38
58
  version_requirement:
39
59
  version_requirements: !ruby/object:Gem::Requirement
40
60
  requirements:
41
61
  - - ">="
42
62
  - !ruby/object:Gem::Version
43
- version: 1.5.3
63
+ version: 0.1.2
44
64
  version:
45
- description: "OkExtensions by steved http://code.google.com/p/rtunnel == DESCRIPTION: http://code.google.com/p/rtunnel"
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.
46
76
  email: coderrr.contact@gmail.com
47
77
  executables:
48
78
  - rtunnel_client
@@ -50,29 +80,86 @@ executables:
50
80
  extensions: []
51
81
 
52
82
  extra_rdoc_files:
53
- - History.txt
54
- - Manifest.txt
55
- - README.txt
83
+ - CHANGELOG
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
56
103
  files:
57
- - History.txt
58
- - Manifest.txt
59
- - README.txt
60
- - rtunnel_client.rb
61
- - rtunnel_server.rb
104
+ - CHANGELOG
105
+ - LICENSE
106
+ - Manifest
107
+ - README.markdown
108
+ - Rakefile
62
109
  - bin/rtunnel_client
63
110
  - bin/rtunnel_server
64
- - lib/rtunnel_client_cmd.rb
65
- - lib/rtunnel_server_cmd.rb
66
- - lib/client.rb
67
- - lib/core.rb
68
- - lib/server.rb
69
- - lib/cmds.rb
111
+ - lib/rtunnel.rb
112
+ - lib/rtunnel/client.rb
113
+ - lib/rtunnel/command_protocol.rb
114
+ - lib/rtunnel/commands.rb
115
+ - lib/rtunnel/core.rb
116
+ - lib/rtunnel/crypto.rb
117
+ - lib/rtunnel/frame_protocol.rb
118
+ - lib/rtunnel/io_extensions.rb
119
+ - lib/rtunnel/leak.rb
120
+ - lib/rtunnel/rtunnel_client_cmd.rb
121
+ - lib/rtunnel/rtunnel_server_cmd.rb
122
+ - lib/rtunnel/server.rb
123
+ - lib/rtunnel/socket_factory.rb
124
+ - lib/rtunnel/connection_id.rb
125
+ - lib/rtunnel/command_processor.rb
126
+ - spec/client_spec.rb
127
+ - spec/cmds_spec.rb
128
+ - spec/integration_spec.rb
129
+ - spec/server_spec.rb
130
+ - spec/spec_helper.rb
131
+ - test/command_stubs.rb
132
+ - test/protocol_mocks.rb
133
+ - test/scenario_connection.rb
134
+ - test/test_client.rb
135
+ - test/test_command_protocol.rb
136
+ - test/test_commands.rb
137
+ - test/test_crypto.rb
138
+ - test/test_frame_protocol.rb
139
+ - test/test_io_extensions.rb
140
+ - test/test_server.rb
141
+ - test/test_socket_factory.rb
142
+ - test/test_tunnel.rb
143
+ - test/test_connection_id.rb
144
+ - test_data/known_hosts
145
+ - test_data/ssh_host_rsa_key
146
+ - test_data/random_rsa_key
147
+ - test_data/ssh_host_dsa_key
148
+ - test_data/authorized_keys2
149
+ - tests/_ab_test.rb
150
+ - tests/_stress_test.rb
151
+ - tests/lo_http_server.rb
152
+ - rtunnel.gemspec
70
153
  has_rdoc: true
71
- homepage: http://code.google.com/p/rtunnel
154
+ homepage: http://github.com/coderrr/rtunnel
72
155
  post_install_message:
73
156
  rdoc_options:
157
+ - --line-numbers
158
+ - --inline-source
159
+ - --title
160
+ - Rtunnel
74
161
  - --main
75
- - README.txt
162
+ - README.markdown
76
163
  require_paths:
77
164
  - lib
78
165
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -85,14 +172,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
172
  requirements:
86
173
  - - ">="
87
174
  - !ruby/object:Gem::Version
88
- version: "0"
175
+ version: "1.2"
89
176
  version:
90
177
  requirements: []
91
178
 
92
179
  rubyforge_project: coderrr
93
- rubygems_version: 1.2.0
180
+ rubygems_version: 1.3.1
94
181
  signing_key:
95
182
  specification_version: 2
96
- summary: http://code.google.com/p/rtunnel
97
- test_files: []
98
-
183
+ summary: Reverse tunnel server and client.
184
+ test_files:
185
+ - test/test_commands.rb
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
data/History.txt DELETED
@@ -1,3 +0,0 @@
1
- == 0.2.1
2
-
3
- * New version
data/Manifest.txt DELETED
@@ -1,13 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- rtunnel_client.rb
5
- rtunnel_server.rb
6
- bin/rtunnel_client
7
- bin/rtunnel_server
8
- lib/rtunnel_client_cmd.rb
9
- lib/rtunnel_server_cmd.rb
10
- lib/client.rb
11
- lib/core.rb
12
- lib/server.rb
13
- lib/cmds.rb