coderrr-rtunnel 0.3.8 → 0.3.9

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.
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
- $debug = true
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.8'
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
- puts msg if $debug
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
- exit
40
+ raise
36
41
  end
37
42
  end
38
43
 
@@ -1,11 +1,9 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  $LOAD_PATH << 'lib'
4
-
4
+ require 'optparse'
5
5
  require 'client'
6
6
 
7
- $debug = true
8
-
9
7
  control_address = tunnel_from_address = tunnel_to_address = remote_listen_address = nil
10
8
 
11
9
  (opts = OptionParser.new do |o|
@@ -1,11 +1,9 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  $LOAD_PATH << 'lib'
4
-
4
+ require 'optparse'
5
5
  require 'server'
6
6
 
7
- $debug = true
8
-
9
7
  control_address = tunnel_port = nil
10
8
 
11
9
  (opts = OptionParser.new do |o|
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
- Socket.do_not_reverse_lookup = true
8
+ require 'gserver'
11
9
 
12
- $debug = true
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rtunnel"
3
- s.version = "0.3.8"
3
+ s.version = "0.3.9"
4
4
  s.summary = "reverse tunnel server and client"
5
5
  s.email = "coderrr.contact@gmail.com"
6
6
  s.homepage = "http://github.com/coderrr/rtunnel"
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
- require 'lib/core'
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 = String.random(10*1024)
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
- pids << fork{ exec "ruby #{base_dir}/rtunnel_server.rb > /dev/null 2>&1" }
50
- pids << fork{ exec "ruby #{base_dir}/rtunnel_client.rb -c localhost -f #{TUNNEL_PORT} -t #{HTTP_PORT} > /dev/null 2>&1" }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coderrr-rtunnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - coderrr