コード例 #1
0
ファイル: EchoServer.py プロジェクト: wallydz/BitBlinder
def main():
    Twisted.install_exception_handlers()
    Globals.reactor = reactor

    reactor.listenTCP(options.port, TCPServer())
    reactor.listenUDP(options.port, UDPServer())
    log_msg('Server is listening on port: %s!' % (options.port), 2)

    reactor.run()
    log_msg("Shutdown cleanly", 2)
コード例 #2
0
ファイル: EchoServer.py プロジェクト: clawplach/BitBlinder
def main():
  Twisted.install_exception_handlers()
  Globals.reactor = reactor
  
  reactor.listenTCP(options.port, TCPServer())
  reactor.listenUDP(options.port, UDPServer())
  log_msg('Server is listening on port: %s!' % (options.port), 2)

  reactor.run()
  log_msg("Shutdown cleanly", 2)
コード例 #3
0
ファイル: BankServer.py プロジェクト: clawplach/BitBlinder
def main():
  """Launches the Serverfactoryprotocolthing """
  #run as a daemon
  Globals.logger = Logger.Logger(options.debug)
  Globals.logger.start_logs(["BANK", "errors"], "BANK", ".")
  Twisted.install_exception_handlers()
  BankUtil.update_local_acoin_interval(start_listening, on_new_interval)
  Globals.reactor = reactor
  log_msg('Server started: fail is imminent (not an error)!', 0)
  if Globals.DEBUG:
    def start_profiler():
      Globals.PROFILER.clear()
      Globals.PROFILER.enable()
    def stop_profiler():
      Globals.PROFILER.disable()
      Globals.PROFILER.dump_stats("temp.stats")
    reactor.callLater(15.0, start_profiler)
    reactor.callLater(75.0, stop_profiler)
  reactor.run()
  ACoinMessages.eventLogger.on_shutdown()
  log_msg("Shutdown cleanly", 2)
コード例 #4
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)
コード例 #5
0
ファイル: MainLoop.py プロジェクト: clawplach/BitBlinder
 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)
コード例 #6
0
ファイル: UPNPPort.py プロジェクト: clawplach/BitBlinder
 def _upnp_request(self):
   """Actually start the program to do the UPNP forwarding"""
   try:
     #figure out our local IP address
     localIP = Twisted.get_lan_ip()
     #start the external UPNP forwarding program
     output = self._start_upnp_exe(("-m", localIP, "-a", localIP, str(self.port), str(self.port), self.trafficType))
     #handle results
     output.addCallback(self._upnp_response)
     output.addErrback(self.upnp_failed)
   except Exception, error:
     log_ex(error, "Failed to send UPNP request")
     self.upnp_failed("Never even sent the request  :(")
コード例 #7
0
 def _upnp_request(self):
     """Actually start the program to do the UPNP forwarding"""
     try:
         #figure out our local IP address
         localIP = Twisted.get_lan_ip()
         #start the external UPNP forwarding program
         output = self._start_upnp_exe(
             ("-m", localIP, "-a", localIP, str(self.port), str(self.port),
              self.trafficType))
         #handle results
         output.addCallback(self._upnp_response)
         output.addErrback(self.upnp_failed)
     except Exception, error:
         log_ex(error, "Failed to send UPNP request")
         self.upnp_failed("Never even sent the request  :(")
コード例 #8
0
ファイル: BankServer.py プロジェクト: wallydz/BitBlinder
def main():
    """Launches the Serverfactoryprotocolthing """
    #run as a daemon
    Globals.logger = Logger.Logger(options.debug)
    Globals.logger.start_logs(["BANK", "errors"], "BANK", ".")
    Twisted.install_exception_handlers()
    BankUtil.update_local_acoin_interval(start_listening, on_new_interval)
    Globals.reactor = reactor
    log_msg('Server started: fail is imminent (not an error)!', 0)
    if Globals.DEBUG:

        def start_profiler():
            Globals.PROFILER.clear()
            Globals.PROFILER.enable()

        def stop_profiler():
            Globals.PROFILER.disable()
            Globals.PROFILER.dump_stats("temp.stats")

        reactor.callLater(15.0, start_profiler)
        reactor.callLater(75.0, stop_profiler)
    reactor.run()
    ACoinMessages.eventLogger.on_shutdown()
    log_msg("Shutdown cleanly", 2)
コード例 #9
0
ファイル: NetworkState.py プロジェクト: kans/BitBlinder
def _update_ip(address, method):
    """Call this function when you learn about a new external IP address"""
    global _externalIP
    if not Twisted.is_local_ip(address):
        if not _externalIP:
            pass
        elif _externalIP != address:
            log_msg(
                "%s reported a different external IP than we already knew about:  %s vs %s"
                % (method, Basic.clean(address), Basic.clean(_externalIP)),
                3,
            )
        else:
            return
        _externalIP = address
        GlobalEvents.throw_event("ip_update", address, method)
    else:
        log_msg("Learned about local address %s via %s, not very helpful..." % (Basic.clean(address), method), 4)
コード例 #10
0
def _update_ip(address, method):
    """Call this function when you learn about a new external IP address"""
    global _externalIP
    if not Twisted.is_local_ip(address):
        if not _externalIP:
            pass
        elif _externalIP != address:
            log_msg(
                "%s reported a different external IP than we already knew about:  %s vs %s"
                % (method, Basic.clean(address), Basic.clean(_externalIP)), 3)
        else:
            return
        _externalIP = address
        GlobalEvents.throw_event("ip_update", address, method)
    else:
        log_msg(
            "Learned about local address %s via %s, not very helpful..." %
            (Basic.clean(address), method), 4)
コード例 #11
0
ファイル: UPNPPort.py プロジェクト: clawplach/BitBlinder
 def _remove_upnp(self):
   """Actually call the outside program to remove the UPNP binding.  Returns a
   deferred that will be triggered when the port binding has finished (either
   successfully or unsuccessfully)"""
   #failures just get printed out, because we cant really do anything about them
   def handle_failure(failure):
     log_msg("Failed to remove UPNP mapping on shutdown:  %s" % (failure), 1)
   try:
     #figure out our local IP address
     localIP = Twisted.get_lan_ip()
     #launch the program
     output = self._start_upnp_exe(("-m", localIP, "-d", str(self.port), self.trafficType))
     #handle results
     output.addCallback(self._upnp_removed)
     output.addErrback(handle_failure)
     return output
   except Exception, error:
     log_ex(error, "Failed send request to remove UPNP")
     handle_failure("Never even sent the request  :(")
コード例 #12
0
    def _remove_upnp(self):
        """Actually call the outside program to remove the UPNP binding.  Returns a
    deferred that will be triggered when the port binding has finished (either
    successfully or unsuccessfully)"""

        #failures just get printed out, because we cant really do anything about them
        def handle_failure(failure):
            log_msg(
                "Failed to remove UPNP mapping on shutdown:  %s" % (failure),
                1)

        try:
            #figure out our local IP address
            localIP = Twisted.get_lan_ip()
            #launch the program
            output = self._start_upnp_exe(
                ("-m", localIP, "-d", str(self.port), self.trafficType))
            #handle results
            output.addCallback(self._upnp_removed)
            output.addErrback(handle_failure)
            return output
        except Exception, error:
            log_ex(error, "Failed send request to remove UPNP")
            handle_failure("Never even sent the request  :(")