# File lib/proxifier/proxies/socks.rb, line 25 def authenticate(socket, method) case method when 0x00 # NO AUTHENTICATION REQUIRED when 0x02 # USERNAME/PASSWORD user &&= user[0, 0xFF] password &&= password[0, 0xFF] socket << [user.size, user, password.size, password].pack("CA#{user.size}CA#{password.size}") version, status = socket.read(2).unpack("CC") check_version(version) case status when 0x00 # SUCCESS else raise "SOCKS5 username/password authentication failed" end else raise "no acceptable SOCKS5 authentication methods" end end