socksify 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/socksify.rb +38 -5
  2. data/lib/socksify/debug.rb +23 -23
  3. metadata +23 -39
@@ -111,6 +111,18 @@ class TCPSocket
111
111
  def self.socks_port=(port)
112
112
  @@socks_port = port
113
113
  end
114
+ def self.socks_username
115
+ @@socks_username ||= nil
116
+ end
117
+ def self.socks_username=(username)
118
+ @@socks_username = username
119
+ end
120
+ def self.socks_password
121
+ @@socks_password ||= nil
122
+ end
123
+ def self.socks_password=(password)
124
+ @@socks_password = password
125
+ end
114
126
  def self.socks_ignores
115
127
  @@socks_ignores ||= %w(localhost)
116
128
  end
@@ -161,18 +173,39 @@ class TCPSocket
161
173
  Socksify::debug_debug "Connected to #{host}:#{port}"
162
174
  end
163
175
  end
164
-
176
+
165
177
  # Authentication
166
178
  def socks_authenticate
167
- Socksify::debug_debug "Sending no authentication"
168
- write "\005\001\000"
179
+ if self.class.socks_username || self.class.socks_password
180
+ Socksify::debug_debug "Sending username/password authentication"
181
+ write "\005\001\001\002"
182
+ else
183
+ Socksify::debug_debug "Sending no authentication"
184
+ write "\005\001\000"
185
+ end
169
186
  Socksify::debug_debug "Waiting for authentication reply"
170
187
  auth_reply = recv(2)
171
188
  if auth_reply[0..0] != "\004" and auth_reply[0..0] != "\005"
172
189
  raise SOCKSError.new("SOCKS version #{auth_reply[0..0]} not supported")
173
190
  end
174
- if auth_reply[1..1] != "\000"
175
- raise SOCKSError.new("SOCKS authentication method #{auth_reply[1..1]} neither requested nor supported")
191
+ if self.class.socks_username || self.class.socks_password
192
+ if auth_reply[1..1] != "\002"
193
+ raise SOCKSError.new("SOCKS authentication method #{auth_reply[1..1]} neither requested nor supported")
194
+ end
195
+ auth = "\001"
196
+ auth += self.class.socks_username.to_s.length.chr
197
+ auth += self.class.socks_username.to_s
198
+ auth += self.class.socks_password.to_s.length.chr
199
+ auth += self.class.socks_password.to_s
200
+ write auth
201
+ auth_reply = recv(2)
202
+ if auth_reply[1..1] != "\000"
203
+ raise SOCKSError.new("SOCKS authentication failed")
204
+ end
205
+ else
206
+ if auth_reply[1..1] != "\000"
207
+ raise SOCKSError.new("SOCKS authentication method #{auth_reply[1..1]} neither requested nor supported")
208
+ end
176
209
  end
177
210
  end
178
211
 
@@ -1,30 +1,30 @@
1
- class Color
2
- class Reset
1
+ module Socksify
2
+ class Color
3
+ class Reset
4
+ def self::to_s
5
+ "\e[0m\e[37m"
6
+ end
7
+ end
8
+
9
+ class Red < Color
10
+ def num; 31; end
11
+ end
12
+ class Green < Color
13
+ def num; 32; end
14
+ end
15
+ class Yellow < Color
16
+ def num; 33; end
17
+ end
18
+
3
19
  def self::to_s
4
- "\e[0m\e[37m"
20
+ new.to_s
21
+ end
22
+
23
+ def to_s
24
+ "\e[1m\e[#{num}m"
5
25
  end
6
26
  end
7
27
 
8
- class Red < Color
9
- def num; 31; end
10
- end
11
- class Green < Color
12
- def num; 32; end
13
- end
14
- class Yellow < Color
15
- def num; 33; end
16
- end
17
-
18
- def self::to_s
19
- new.to_s
20
- end
21
-
22
- def to_s
23
- "\e[1m\e[#{num}m"
24
- end
25
- end
26
-
27
- module Socksify
28
28
  def self.debug=(enabled)
29
29
  @@debug = enabled
30
30
  end
metadata CHANGED
@@ -1,77 +1,61 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: socksify
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 4
8
- - 1
9
- version: 1.4.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Stephan Maka
13
9
  - Andrey Kouznetsov
14
10
  - Christopher Thorpe
15
11
  - Musy Bite
16
12
  - Yuichi Tateno
13
+ - David Dollar
17
14
  autorequire:
18
15
  bindir: bin
19
16
  cert_chain: []
20
-
21
- date: 2011-06-07 00:00:00 +02:00
22
- default_executable:
17
+ date: 2012-06-22 00:00:00.000000000 Z
23
18
  dependencies: []
24
-
25
19
  description:
26
20
  email: stephan@spaceboyz.net
27
- executables:
21
+ executables:
28
22
  - socksify_ruby
29
23
  extensions: []
30
-
31
- extra_rdoc_files:
24
+ extra_rdoc_files:
32
25
  - doc/index.css
33
26
  - doc/index.html
34
27
  - COPYING
35
- files:
28
+ files:
36
29
  - COPYING
37
- - lib/socksify.rb.orig
38
30
  - lib/socksify/debug.rb
39
31
  - lib/socksify/http.rb
40
32
  - lib/socksify.rb
33
+ - lib/socksify.rb.orig
41
34
  - bin/socksify_ruby
42
35
  - doc/index.css
43
36
  - doc/index.html
44
- has_rdoc: true
45
37
  homepage: http://socksify.rubyforge.org/
46
38
  licenses: []
47
-
48
39
  post_install_message:
49
40
  rdoc_options: []
50
-
51
- require_paths:
41
+ require_paths:
52
42
  - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
43
+ required_ruby_version: !ruby/object:Gem::Requirement
54
44
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- segments:
59
- - 0
60
- version: "0"
61
- required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
50
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- segments:
67
- - 0
68
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
69
55
  requirements: []
70
-
71
56
  rubyforge_project: socksify
72
- rubygems_version: 1.3.7
57
+ rubygems_version: 1.8.23
73
58
  signing_key:
74
59
  specification_version: 3
75
60
  summary: Redirect all TCPSockets through a SOCKS5 proxy
76
61
  test_files: []
77
-