modified start_browsing script to use the proxy settings
authorBartha Mihai <mihai.bartha@ait.ac.at>
Tue, 28 Oct 2014 15:20:42 +0100
changeset 238d33edf5c2717
parent 237 63f6861d0ad9
child 239 bfac95f9ac41
child 244 9a094a081c90
modified start_browsing script to use the proxy settings
OpenSecurity/bin/opensecurity_tray.pyw
OpenSecurity/bin/start_browsing.pyw
OpenSecurity/bin/vmmanager.pyw
     1.1 --- a/OpenSecurity/bin/opensecurity_tray.pyw	Wed Oct 22 18:36:04 2014 +0200
     1.2 +++ b/OpenSecurity/bin/opensecurity_tray.pyw	Tue Oct 28 15:20:42 2014 +0100
     1.3 @@ -143,7 +143,7 @@
     1.4  
     1.5      def clicked_exit(self):
     1.6          """clicked exit"""
     1.7 -        opensecurity_client_restful_server.stop()
     1.8 +        #opensecurity_client_restful_server.stop()
     1.9          sys.exit(0)
    1.10      
    1.11  
     2.1 --- a/OpenSecurity/bin/start_browsing.pyw	Wed Oct 22 18:36:04 2014 +0200
     2.2 +++ b/OpenSecurity/bin/start_browsing.pyw	Tue Oct 28 15:20:42 2014 +0100
     2.3 @@ -38,6 +38,7 @@
     2.4  
     2.5  # local
     2.6  import __init__ as opensecurity
     2.7 +import proxy_getter
     2.8  
     2.9  if sys.platform == 'win32' or sys.platform == 'cygwin':
    2.10      from cygwin import Cygwin
    2.11 @@ -51,17 +52,25 @@
    2.12  if __name__ == "__main__":
    2.13  
    2.14      if not (sys.platform == 'win32' or sys.platform == 'cygwin'):
    2.15 -        QtGui.QMessageBox.critical(self.parent(), 'OpenSecurity Error', 'This action is not supported on this platform.\nSorry.')
    2.16 +        QtGui.QMessageBox.critical(None, 'OpenSecurity Error', 'This action is not supported on this platform.\nSorry.')
    2.17          sys.exit(1)
    2.18     
    2.19      try:
    2.20      
    2.21          # get a proper browsing VM
    2.22          Cygwin.start_X11()
    2.23 +        
    2.24 +        proxy_support = urllib2.ProxyHandler({})
    2.25 +        opener = urllib2.build_opener(proxy_support)
    2.26 +        urllib2.install_opener(opener)
    2.27  
    2.28 -        # TODO: HARDCODED ADDRESS OF OPENSECURITYD
    2.29 -        browsing_vm = urllib2.urlopen('http://127.0.0.1:8080/browsing').readline()
    2.30 -        print('Called http://127.0.0.1:8080/browsing got: ' + str(browsing_vm))
    2.31 +        req_data = ""
    2.32 +        proxy = proxy_getter.getProxySettings()
    2.33 +        if proxy:
    2.34 +            req_data = '?' + urllib.urlencode(proxy) 
    2.35 +        req = 'http://127.0.0.1:8080/browsing'+ req_data
    2.36 +        browsing_vm = urllib2.urlopen(req).readline()
    2.37 +        print('Called '+ req + ' got: ' + str(browsing_vm))
    2.38          
    2.39      except:
    2.40          
     3.1 --- a/OpenSecurity/bin/vmmanager.pyw	Wed Oct 22 18:36:04 2014 +0200
     3.2 +++ b/OpenSecurity/bin/vmmanager.pyw	Tue Oct 28 15:20:42 2014 +0100
     3.3 @@ -1051,8 +1051,6 @@
     3.4      def run(self):
     3.5          session = None
     3.6          try:
     3.7 -            #appDataDir = self.getAppDataDir()
     3.8 -
     3.9              session = self.vmm.getSession()
    3.10              if not session:
    3.11                  raise OpenSecurityException("Could not get new SDVM session.")
    3.12 @@ -1063,16 +1061,6 @@
    3.13              self.net_resource = '\\\\' + self.ip_addr + '\\Download'
    3.14              urllib2.urlopen('http://127.0.0.1:8090/netmount?'+'net_resource='+self.net_resource)#.readline()
    3.15              
    3.16 -            #logger.info("Restoring browser settings in AppData dir " + appDataDir)
    3.17 -            # create OpenSecurity settings dir on local machine user home /AppData/Roaming 
    3.18 -            #Cygwin.bashExecute('/usr/bin/mkdir -p \\\"' + appDataDir + '/OpenSecurity\\\"')
    3.19 -            # create chromium settings dir on local machine if not existing
    3.20 -            #Cygwin.bashExecute('/usr/bin/mkdir -p \\\"' + appDataDir + '/OpenSecurity/chromium\\\"')
    3.21 -            # create chromium settings dir on remote machine if not existing
    3.22 -            #Cygwin.sshExecute('"mkdir -p \\\"/home/osecuser/.config\\\""', self.ip_addr, 'osecuser', Cygwin.cygPath(self.vmm.getMachineFolder()) + '/' + self.vm_name + '/dvm_key')
    3.23 -            #restore settings on vm
    3.24 -            #self.restoreFile(appDataDir + '/OpenSecurity/chromium', '/home/osecuser/.config/')
    3.25 -                    
    3.26              if self.wpad:
    3.27                  browser = '\\\"/usr/bin/chromium --proxy-pac-url=\\\"'+self.wpad+'\\\"\\\"'
    3.28              elif self.proxy: