Пример #1
0
    def _start_probe(self):
        """Try to start up the external connection over some circuit to connect to ourselves"""
        #log_msg("start_probe", 4)
        if not self.probeRunning and self.testsStarted and not self.reachable:
            #log_msg("launch?", 4)
            #if we dont yet know our real IP address:
            if not NetworkState.get_external_ip(self.bbApp):
                #log_msg("no external ip  :(", 4)
                #then we should try back later
                #TODO:  not perfect, we're basically polling for an external IP (which comes from Tor sometimes)
                #the Twisted way would be to have some sort of deferred or callback or something.
                self._schedule_next_test()
                return
            if not self.bbApp.is_ready():
                self._schedule_next_test()
                return
            #find a circuit if we dont have one already or it is broken
            if not self.circ or self.circ.is_done():
                self.circ = self.bbApp.build_circuit(
                    NetworkState.get_external_ip(self.bbApp),
                    self.port,
                    isFast=None,
                    force=True,
                    ignoreExits=self.ignoreExits)
            #if we cant find any suitable circuits
            if not self.circ:
                #try some of the relays that we tried before and failed with
                self.ignoreExits = []
                self.circ = self.bbApp.build_circuit(
                    NetworkState.get_external_ip(self.bbApp),
                    self.port,
                    isFast=None,
                    force=True,
                    ignoreExits=self.ignoreExits)
            #if we STILL cant find any circuits:
            if not self.circ:
                #postpone the probe:
                log_msg(
                    "Delaying the PortTest probe due to lack of suitable circuits",
                    1)
                self._schedule_next_test()
                return


#      #dont send payments, since we dont actually care about this circuit, and it will be closed when we've started up
            self.circ.sendPayments = False
            #launch the connection
            self.probeRunning = True
            self.numProbes += 1
            self._handle_launch()
Пример #2
0
 def _handle_launch(self):
     """Actually launch the externally proxied connection to our forwarded port"""
     log_msg("Testing our %s through %s" %
             (self.name, self.circ.get_exit().desc.idhex))
     self.bbApp.launch_external_protocol(
         NetworkState.get_external_ip(self.bbApp), self.port,
         ProbeProtocol(self), self.circ.handle_stream,
         self._connection_failed, "%sTest" % (self.name))
Пример #3
0
  def _start_probe(self):
    """Try to start up the external connection over some circuit to connect to ourselves"""
    #log_msg("start_probe", 4)
    if not self.probeRunning and self.testsStarted and not self.reachable:
      #log_msg("launch?", 4)
      #if we dont yet know our real IP address:
      if not NetworkState.get_external_ip(self.bbApp):
        #log_msg("no external ip  :(", 4)
        #then we should try back later
        #TODO:  not perfect, we're basically polling for an external IP (which comes from Tor sometimes)
        #the Twisted way would be to have some sort of deferred or callback or something.
        self._schedule_next_test()
        return
      if not self.bbApp.is_ready():
        self._schedule_next_test()
        return
      #find a circuit if we dont have one already or it is broken
      if not self.circ or self.circ.is_done():
        self.circ = self.bbApp.build_circuit(NetworkState.get_external_ip(self.bbApp), self.port, isFast=None, force=True, ignoreExits=self.ignoreExits)
      #if we cant find any suitable circuits
      if not self.circ:
        #try some of the relays that we tried before and failed with
        self.ignoreExits = []
        self.circ = self.bbApp.build_circuit(NetworkState.get_external_ip(self.bbApp), self.port, isFast=None, force=True, ignoreExits=self.ignoreExits)
      #if we STILL cant find any circuits:
      if not self.circ:
        #postpone the probe:
        log_msg("Delaying the PortTest probe due to lack of suitable circuits", 1)
        self._schedule_next_test()
        return
#      #dont send payments, since we dont actually care about this circuit, and it will be closed when we've started up
      self.circ.sendPayments = False
      #launch the connection
      self.probeRunning = True
      self.numProbes += 1
      self._handle_launch()
Пример #4
0
 def _handle_launch(self):
   """Actually launch the externally proxied connection to our forwarded port"""
   log_msg("Testing our %s through %s" % (self.name, self.circ.get_exit().desc.idhex))
   self.bbApp.launch_external_protocol(NetworkState.get_external_ip(self.bbApp), self.port, ProbeProtocol(self), self.circ.handle_stream, self._connection_failed, "%sTest" % (self.name))