Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for connection by hostname

  • Loading branch information...
commit 382f259ccfd393b6779d55d9cab7a21610611ebe 1 parent 18eee6e
@meh meh 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('CA4n')
rescue
- fail("could not resolve host")
+ send_data [3, @host.size, @host].pack('CCA4n')
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.