OpenSecurity/bin/opensecurity_tray.pyw
changeset 234 216da9017f8f
parent 223 a4fb6694e6fe
child 238 d33edf5c2717
     1.1 --- a/OpenSecurity/bin/opensecurity_tray.pyw	Wed Sep 24 16:40:43 2014 +0100
     1.2 +++ b/OpenSecurity/bin/opensecurity_tray.pyw	Thu Oct 02 13:08:09 2014 +0100
     1.3 @@ -39,8 +39,6 @@
     1.4  import urllib
     1.5  import urllib2
     1.6  import webbrowser
     1.7 -import _winreg
     1.8 -import re
     1.9  
    1.10  from PyQt4 import QtCore
    1.11  from PyQt4 import QtGui
    1.12 @@ -52,11 +50,11 @@
    1.13      from cygwin import Cygwin
    1.14  
    1.15  import opensecurity_client_restful_server 
    1.16 +import proxy_getter
    1.17  from ui import AboutDialog
    1.18  from ui import ConfigureDialog
    1.19  from ui import opensecurity_rc
    1.20  
    1.21 -
    1.22  # ------------------------------------------------------------
    1.23  # code
    1.24  
    1.25 @@ -106,32 +104,6 @@
    1.26          """clicked about"""
    1.27          d = AboutDialog()
    1.28          d.exec_()
    1.29 -    
    1.30 -    def getProxySettings(self):        
    1.31 -        aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_CURRENT_USER)
    1.32 -        aKey = _winreg.OpenKey(aReg, r"Software\Microsoft\Windows\CurrentVersion\Internet Settings")
    1.33 -        subCount, valueCount, lastModified = _winreg.QueryInfoKey(aKey)
    1.34 -        reg_entries = dict()
    1.35 -        for i in range(valueCount):                                           
    1.36 -            try:
    1.37 -                n,v,t = _winreg.EnumValue(aKey,i)
    1.38 -                reg_entries[n] = v
    1.39 -            except EnvironmentError:                                               
    1.40 -                break
    1.41 -        _winreg.CloseKey(aKey)
    1.42 -        
    1.43 -        if 'AutoConfigURL' in reg_entries.keys():
    1.44 -            return {'ProxyAutoConfigURL': reg_entries['AutoConfigURL']}
    1.45 -
    1.46 -        if 'ProxyEnable' in reg_entries.keys() and reg_entries['ProxyEnable'] == 1:
    1.47 -            proxy_search = re.search(r"(?<=http=)(?P<ProxyServer>.*?)(?=;)", reg_entries['ProxyServer'])
    1.48 -            if proxy_search:
    1.49 -                proxies = proxy_search.groupdict()
    1.50 -                if 'ProxyServer' in proxies.keys(): # found http proxy
    1.51 -                    return {'ProxyServer': proxies['ProxyServer']}  
    1.52 -            return {'ProxyServer': reg_entries['ProxyServer']}
    1.53 -            
    1.54 -        return None
    1.55  
    1.56      def clicked_browser(self):
    1.57          """wish for safe internet browsing"""
    1.58 @@ -150,7 +122,7 @@
    1.59              urllib2.install_opener(opener)
    1.60  
    1.61              req_data = ""
    1.62 -            proxy = self.getProxySettings()
    1.63 +            proxy = proxy_getter.getProxySettings()
    1.64              if proxy:
    1.65                  req_data = '?' + urllib.urlencode(proxy) 
    1.66              req = 'http://127.0.0.1:8080/browsing'+ req_data
    1.67 @@ -187,14 +159,11 @@
    1.68              return
    1.69  
    1.70          try:
    1.71 -        
    1.72              # get a proper browsing VM
    1.73              Cygwin.start_X11()
    1.74 -
    1.75              # TODO: HARDCODED ADDRESS OF OPENSECURITYD
    1.76              url = 'http://127.0.0.1:8080/sdvms/' + j['vm'] + '/application' + j['application']
    1.77              result = urllib2.urlopen(url).readline()
    1.78 -            
    1.79          except:
    1.80              pass 
    1.81