else: out = bencode({TID: msg[TID], TYP: RSP, RSP: {}}) # send response olen = len(out) #self.rltransport.sendto(out, 0, addr) self.transport.write(out, addr) else: if self.noisy: #print "don't know about method %s" % msg[REQ] pass # unknown method olen = self.sendErr(addr, msg[TID], *KERR_METHOD_UNKNOWN) if self.noisy: try: ndist = 10 * log10(2**160 * 1.0 / distance( self.factory.node.id, msg[ARG]['id'])) ndist = int(ndist) except OverflowError: ndist = 999 h = None if msg[ARG].has_key('target'): h = msg[ARG]['target'] elif msg[ARG].has_key('info_hash'): h = msg[ARG]['info_hash'] else: tdist = '-' if h != None: try: tdist = 10 * log10(2**160 * 1.0 / distance(
out = bencode({TID : msg[TID], TYP : RSP, RSP : {}}) # send response olen = len(out) self.rltransport.sendto(out, 0, addr) else: if self.noisy: #print "don't know about method %s" % msg[REQ] pass # unknown method out = bencode({TID:msg[TID], TYP:ERR, ERR : KRPC_ERROR_METHOD_UNKNOWN}) olen = len(out) self.rltransport.sendto(out, 0, addr) if self.noisy: try: ndist = 10 * log10(2**160 * 1.0 / distance(self.factory.node.id, msg[ARG]['id'])) ndist = int(ndist) except OverflowError: ndist = 999 h = None if msg[ARG].has_key('target'): h = msg[ARG]['target'] elif msg[ARG].has_key('info_hash'): h = msg[ARG]['info_hash'] else: tdist = '-' if h != None: try: tdist = 10 * log10(2**160 * 1.0 / distance(self.factory.node.id, h))