@@ -185,31 +185,31 @@ def __negotiatesocks5(self, destaddr, destport):
185
185
# We'll receive the server's response to determine which
186
186
# method was selected
187
187
chosenauth = self .__recvall (2 )
188
- if chosenauth [0 :1 ] != chr ( 0x05 ). encode () :
188
+ if chosenauth [0 :1 ] != b' \x05 ' :
189
189
self .close ()
190
190
raise GeneralProxyError ((1 , _generalerrors [1 ]))
191
191
# Check the chosen authentication method
192
- if chosenauth [1 :2 ] == chr ( 0x00 ). encode () :
192
+ if chosenauth [1 :2 ] == b' \x00 ' :
193
193
# No authentication is required
194
194
pass
195
- elif chosenauth [1 :2 ] == chr ( 0x02 ). encode () :
195
+ elif chosenauth [1 :2 ] == b' \x02 ' :
196
196
# Okay, we need to perform a basic username/password
197
197
# authentication.
198
- self .sendall (chr ( 0x01 ). encode () + chr (len (self .__proxy [4 ])).encode () + self .__proxy [4 ].encode () + chr (len (self .__proxy [5 ])).encode () + self .__proxy [5 ].encode ())
198
+ self .sendall (b' \x01 ' + chr (len (self .__proxy [4 ])).encode () + self .__proxy [4 ].encode () + chr (len (self .__proxy [5 ])).encode () + self .__proxy [5 ].encode ())
199
199
authstat = self .__recvall (2 )
200
- if authstat [0 :1 ] != chr ( 0x01 ). encode () :
200
+ if authstat [0 :1 ] != b' \x01 ' :
201
201
# Bad response
202
202
self .close ()
203
203
raise GeneralProxyError ((1 , _generalerrors [1 ]))
204
- if authstat [1 :2 ] != chr ( 0x00 ). encode () :
204
+ if authstat [1 :2 ] != b' \x00 ' :
205
205
# Authentication failed
206
206
self .close ()
207
207
raise Socks5AuthError ((3 , _socks5autherrors [3 ]))
208
208
# Authentication succeeded
209
209
else :
210
210
# Reaching here is always bad
211
211
self .close ()
212
- if chosenauth [1 ] == chr ( 0xFF ). encode () :
212
+ if chosenauth [1 : 2 ] == b' \xff ' :
213
213
raise Socks5AuthError ((2 , _socks5autherrors [2 ]))
214
214
else :
215
215
raise GeneralProxyError ((1 , _generalerrors [1 ]))
@@ -219,7 +219,7 @@ def __negotiatesocks5(self, destaddr, destport):
219
219
# use the IPv4 address request even if remote resolving was specified.
220
220
try :
221
221
ipaddr = socket .inet_aton (destaddr )
222
- req = req + chr ( 0x01 ). encode () + ipaddr
222
+ req = req + b' \x01 ' + ipaddr
223
223
except socket .error :
224
224
# Well it's not an IP number, so it's probably a DNS name.
225
225
if self .__proxy [3 ]:
0 commit comments