Beispiel #1
0
    def handleKey(self, key):
        isKeystrokeConsumed = True

        if key in (ord('n'),
                   ord('N')) and torTools.getConn().isNewnymAvailable():
            self.sendNewnym()
        elif key in (ord('r'), ord('R')) and not self._isTorConnected:
            torctlConn = None
            allowPortConnection, allowSocketConnection, _ = starter.allowConnectionTypes(
            )

            if os.path.exists(self._config["startup.interface.socket"]
                              ) and allowSocketConnection:
                try:
                    torctlConn = torTools.connect_socket(
                        self._config["startup.interface.socket"])
                except IOError, exc:
                    if not allowPortConnection:
                        cli.popups.showMsg("Unable to reconnect (%s)" % exc, 3)
            elif not allowPortConnection:
                cli.popups.showMsg(
                    "Unable to reconnect (socket '%s' doesn't exist)" %
                    self._config["startup.interface.socket"], 3)

            if not torctlConn and allowPortConnection:
                try:
                    ctlAddr, ctlPort = self._config[
                        "startup.interface.ipAddress"], self._config[
                            "startup.interface.port"]
                    tmpConn, authType, authValue = TorCtl.TorCtl.preauth_connect(
                        ctlAddr, ctlPort)

                    if authType == TorCtl.TorCtl.AUTH_TYPE.PASSWORD:
                        authValue = cli.popups.inputPrompt(
                            "Controller Password: "******"Reconnected to Tor's control port")
                        cli.popups.showMsg("Tor reconnected", 1)
                    except:
                        # displays notice for the first failed connection attempt
                        if exc.args:
                            cli.popups.showMsg(
                                "Unable to reconnect (%s)" % exc, 3)
Beispiel #2
0
 def handleKey(self, key):
   isKeystrokeConsumed = True
   
   if key in (ord('n'), ord('N')) and torTools.getConn().isNewnymAvailable():
     self.sendNewnym()
   elif key in (ord('r'), ord('R')) and not self._isTorConnected:
     torctlConn = None
     allowPortConnection, allowSocketConnection, _ = starter.allowConnectionTypes()
     
     if os.path.exists(self._config["startup.interface.socket"]) and allowSocketConnection:
       try: torctlConn = torTools.connect_socket(self._config["startup.interface.socket"])
       except IOError, exc:
         if not allowPortConnection:
           cli.popups.showMsg("Unable to reconnect (%s)" % exc, 3)
     elif not allowPortConnection:
       cli.popups.showMsg("Unable to reconnect (socket '%s' doesn't exist)" % self._config["startup.interface.socket"], 3)
     
     if not torctlConn and allowPortConnection:
       # TODO: This has diverged from starter.py's connection, for instance it
       # doesn't account for relative cookie paths or multiple authentication
       # methods. We can't use the starter.py's connection function directly
       # due to password prompts, but we could certainly make this mess more
       # manageable.
       
       try:
         ctlAddr, ctlPort = self._config["startup.interface.ipAddress"], self._config["startup.interface.port"]
         tmpConn, authType, authValue = TorCtl.TorCtl.preauth_connect(ctlAddr, ctlPort)
         
         if authType == TorCtl.TorCtl.AUTH_TYPE.PASSWORD:
           authValue = cli.popups.inputPrompt("Controller Password: "******"authentication cookie '%s' is the wrong size (%i bytes instead of 32)" % (authValue, authCookieSize))
         
         tmpConn.authenticate(authValue)
         torctlConn = tmpConn
       except Exception, exc:
         # attempts to use the wizard port too
         try:
           cli.controller.getController().getTorManager().connectManagedInstance()
           log.log(log.NOTICE, "Reconnected to Tor's control port")
           cli.popups.showMsg("Tor reconnected", 1)
         except:
           # displays notice for the first failed connection attempt
           if exc.args: cli.popups.showMsg("Unable to reconnect (%s)" % exc, 3)
Beispiel #3
0
 def handleKey(self, key):
   isKeystrokeConsumed = True
   
   if key in (ord('n'), ord('N')) and torTools.getConn().isNewnymAvailable():
     self.sendNewnym()
   elif key in (ord('r'), ord('R')) and not self._isTorConnected:
     torctlConn = None
     allowPortConnection, allowSocketConnection, _ = starter.allowConnectionTypes()
     
     if os.path.exists(self._config["startup.interface.socket"]) and allowSocketConnection:
       try: torctlConn = torTools.connect_socket(self._config["startup.interface.socket"])
       except IOError, exc:
         if not allowPortConnection:
           cli.popups.showMsg("Unable to reconnect (%s)" % exc, 3)
     elif not allowPortConnection:
       cli.popups.showMsg("Unable to reconnect (socket '%s' doesn't exist)" % self._config["startup.interface.socket"], 3)
     
     if not torctlConn and allowPortConnection:
       try:
         ctlAddr, ctlPort = self._config["startup.interface.ipAddress"], self._config["startup.interface.port"]
         tmpConn, authType, authValue = TorCtl.TorCtl.preauth_connect(ctlAddr, ctlPort)
         
         if authType == TorCtl.TorCtl.AUTH_TYPE.PASSWORD:
           authValue = cli.popups.inputPrompt("Controller Password: "******"Reconnected to Tor's control port")
           cli.popups.showMsg("Tor reconnected", 1)
         except:
           # displays notice for the first failed connection attempt
           if exc.args: cli.popups.showMsg("Unable to reconnect (%s)" % exc, 3)