Exemplo n.º 1
0
    def _setup_environment(self):
        """Finish misc startup tasks like starting logging, zipping any crash logs 
    from the last run, installing signal handlers, startup argument handler, etc"""

        #apply the necessary hacks:
        Twisted.apply_dns_hack()
        Twisted.apply_dns_hack2()
        if System.IS_WINDOWS:
            Win32HiddenWindowHack.apply()

        #start listening for connections from any other instances of BitBlinder
        StartupServer.start()

        Profiler.start()

        #Make sure we log ALL exceptions
        Twisted.install_exception_handlers(self.on_quit_signal)

        #Set the signal handler for exiting
        def sig_handler(signum, frame):
            self.on_quit_signal()

        signal.signal(signal.SIGTERM, sig_handler)

        #make the gui:
        GUIController.start()
        self.gui = GUIController.get()

        #do some tests to see how this user's network is configured:
        NetworkState.test_network_state()

        #TODO: figure out what needs to change in the wrapper and submit a fix
        warnings.filterwarnings('ignore',
                                module=".*TwistedProtocolWrapper.*",
                                lineno=447)
Exemplo n.º 2
0
 def _setup_environment(self):
   """Finish misc startup tasks like starting logging, zipping any crash logs 
   from the last run, installing signal handlers, startup argument handler, etc"""
   
   #apply the necessary hacks:
   Twisted.apply_dns_hack()
   Twisted.apply_dns_hack2()
   if System.IS_WINDOWS:
     Win32HiddenWindowHack.apply()
   
   #start listening for connections from any other instances of BitBlinder
   StartupServer.start()
   
   Profiler.start()
   
   #Make sure we log ALL exceptions
   Twisted.install_exception_handlers(self.on_quit_signal)
   
   #Set the signal handler for exiting
   def sig_handler(signum, frame):
     self.on_quit_signal()
   signal.signal(signal.SIGTERM, sig_handler)
   
   #make the gui:
   GUIController.start()
   self.gui = GUIController.get()
   
   #do some tests to see how this user's network is configured:
   NetworkState.test_network_state()
   
   #TODO: figure out what needs to change in the wrapper and submit a fix
   warnings.filterwarnings('ignore', module=".*TwistedProtocolWrapper.*", lineno=447)
Exemplo n.º 3
0
 def start_test(self):
     if not self.testsStarted:
         self.testsStarted = True
         #try the server test
         NetworkState.test_incoming_port(self.port,
                                         self._on_server_test_done,
                                         self.portTestType)
Exemplo n.º 4
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()
Exemplo n.º 5
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))
Exemplo n.º 6
0
 def get_status(self):
   statusString = ""
   #get the status of all the individual components:
   for app in (self.bankApp, self.torApp, self.bbApp, self.btApp, self.ffApp):
     if app:
       statusString += app.get_status() + "\n"
   #network status
   statusString += NetworkState.get_status()
   return statusString
Exemplo n.º 7
0
 def get_status(self):
     statusString = ""
     #get the status of all the individual components:
     for app in (self.bankApp, self.torApp, self.bbApp, self.btApp,
                 self.ffApp):
         if app:
             statusString += app.get_status() + "\n"
     #network status
     statusString += NetworkState.get_status()
     return statusString
Exemplo n.º 8
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()
Exemplo n.º 9
0
 def start_test(self):
   if not self.testsStarted:
     self.testsStarted = True
     #try the server test
     NetworkState.test_incoming_port(self.port, self._on_server_test_done, self.portTestType)
Exemplo n.º 10
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))