Skip to content

Commit

Permalink
gp_saml_gui.py: allow ignore system proxy settings
Browse files Browse the repository at this point in the history
Using a proxy while trying to connect to VPN can be problematic, as
proxies are usually behind the VPN.

So, add an option to disable it when opening the WebKit window.
  • Loading branch information
mchehab authored and dlenski committed May 2, 2024
1 parent fd1a3fb commit 13d373a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gp_saml_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def __init__(self, uri, html, args):
self.cookies.set_persistent_storage(args.cookies, WebKit2.CookiePersistentStorage.TEXT)
self.wview = WebKit2.WebView()

if args.no_proxy:
data_manager = self.ctx.get_website_data_manager()
data_manager.set_network_proxy_settings(WebKit2.NetworkProxyMode.NO_PROXY, None)

if args.user_agent is None:
args.user_agent = 'PAN GlobalProtect'
settings = self.wview.get_settings()
Expand Down Expand Up @@ -279,6 +283,7 @@ def parse_args(args = None):
help='Allow use of insecure renegotiation or ancient 3DES and RC4 ciphers')
p.add_argument('--user-agent', '--useragent', default='PAN GlobalProtect',
help='Use the provided string as the HTTP User-Agent header (default is %(default)r, as used by OpenConnect)')
p.add_argument('--no-proxy', action='store_true', help='Disable system proxy settings')
p.add_argument('openconnect_extra', nargs='*', help="Extra arguments to include in output OpenConnect command-line")
args = p.parse_args(args)

Expand Down Expand Up @@ -413,6 +418,8 @@ def main(args = None):
if key:
openconnect_args.insert(1, "--sslkey="+key)
openconnect_args.insert(1, "--certificate="+cert)
if args.no_proxy:
openconnect_args.insert(1, "--no-proxy")

openconnect_command = ''' echo {} |\n sudo openconnect {}'''.format(
quote(cv), " ".join(map(quote, openconnect_args)))
Expand Down

0 comments on commit 13d373a

Please sign in to comment.