| 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 24
24: def initialize(socks_host, socks_port)
25: super(socks_host, socks_port)
26: end
Authenticate for SOCKS5 proxy
Currently supports only ‘no authentication required‘
# File lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb, line 32
32: def auth
33: write("\x05\x01\x00")
34: buf = read(2)
35: if buf.nil? or buf != "\x05\x00"
36: close
37: raise SOCKS5Error.new("Invalid SOCKS5 authentication: #{buf.inspect}")
38: end
39:
40: self
41: 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 48
48: def connect_domain(domain, port)
49: write("\x05\x01\x00\x03#{domain.size.chr}#{domain}#{[port].pack("n")}")
50: buf = read(7 + domain.size)
51: if buf.nil? or buf[0..1] != "\005\000"
52: close
53: raise SOCKS5Error.new("Invalid SOCKS5 connect: #{buf.inspect}")
54: end
55:
56: self
57: end