Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2 from meh/master

Add support for connection by unresolvable hostname (Tor support)
  • Loading branch information...
commit b6b387bab731a435b6f3ef542838bcbf5a679ee0 2 parents 18eee6e + e6d0aa8
@igrigorik authored
Showing with 9 additions and 6 deletions.
  1. +9 −6 lib/em-socksify/socksify.rb
View
15 lib/em-socksify/socksify.rb
@@ -31,14 +31,17 @@ def send_socks_handshake
end
def send_socks_connect_request
- begin
- # TO-DO: Implement address types for IPv6 and Domain
- ip_address = Socket.gethostbyname(@host).last
- send_data [5, 1, 0, 1, ip_address, @port].flatten.pack('CCCCA4n')
+ send_data [5, 1, 0].pack('CCC')
+ begin
+ # TODO: Implement address types for IPv6 and Domain
+ # TODO: resolve domain through the proxy
+ send_data [1, Socket.gethostbyname(@host).last].pack('CA4')
rescue
- fail("could not resolve host")
+ send_data [3, @host.size, @host].pack('CCA*')
end
+
+ send_data [@port].pack('n')
end
private
@@ -119,4 +122,4 @@ def socks_methods
end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.