示例#1
0
 def set_start_on_boot(self, newVal):
   """Change the registry key (if necessary) for auto launching BitBlinder at startup on windows, does nothing on *nix.
   Ends up calling a function made with NSIS that will get the necessary permissions to do the modification
   @param newVal:  whether to start on boot or not
   @type  newVal:  bool"""
   if not System.IS_WINDOWS:
     return
   #No need to change if the value is already correct?
   if self.check_start_on_boot() == newVal:
     if self.startOnBootDeferred:
       log_msg("Failed to modify 'start at bootup' value, already editing the registry!", 0)
     return
   if self.startOnBootDeferred:
     return
   def uac_done(result):
     self.startOnBootDeferred = None
     if result != True:
       log_ex(result, "Bad result while running BitBlinderSettingsUpdate.exe")
   #launch the program:
   if newVal:
     args = " --add-startup=" + ClientUtil.get_launch_command()
   else:
     args = " --remove-startup"
     
   encodedExe = System.encode_for_filesystem(os.path.join(Globals.WINDOWS_BIN, "BitBlinderSettingsUpdate.exe"))
   self.startOnBootDeferred = SerialProcessLauncher.get().run_app(encodedExe + "  /S" + args)
   self.startOnBootDeferred.addCallback(uac_done)
   self.startOnBootDeferred.addErrback(uac_done)
示例#2
0
 def set_half_open_conns(self, app, halfOpenConnections):
     """uses tcpz to change the number of half open connections to 218"""
     try:
         #this is a windows specific fix:
         if not System.IS_WINDOWS:
             return
         #also, this is only necessary if we are acting as a Tor server:
         if not app.torApp.settings.beRelay:
             return
         winInfo = sys.getwindowsversion()
         #not sure if this exists, but just in case :)
         if winInfo[0] > 6:
             return
         #if this is win7, we're all set:
         if winInfo[0] == 6 and winInfo[1] >= 1:
             return
         #if this is vista, check the service pack level:
         if winInfo[0] == 6 and winInfo[1] == 0:
             #default and SP1 need fixing:
             if winInfo[4] not in ('', 'Service Pack 1'):
                 return
         if halfOpenConnections:
             #if we already did this, also return:
             if self.appliedHalfOpenCorrection:
                 return
             self.appliedHalfOpenCorrection = True
             #we should only ever run one tcp-z, no going back etiher
             ids = System.get_process_ids()
             for id in ids:
                 if id[0] == 'tcpz.exe':
                     return
             #create the vbs script file to do what we need:
             encodedScriptFile = System.encode_for_filesystem(
                 os.path.join(Globals.USER_DATA_DIR, "tcpz.vbs"))
             encodedExe = System.encode_for_filesystem(
                 os.path.join(Globals.WINDOWS_BIN, 'tcpz.exe'))
             cmd = """Set oShell = WScript.CreateObject("WSCript.shell")\r\ncall oShell.run("cmd /c ""%s"" -limit:220 -autoexit", 0, false)\r\n""" % (
                 encodedExe)
             f = open(encodedScriptFile, "wb")
             f.write(cmd)
             f.close()
             #and execute the script:
             SerialProcessLauncher.get().run_app(
                 'cscript.exe "%s" //B //Nologo' % (encodedScriptFile))
             return
     except Exception, e:
         log_ex(e, "Failed to launch tcpz.exe")
示例#3
0
 def set_half_open_conns(self, app, halfOpenConnections):
   """uses tcpz to change the number of half open connections to 218"""
   try:
     #this is a windows specific fix:
     if not System.IS_WINDOWS:
       return
     #also, this is only necessary if we are acting as a Tor server:
     if not app.torApp.settings.beRelay:
       return
     winInfo = sys.getwindowsversion()
     #not sure if this exists, but just in case :)
     if winInfo [0] > 6:
       return
     #if this is win7, we're all set:
     if winInfo[0] == 6 and winInfo[1] >= 1:
       return
     #if this is vista, check the service pack level:
     if winInfo[0] == 6 and winInfo[1] == 0:
       #default and SP1 need fixing:
       if winInfo[4] not in ('', 'Service Pack 1'):
         return
     if halfOpenConnections:
       #if we already did this, also return:
       if self.appliedHalfOpenCorrection:
         return
       self.appliedHalfOpenCorrection = True
       #we should only ever run one tcp-z, no going back etiher
       ids = System.get_process_ids()
       for id in ids:
         if id[0] == 'tcpz.exe':
           return
       #create the vbs script file to do what we need:
       encodedScriptFile = System.encode_for_filesystem(os.path.join(Globals.USER_DATA_DIR, "tcpz.vbs"))
       encodedExe = System.encode_for_filesystem(os.path.join(Globals.WINDOWS_BIN,'tcpz.exe'))
       cmd = """Set oShell = WScript.CreateObject("WSCript.shell")\r\ncall oShell.run("cmd /c ""%s"" -limit:220 -autoexit", 0, false)\r\n""" % (encodedExe)
       f = open(encodedScriptFile, "wb")
       f.write(cmd)
       f.close()
       #and execute the script:
       SerialProcessLauncher.get().run_app('cscript.exe "%s" //B //Nologo' % (encodedScriptFile))
       return
   except Exception, e:
     log_ex(e, "Failed to launch tcpz.exe")
示例#4
0
    def set_start_on_boot(self, newVal):
        """Change the registry key (if necessary) for auto launching BitBlinder at startup on windows, does nothing on *nix.
    Ends up calling a function made with NSIS that will get the necessary permissions to do the modification
    @param newVal:  whether to start on boot or not
    @type  newVal:  bool"""
        if not System.IS_WINDOWS:
            return
        #No need to change if the value is already correct?
        if self.check_start_on_boot() == newVal:
            if self.startOnBootDeferred:
                log_msg(
                    "Failed to modify 'start at bootup' value, already editing the registry!",
                    0)
            return
        if self.startOnBootDeferred:
            return

        def uac_done(result):
            self.startOnBootDeferred = None
            if result != True:
                log_ex(
                    result,
                    "Bad result while running BitBlinderSettingsUpdate.exe")

        #launch the program:
        if newVal:
            args = " --add-startup=" + ClientUtil.get_launch_command()
        else:
            args = " --remove-startup"

        encodedExe = System.encode_for_filesystem(
            os.path.join(Globals.WINDOWS_BIN, "BitBlinderSettingsUpdate.exe"))
        self.startOnBootDeferred = SerialProcessLauncher.get().run_app(
            encodedExe + "  /S" + args)
        self.startOnBootDeferred.addCallback(uac_done)
        self.startOnBootDeferred.addErrback(uac_done)