@@ -185,31 +185,31 @@ def __negotiatesocks5(self, destaddr, destport):
185185 # We'll receive the server's response to determine which
186186 # method was selected
187187 chosenauth = self .__recvall (2 )
188- if chosenauth [0 :1 ] != chr ( 0x05 ). encode () :
188+ if chosenauth [0 :1 ] != b' \x05 ' :
189189 self .close ()
190190 raise GeneralProxyError ((1 , _generalerrors [1 ]))
191191 # Check the chosen authentication method
192- if chosenauth [1 :2 ] == chr ( 0x00 ). encode () :
192+ if chosenauth [1 :2 ] == b' \x00 ' :
193193 # No authentication is required
194194 pass
195- elif chosenauth [1 :2 ] == chr ( 0x02 ). encode () :
195+ elif chosenauth [1 :2 ] == b' \x02 ' :
196196 # Okay, we need to perform a basic username/password
197197 # 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 ())
199199 authstat = self .__recvall (2 )
200- if authstat [0 :1 ] != chr ( 0x01 ). encode () :
200+ if authstat [0 :1 ] != b' \x01 ' :
201201 # Bad response
202202 self .close ()
203203 raise GeneralProxyError ((1 , _generalerrors [1 ]))
204- if authstat [1 :2 ] != chr ( 0x00 ). encode () :
204+ if authstat [1 :2 ] != b' \x00 ' :
205205 # Authentication failed
206206 self .close ()
207207 raise Socks5AuthError ((3 , _socks5autherrors [3 ]))
208208 # Authentication succeeded
209209 else :
210210 # Reaching here is always bad
211211 self .close ()
212- if chosenauth [1 ] == chr ( 0xFF ). encode () :
212+ if chosenauth [1 : 2 ] == b' \xff ' :
213213 raise Socks5AuthError ((2 , _socks5autherrors [2 ]))
214214 else :
215215 raise GeneralProxyError ((1 , _generalerrors [1 ]))
@@ -219,7 +219,7 @@ def __negotiatesocks5(self, destaddr, destport):
219219 # use the IPv4 address request even if remote resolving was specified.
220220 try :
221221 ipaddr = socket .inet_aton (destaddr )
222- req = req + chr ( 0x01 ). encode () + ipaddr
222+ req = req + b' \x01 ' + ipaddr
223223 except socket .error :
224224 # Well it's not an IP number, so it's probably a DNS name.
225225 if self .__proxy [3 ]:
0 commit comments