comparison src/plugins/plugin_xep_0065.py @ 1409:3265a2639182

massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
author souliane <souliane@mailoo.org>
date Thu, 16 Apr 2015 14:57:57 +0200
parents 069ad98b360d
children 7cc29634b6ef
comparison
equal deleted inserted replaced
1408:8a7145138330 1409:3265a2639182
303 303
304 except struct.error: 304 except struct.error:
305 return None 305 return None
306 306
307 def connectionMade(self): 307 def connectionMade(self):
308 log.debug("connectionMade (mode = %s)" % "requester" if isinstance(self.factory, Socks5ServerFactory) else "target") 308 log.debug(u"connectionMade (mode = %s)" % "requester" if isinstance(self.factory, Socks5ServerFactory) else "target")
309 309
310 if isinstance(self.factory, Socks5ClientFactory): 310 if isinstance(self.factory, Socks5ClientFactory):
311 self.sid = self.factory.sid 311 self.sid = self.factory.sid
312 self.profile = self.factory.profile 312 self.profile = self.factory.profile
313 self.data = self.factory.data 313 self.data = self.factory.data
350 350
351 def bindRequested(self, addr, port): 351 def bindRequested(self, addr, port):
352 pass 352 pass
353 353
354 def authenticateUserPass(self, user, passwd): 354 def authenticateUserPass(self, user, passwd):
355 log.debug("User/pass: %s/%s" % (user, passwd)) 355 # FIXME: implement authentication and remove the debug printing a password
356 log.debug(u"User/pass: %s/%s" % (user, passwd))
356 return True 357 return True
357 358
358 def dataReceived(self, buf): 359 def dataReceived(self, buf):
359 if self.state == STATE_TARGET_READY: 360 if self.state == STATE_TARGET_READY:
360 self.data["file_obj"].write(buf) 361 self.data["file_obj"].write(buf)
401 402
402 def startedConnecting(self, connector): 403 def startedConnecting(self, connector):
403 log.debug(_("Socks 5 server connection started")) 404 log.debug(_("Socks 5 server connection started"))
404 405
405 def clientConnectionLost(self, connector, reason): 406 def clientConnectionLost(self, connector, reason):
406 log.debug(_("Socks 5 server connection lost (reason: %s)") % reason) 407 log.debug(_(u"Socks 5 server connection lost (reason: %s)") % reason)
407 408
408 409
409 class Socks5ClientFactory(protocol.ClientFactory): 410 class Socks5ClientFactory(protocol.ClientFactory):
410 protocol = SOCKSv5 411 protocol = SOCKSv5
411 412
429 430
430 def startedConnecting(self, connector): 431 def startedConnecting(self, connector):
431 log.debug(_("Socks 5 client connection started")) 432 log.debug(_("Socks 5 client connection started"))
432 433
433 def clientConnectionLost(self, connector, reason): 434 def clientConnectionLost(self, connector, reason):
434 log.debug(_("Socks 5 client connection lost (reason: %s)") % reason) 435 log.debug(_(u"Socks 5 client connection lost (reason: %s)") % reason)
435 self.finishedCb(self.sid, reason.type == error.ConnectionDone, self.profile) # TODO: really check if the state is actually successful 436 self.finishedCb(self.sid, reason.type == error.ConnectionDone, self.profile) # TODO: really check if the state is actually successful
436 437
437 438
438 class XEP_0065(object): 439 class XEP_0065(object):
439 440
682 query_elt = iq_elt.firstChildElement() 683 query_elt = iq_elt.firstChildElement()
683 sid = query_elt.getAttribute("sid") 684 sid = query_elt.getAttribute("sid")
684 streamhost_elts = filter(lambda elt: elt.name == 'streamhost', query_elt.elements()) 685 streamhost_elts = filter(lambda elt: elt.name == 'streamhost', query_elt.elements())
685 686
686 if not sid in client.xep_0065_current_stream: 687 if not sid in client.xep_0065_current_stream:
687 log.warning(_("Ignoring unexpected BS transfer: %s" % sid)) 688 log.warning(_(u"Ignoring unexpected BS transfer: %s" % sid))
688 self.sendNotAcceptableError(iq_elt['id'], iq_elt['from'], xmlstream) 689 self.sendNotAcceptableError(iq_elt['id'], iq_elt['from'], xmlstream)
689 return 690 return
690 691
691 client.xep_0065_current_stream[sid]['timer'].cancel() 692 client.xep_0065_current_stream[sid]['timer'].cancel()
692 client.xep_0065_current_stream[sid]["to"] = jid.JID(iq_elt["to"]) 693 client.xep_0065_current_stream[sid]["to"] = jid.JID(iq_elt["to"])
693 client.xep_0065_current_stream[sid]["xmlstream"] = xmlstream 694 client.xep_0065_current_stream[sid]["xmlstream"] = xmlstream
694 695
695 if not streamhost_elts: 696 if not streamhost_elts:
696 log.warning(_("No streamhost found in stream query %s" % sid)) 697 log.warning(_(u"No streamhost found in stream query %s" % sid))
697 self.sendBadRequestError(iq_elt['id'], iq_elt['from'], xmlstream) 698 self.sendBadRequestError(iq_elt['id'], iq_elt['from'], xmlstream)
698 return 699 return
699 700
700 streamhost_elt = streamhost_elts[0] # TODO: manage several streamhost elements case 701 streamhost_elt = streamhost_elts[0] # TODO: manage several streamhost elements case
701 sh_host = streamhost_elt.getAttribute("host") 702 sh_host = streamhost_elt.getAttribute("host")