Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/socksify/socksproxyable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def socks_authenticate
write "\005\001\000"
end
Socksify.debug_debug 'Waiting for authentication reply'
auth_reply = recv(2)
auth_reply = recv(2).to_s
raise SOCKSError, "Server doesn't reply authentication" if auth_reply.empty?

if auth_reply[0..0] != "\004" && auth_reply[0..0] != "\005"
Expand All @@ -53,7 +53,7 @@ def socks_authenticate
auth += self.class.socks_password.to_s.length.chr
auth += self.class.socks_password.to_s
write auth
auth_reply = recv(2)
auth_reply = recv(2).to_s
raise SOCKSError, 'SOCKS authentication failed' if auth_reply[1..1] != "\000"
elsif auth_reply[1..1] != "\000"
raise SOCKSError, "SOCKS authentication method #{auth_reply[1..1]} neither requested nor supported"
Expand Down Expand Up @@ -103,7 +103,7 @@ def socks_connect(host, port)
def socks_receive_reply
Socksify.debug_debug 'Waiting for SOCKS reply'
if self.class.socks_version == '5'
connect_reply = recv(4)
connect_reply = recv(4).to_s
raise SOCKSError, "Server doesn't reply" if connect_reply.empty?

Socksify.debug_debug connect_reply.unpack 'H*'
Expand All @@ -115,13 +115,13 @@ def socks_receive_reply
when "\001"
4
when "\003"
recv(1).bytes.first
recv(1).to_s.bytes.first
when "\004"
16
else
raise SOCKSError.for_response_code(connect_reply.bytes.to_a[3])
end
bind_addr_s = recv(bind_addr_len)
bind_addr_s = recv(bind_addr_len).to_s
bind_addr = case connect_reply[3..3]
when "\001"
bind_addr_s.bytes.to_a.join('.')
Expand All @@ -136,10 +136,10 @@ def socks_receive_reply
ip6 += b.to_s(16).rjust(2, '0')
end
end
bind_port = recv(bind_addr_len + 2)
bind_port = recv(bind_addr_len + 2).to_s
[bind_addr, bind_port.unpack('n')]
else
connect_reply = recv(8)
connect_reply = recv(8).to_s
unless connect_reply[0] == "\000" && connect_reply[1] == "\x5A"
Socksify.debug_debug connect_reply.unpack 'H'
raise SOCKSError, 'Failed while connecting througth socks'
Expand Down