pagoda-tunnel 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/pagoda-tunnel.rb +12 -9
  2. metadata +18 -7
data/lib/pagoda-tunnel.rb CHANGED
@@ -4,7 +4,7 @@ require 'openssl'
4
4
 
5
5
  module Pagoda
6
6
  class Tunnel
7
- VERSION = "0.1.2"
7
+ VERSION = "0.1.3"
8
8
  # Your code goes here...
9
9
 
10
10
  def initialize(type, user, pass, app, instance, port = 3306)
@@ -61,7 +61,7 @@ module Pagoda
61
61
 
62
62
  # If we are running on windows checking available ports does not work
63
63
  # thus we must just attempt a few times and fail if we cant we start at a high number and pray it works :)
64
-
64
+
65
65
  if RUBY_PLATFORM =~ /mswin32|mingw32/ # running on windows
66
66
  @port = 45000
67
67
  else
@@ -73,7 +73,7 @@ module Pagoda
73
73
  proxy_server = TCPServer.new('0.0.0.0', @port)
74
74
  rescue Exception => e
75
75
  @port += 1
76
- retry if retrys < 4
76
+ retry if retrys += 1 < 4
77
77
  # puts "unable to connect to #{@port}. The algorithm is broken"
78
78
  exit
79
79
  end
@@ -90,6 +90,7 @@ module Pagoda
90
90
  puts "-----------------------------------------------"
91
91
  puts "(note : ctrl-c To close this tunnel)"
92
92
 
93
+ # puts "what th heck"
93
94
  loop do
94
95
 
95
96
  # puts "start a new thread for every client connection"
@@ -103,23 +104,25 @@ module Pagoda
103
104
  ssl_socket.sync_close = true
104
105
  ssl_socket.connect
105
106
  rescue Errno::ECONNREFUSED
106
- # puts "connection refused"
107
+ puts "connection refused"
107
108
  client_socket.close
108
109
  raise
109
110
  end
110
111
 
111
- # puts "authenticate"
112
- if ssl_socket.readpartial(chunk) == "auth"
112
+
113
+ if ssl_socket.read(4) == 'auth'
113
114
  # puts "authentication"
114
115
  # puts "auth=#{@type}:#{@user}:#{@pass}:#{@app}:#{@instance}"
115
116
  ssl_socket.write "auth=#{@type}:#{@user}:#{@pass}:#{@app}:#{@instance}"
116
- if ssl_socket.readpartial(chunk) == "success"
117
+ if ssl_socket.read(7) == "success"
117
118
  # puts "successful connection"
118
119
  else
119
- # puts "failed connection"
120
+ puts "Authentication Failed!"
121
+ exit 1
120
122
  end
121
123
  else
122
- # puts "danger will robbinson! abort!"
124
+ puts "Failed connection."
125
+ exit 1
123
126
  end
124
127
 
125
128
  loop do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagoda-tunnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-14 00:00:00.000000000Z
12
+ date: 2012-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2154226360 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2154226360
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rest-client
27
- requirement: &2154225040 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *2154225040
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: Pagodabox container tunnel. Allows users to tunnel into pagodabox db's.
37
47
  email:
38
48
  - lyon@delorum.com
@@ -66,9 +76,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
76
  version: '0'
67
77
  requirements: []
68
78
  rubyforge_project: pagoda-tunnel
69
- rubygems_version: 1.8.10
79
+ rubygems_version: 1.8.20
70
80
  signing_key:
71
81
  specification_version: 3
72
82
  summary: Pagodabox Tunnel gem
73
83
  test_files:
74
84
  - spec/tunnel_spec.rb
85
+ has_rdoc: