From 94ede80533bb1cda45c99d96fe284ae7b1e9dda7 Mon Sep 17 00:00:00 2001 From: Davide Cavarretta Date: Wed, 13 Apr 2022 16:55:41 +0200 Subject: [PATCH] Fixes schlatterbeck/snxvpn#30 Adds --useragent parameter to send User-Agent http headers request. In new web client somethink filter for User-Agent --- snxconnect.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/snxconnect.py b/snxconnect.py index d9cd5f4..0999640 100644 --- a/snxconnect.py +++ b/snxconnect.py @@ -281,7 +281,7 @@ def open (self, filepart = None, data = None, do_soup = True) : url = '/'.join (('%s:/' % self.args.protocol, self.args.host, filepart)) if data : data = data.encode ('ascii') - rq = Request (url, data) + rq = Request (url, data, headers={'User-Agent': self.args.useragent}) self.f = f = self.opener.open (rq, timeout = 10) if do_soup : # Sometimes we get incomplete read. So we read everything @@ -474,6 +474,11 @@ def main () : ' want a full path here' , default = cfg.get ('snxpath', 'snx') ) + cmd.add_argument \ + ( '-u', '--useragent' + , help = 'User-Agent to be passed to Checkpoint Portal, default="%(default)s"' + , default = cfg.get ('useragent', 'Mozilla/5.0 (X11; Linux x86_64; rv:100.0) Gecko/20100101 Firefox/100.0') + ) cmd.add_argument \ ( '-U', '--username' , help = 'Login username, default="%(default)s"'