coderrr-rtunnel 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/client.rb +2 -8
- data/lib/core.rb +10 -5
- data/lib/rtunnel_client_cmd.rb +1 -3
- data/lib/rtunnel_server_cmd.rb +1 -3
- data/lib/server.rb +3 -5
- data/rtunnel.gemspec +1 -1
- data/stress_test.rb +16 -22
- metadata +1 -1
data/lib/client.rb
CHANGED
@@ -1,15 +1,9 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
require 'gserver'
|
4
|
-
require 'optparse'
|
5
|
-
require 'timeout'
|
6
|
-
require 'resolv'
|
7
|
-
|
8
1
|
require 'core'
|
9
2
|
require 'cmds'
|
10
3
|
require 'leak'
|
11
4
|
|
12
|
-
|
5
|
+
require 'gserver'
|
6
|
+
require 'timeout'
|
13
7
|
|
14
8
|
module RTunnel
|
15
9
|
class Client
|
data/lib/core.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
|
+
require 'resolv'
|
2
|
+
|
1
3
|
module RTunnel
|
2
|
-
VERSION = '0.3.
|
4
|
+
VERSION = '0.3.9'
|
3
5
|
|
4
6
|
DEFAULT_CONTROL_PORT = 19050
|
5
7
|
PING_TIMEOUT = 10
|
6
8
|
end
|
7
9
|
|
8
|
-
|
9
|
-
def D(msg)
|
10
|
-
|
10
|
+
if ENV['RTUNNEL_DEBUG']
|
11
|
+
def D(msg)
|
12
|
+
puts msg
|
13
|
+
end
|
14
|
+
else
|
15
|
+
def D(*a);end
|
11
16
|
end
|
12
17
|
|
13
18
|
class << Thread
|
@@ -32,7 +37,7 @@ class String
|
|
32
37
|
self.replace(self.gsub(host, ip))
|
33
38
|
rescue Exception
|
34
39
|
puts "Error resolving #{host}"
|
35
|
-
|
40
|
+
raise
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
data/lib/rtunnel_client_cmd.rb
CHANGED
data/lib/rtunnel_server_cmd.rb
CHANGED
data/lib/server.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
|
3
|
-
require 'gserver'
|
4
|
-
require 'optparse'
|
2
|
+
gem 'uuidtools', '>=1.0.2'
|
5
3
|
require 'uuidtools'
|
6
4
|
|
7
5
|
require 'core'
|
8
6
|
require 'cmds'
|
9
7
|
|
10
|
-
|
8
|
+
require 'gserver'
|
11
9
|
|
12
|
-
|
10
|
+
Socket.do_not_reverse_lookup = true
|
13
11
|
|
14
12
|
module RTunnel
|
15
13
|
# listens for incoming connections to tunnel
|
data/rtunnel.gemspec
CHANGED
data/stress_test.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'thin'
|
3
|
+
|
4
|
+
require 'lib/core'
|
2
5
|
|
3
|
-
require 'mongrel'
|
4
|
-
require 'facets'
|
5
|
-
require 'facets/random'
|
6
6
|
require 'logger'
|
7
7
|
require 'stringio'
|
8
8
|
|
9
|
-
|
9
|
+
|
10
|
+
CONCURRENT_CONNECTIONS = 25
|
11
|
+
DISPLAY_RTUNNEL_OUTPUT = false
|
12
|
+
TUNNEL_PORT = 5000
|
13
|
+
HTTP_PORT = 4444
|
14
|
+
|
15
|
+
#################
|
10
16
|
|
11
17
|
pids = []
|
12
18
|
at_exit do
|
@@ -26,35 +32,23 @@ module Enumerable
|
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
29
|
-
CONCURRENT_CONNECTIONS = 25
|
30
|
-
|
31
|
-
TUNNEL_PORT = 5000
|
32
|
-
HTTP_PORT = 4444
|
33
35
|
TUNNEL_URI = "http://localhost:#{TUNNEL_PORT}"
|
34
|
-
EXPECTED_DATA =
|
35
|
-
|
36
|
-
puts EXPECTED_DATA.inspect
|
37
|
-
|
38
|
-
p :gend_random_data
|
36
|
+
EXPECTED_DATA = (0..10*1024).map{0until(c=rand(?z).chr)=~/(?!_)\w/;c}*'' # gen random string GOLF FTW!
|
37
|
+
puts EXPECTED_DATA
|
39
38
|
|
40
|
-
require 'thin'
|
41
39
|
app = lambda { |env| [200, {}, EXPECTED_DATA] }
|
42
40
|
server = ::Thin::Server.new('localhost', HTTP_PORT, app)
|
43
41
|
Thread.new { server.start }
|
44
42
|
|
45
|
-
p :started_stressed_server
|
46
|
-
|
47
43
|
base_dir = File.dirname(__FILE__)
|
48
44
|
|
49
|
-
|
50
|
-
pids << fork{ exec "ruby #{base_dir}/
|
51
|
-
|
52
|
-
p :started_rtunnels
|
45
|
+
d = !DISPLAY_RTUNNEL_OUTPUT
|
46
|
+
pids << fork{ exec "ruby #{base_dir}/rtunnel_server.rb #{d && '> /dev/null'} 2>&1" }
|
47
|
+
pids << fork{ exec "ruby #{base_dir}/rtunnel_client.rb -c localhost -f #{TUNNEL_PORT} -t #{HTTP_PORT} #{d &&' > /dev/null'} 2>&1" }
|
53
48
|
|
49
|
+
puts 'wait 2 secs'
|
54
50
|
sleep 2
|
55
51
|
|
56
|
-
p :slept
|
57
|
-
|
58
52
|
STDOUT.sync = true
|
59
53
|
999999999.times do |i|
|
60
54
|
puts i if i%10 == 0
|