raise KrpcError, (KRPC_ERROR_MALFORMED_PACKET, "response not specified")
if type(msg[RSP]) != dict:
raise KrpcError, (KRPC_ERROR_MALFORMED_PACKET, "response is not a dictionary")
+# if 'nodes' in msg[RSP] and type(msg[RSP]['nodes']) != list:
+# raise KrpcError, (KRPC_ERROR_MALFORMED_PACKET, "wrong type of node, this is not bittorrent")
elif msg[TYP] == ERR:
if ERR not in msg:
raise KrpcError, (KRPC_ERROR_MALFORMED_PACKET, "error not specified")
raise KrpcError, (KRPC_ERROR_MALFORMED_PACKET, "no transaction ID specified")
if type(msg[TID]) != str:
raise KrpcError, (KRPC_ERROR_MALFORMED_PACKET, "transaction id is not a string")
+ if len(msg[TID]) != 20:
+ raise KrpcError, (KRPC_ERROR_MALFORMED_PACKET, "wrong type of node, this is not bittorrent")
class hostbroker(protocol.DatagramProtocol):
"""The factory for the KRPC protocol.
msg = bdecode(data)
except Exception, e:
if self.config.get('SPEW', False):
- log.msg("krpc bdecode error: ")
+ log.msg("krpc bdecode error from %r: " % (addr, ))
log.err(e)
return
try:
verifyMessage(msg)
except Exception, e:
- log.msg("krpc message verification error: ")
- log.err(e)
+ log.msg("krpc message verification error from %r: %r" % (addr, e))
return
if self.config.get('SPEW', False):
else:
# no tid, this transaction was finished already...
log.msg('received an error %r from %r for completed request: %r' %
- (msg[ERR], msg[RSP]['id'], msg[TID]))
+ (msg[ERR], addr, msg[TID]))
else:
# Received an unknown message type
if self.config.get('SPEW', False):