| Class | Jabber::Bytestreams::SOCKS5Socket |
| In: |
lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb
|
| Parent: | TCPSocket |
A SOCKS5 client implementation
Connect to SOCKS5 proxy
# File lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb, line 20
20: def initialize(socks_host, socks_port)
21: super(socks_host, socks_port)
22: end
Authenticate for SOCKS5 proxy
Currently supports only ‘no authentication required‘
# File lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb, line 28
28: def auth
29: write("\x05\x01\x00")
30: buf = read(2)
31: if buf.nil? or buf != "\x05\x00"
32: close
33: raise SOCKS5Error.new("Invalid SOCKS5 authentication: #{buf.inspect}")
34: end
35:
36: self
37: end
Issue a CONNECT request to a host name which is to be resolved by the proxy.
| domain: | [String] Host name |
| port: | [Fixnum] Port number |
# File lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb, line 44
44: def connect_domain(domain, port)
45: write("\x05\x01\x00\x03#{domain.size.chr}#{domain}#{[port].pack("n")}")
46: buf = read(7 + domain.size)
47: if buf.nil? or buf[0..1] != "\005\000"
48: close
49: raise SOCKS5Error.new("Invalid SOCKS5 connect: #{buf.inspect}")
50: end
51:
52: self
53: end