def sendto(self, data, destination):
if self.check_num_packets(destination, False):
if DataChecker.is_allowed(data):
def on_error(failure):
self.logger.error("Can't resolve ip address for hostname %s. Failure: %s",
destination[0], failure)
def on_ip_address(ip_address):
self.logger.debug("Resolved hostname %s to ip_address %s", destination[0], ip_address)
try:
self.transport.write(data, (ip_address, destination[1]))
self.overlay.increase_bytes_sent(self, len(data))
except (AttributeError, MessageLengthError, socket.error) as exception:
self.logger.error(
"Failed to write data to transport: %s. Destination: %r error was: %r",
exception, destination, exception)
resolve_ip_address_deferred = reactor.resolve(destination[0])
resolve_ip_address_deferred.addCallbacks(on_ip_address, on_error)
self.register_task("resolving_%r" % destination[0], resolve_ip_address_deferred)
else:
self.logger.error("dropping forbidden packets from exit socket with circuit_id %d",
self.circuit_id)
评论列表
文章目录