mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-10 06:32:17 +03:00
changed proxy protocol
This commit is contained in:
parent
f029e916ef
commit
bb4ba8fb75
1 changed files with 36 additions and 19 deletions
|
@ -19,7 +19,7 @@ class BrowserChrome(AbstractPlugin):
|
||||||
self.local_settings_path = '/etc/opt/chrome/'
|
self.local_settings_path = '/etc/opt/chrome/'
|
||||||
self.local_settings_proxy_profile = '/etc/profile.d/'
|
self.local_settings_proxy_profile = '/etc/profile.d/'
|
||||||
self.local_settings_proxy_file = 'liderahenk_chrome_proxy.sh'
|
self.local_settings_proxy_file = 'liderahenk_chrome_proxy.sh'
|
||||||
self.user_js_file = 'liderahenk_browser_chrome_preferences.json'
|
self.user_js_file = "liderahenk_browser_chrome_preferences.json"
|
||||||
|
|
||||||
self.logger.info('Parameters were initialized.')
|
self.logger.info('Parameters were initialized.')
|
||||||
|
|
||||||
|
@ -83,34 +83,51 @@ class BrowserChrome(AbstractPlugin):
|
||||||
|
|
||||||
|
|
||||||
def write_to_chrome_proxy(self):
|
def write_to_chrome_proxy(self):
|
||||||
proxy_full_path = self.local_settings_proxy_profile + self.local_settings_proxy_file
|
proxy_type = "0"
|
||||||
self.silent_remove(proxy_full_path)
|
|
||||||
self.create_file(proxy_full_path)
|
|
||||||
proxy_preferences = json.loads(self.data)
|
proxy_preferences = json.loads(self.data)
|
||||||
line = ""
|
username = self.get_username()
|
||||||
if len(proxy_preferences) > 0:
|
if len(proxy_preferences) > 0:
|
||||||
proxy_data = proxy_preferences["proxyListChrome"]
|
proxy_data = proxy_preferences["proxyListChrome"]
|
||||||
if proxy_data[0].get('value') == '0' :
|
self.logger.debug(proxy_data)
|
||||||
line = proxy_data[1].get('preferenceName')
|
|
||||||
|
|
||||||
elif proxy_data[0].get('value') == '1':
|
for pref in proxy_data:
|
||||||
for proxy in proxy_data[1:5]:
|
if pref["preferenceName"] == "type":
|
||||||
line += str(proxy['preferenceName'] + "\n")
|
proxy_type = pref['value']
|
||||||
|
|
||||||
elif proxy_data[0].get('value') == '2':
|
if proxy_type == '0':
|
||||||
line = proxy_data[1].get('preferenceName')
|
self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy mode 'none''".format(username))
|
||||||
|
#self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy mode 'none''".format("ebru_chrome"))
|
||||||
|
elif proxy_type == '1':
|
||||||
|
self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy mode 'manual''".format(username))
|
||||||
|
for pref in proxy_data:
|
||||||
|
if pref["preferenceName"] == "httpHost":
|
||||||
|
self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy.http host '{1}''".format(username,str(pref['value'])))
|
||||||
|
if pref["preferenceName"] == "httpPort":
|
||||||
|
self.execute("su - {0} -c ' gsettings set org.gnome.system.proxy.http port '{1}''".format(username,str(pref['value'])))
|
||||||
|
if pref["preferenceName"] == "httpsHost":
|
||||||
|
self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy.https host '{1}''".format(username,str(pref['value'])))
|
||||||
|
if pref["preferenceName"] == "httpsPort":
|
||||||
|
self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy.https port '{1}''".format(username,str(pref['value'])))
|
||||||
|
if pref["preferenceName"] == "ftpHost":
|
||||||
|
self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy.ftp host '{1}''".format(username,str(pref['value'])))
|
||||||
|
if pref["preferenceName"] == "ftpPort":
|
||||||
|
self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy.ftp port '{1}''".format(username,str(pref['value'])))
|
||||||
|
if pref["preferenceName"] == "socksHost":
|
||||||
|
self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy.socks port '{1}''".format(username,str(pref['value'])))
|
||||||
|
if pref["preferenceName"] == "socksPort":
|
||||||
|
self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy.socks port '{1}''".format(username,str(pref['value'])))
|
||||||
|
elif proxy_type == '2':
|
||||||
|
self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy mode 'auto''".format(username))
|
||||||
|
self.execute("su - {0} -c 'gsettings set org.gnome.system.proxy autoconfig-url '{1}''".format(username,str(pref['value'])))
|
||||||
|
|
||||||
self.write_file(proxy_full_path, line)
|
|
||||||
self.make_executable(proxy_full_path)
|
|
||||||
self.execute_script(proxy_full_path)
|
|
||||||
else:
|
else:
|
||||||
self.logger.debug("Proxy preferences files is empty!!")
|
self.logger.debug("Proxy preferences files is empty!!")
|
||||||
# subprocess.Popen('sudo chmod +x {0}'.format(proxy_sh), shell=True)
|
|
||||||
self.logger.debug('User proxy preferences were wrote successfully')
|
self.logger.debug('User proxy preferences were wrote successfully')
|
||||||
|
|
||||||
|
|
||||||
#sudo chmod +x /etc/profile.d/proxy.sh
|
#sudo chmod +x /etc/profile.d/proxy.sh
|
||||||
|
|
||||||
def handle_policy(profile_data, context):
|
def handle_policy(profile_data, context):
|
||||||
browser = BrowserChrome(profile_data, context)
|
browser = BrowserChrome(profile_data, context)
|
||||||
browser.handle_policy()
|
browser.handle_policy()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue