socksify 1.7.0 → 1.7.1

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/socksify.rb +22 -18
  3. metadata +7 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de7d71ec280f514fb083bd26f34b76ce14a2c82d
4
- data.tar.gz: 10454a02092c6e14884441f90997b17ed92ee27a
3
+ metadata.gz: 24bd364bbfc92b361cbd76623e0394476141f9f8
4
+ data.tar.gz: 72d2a6761ee659f0b96773048c6f1834d205e7a9
5
5
  SHA512:
6
- metadata.gz: 9bb3836afe02eadd52465295fe8428e3e9424a139271abf08951722a3195bf56b0093611c80a557e1d836faf0a498f3795953caf63e9a32ec0175562e9dc4b6c
7
- data.tar.gz: 00deeb904f05fe9be737fbae6b2633ecc234b81c9841c4fd99718076b0b657b3d24399b5e890ff884e7e5899644191b7272a0f59b22e59beb6324230fa109210
6
+ metadata.gz: 9b9cf647a3dacbf545aad7e89779b34098b624614548572aee91210ca3387320b1b549db82ecebf84d236679a631f6bf87b7ad37883de3ad132427ebc50a98ea
7
+ data.tar.gz: 4011606be7484d050d32b37825f3fe5c340557b50c5be0eb3f25588d89ecbe22bc82b7e13833030f860d70e5a20ef7079219e296c24836b117ca4672b02444ca
@@ -221,40 +221,42 @@ class TCPSocket
221
221
  # Connect
222
222
  def socks_connect(host, port)
223
223
  port = Socket.getservbyname(port) if port.is_a?(String)
224
+ req = String.new
224
225
  Socksify::debug_debug "Sending destination address"
225
- write TCPSocket.socks_version
226
+ req << TCPSocket.socks_version
226
227
  Socksify::debug_debug TCPSocket.socks_version.unpack "H*"
227
- write "\001"
228
- write "\000" if @@socks_version == "5"
229
- write [port].pack('n') if @@socks_version =~ /^4/
228
+ req << "\001"
229
+ req << "\000" if @@socks_version == "5"
230
+ req << [port].pack('n') if @@socks_version =~ /^4/
230
231
 
231
232
  if @@socks_version == "4"
232
233
  host = Resolv::DNS.new.getaddress(host).to_s
233
234
  end
234
235
  Socksify::debug_debug host
235
236
  if host =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ # to IPv4 address
236
- write "\001" if @@socks_version == "5"
237
+ req << "\001" if @@socks_version == "5"
237
238
  _ip = [$1.to_i,
238
239
  $2.to_i,
239
240
  $3.to_i,
240
241
  $4.to_i
241
242
  ].pack('CCCC')
242
- write _ip
243
+ req << _ip
243
244
  elsif host =~ /^[:0-9a-f]+$/ # to IPv6 address
244
245
  raise "TCP/IPv6 over SOCKS is not yet supported (inet_pton missing in Ruby & not supported by Tor"
245
- write "\004"
246
+ req << "\004"
246
247
  else # to hostname
247
248
  if @@socks_version == "5"
248
- write "\003" + [host.size].pack('C') + host
249
+ req << "\003" + [host.size].pack('C') + host
249
250
  else
250
- write "\000\000\000\001"
251
- write "\007\000"
251
+ req << "\000\000\000\001"
252
+ req << "\007\000"
252
253
  Socksify::debug_notice host
253
- write host
254
- write "\000"
254
+ req << host
255
+ req << "\000"
255
256
  end
256
257
  end
257
- write [port].pack('n') if @@socks_version == "5"
258
+ req << [port].pack('n') if @@socks_version == "5"
259
+ write req
258
260
 
259
261
  socks_receive_reply
260
262
  Socksify::debug_notice "Connected to #{host}:#{port} over SOCKS"
@@ -321,21 +323,23 @@ module Socksify
321
323
  s = TCPSocket.new
322
324
 
323
325
  begin
326
+ req = String.new
324
327
  Socksify::debug_debug "Sending hostname to resolve: #{host}"
325
- s.write "\005"
328
+ req << "\005"
326
329
  if host =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ # to IPv4 address
327
- s.write "\xF1\000\001" + [$1.to_i,
330
+ req << "\xF1\000\001" + [$1.to_i,
328
331
  $2.to_i,
329
332
  $3.to_i,
330
333
  $4.to_i
331
334
  ].pack('CCCC')
332
335
  elsif host =~ /^[:0-9a-f]+$/ # to IPv6 address
333
336
  raise "TCP/IPv6 over SOCKS is not yet supported (inet_pton missing in Ruby & not supported by Tor"
334
- s.write "\004"
337
+ req << "\004"
335
338
  else # to hostname
336
- s.write "\xF0\000\003" + [host.size].pack('C') + host
339
+ req << "\xF0\000\003" + [host.size].pack('C') + host
337
340
  end
338
- s.write [0].pack('n') # Port
341
+ req << [0].pack('n') # Port
342
+ s.write req
339
343
 
340
344
  addr, _port = s.socks_receive_reply
341
345
  Socksify::debug_notice "Resolved #{host} as #{addr} over SOCKS"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socksify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephan Maka
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2015-07-31 00:00:00.000000000 Z
16
+ date: 2017-02-24 00:00:00.000000000 Z
17
17
  dependencies: []
18
18
  description:
19
19
  email: stephan@spaceboyz.net
@@ -21,8 +21,8 @@ executables:
21
21
  - socksify_ruby
22
22
  extensions: []
23
23
  extra_rdoc_files:
24
- - doc/index.html
25
24
  - doc/index.css
25
+ - doc/index.html
26
26
  - COPYING
27
27
  files:
28
28
  - COPYING
@@ -33,7 +33,9 @@ files:
33
33
  - lib/socksify/debug.rb
34
34
  - lib/socksify/http.rb
35
35
  homepage: http://socksify.rubyforge.org/
36
- licenses: []
36
+ licenses:
37
+ - Ruby
38
+ - GPL-3.0
37
39
  metadata: {}
38
40
  post_install_message:
39
41
  rdoc_options: []
@@ -51,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
53
  version: '0'
52
54
  requirements: []
53
55
  rubyforge_project: socksify
54
- rubygems_version: 2.4.5
56
+ rubygems_version: 2.5.2
55
57
  signing_key:
56
58
  specification_version: 4
57
59
  summary: Redirect all TCPSockets through a SOCKS5 proxy