From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter =?utf-8?q?M=C3=BCller?= To: development@lists.ipfire.org Subject: Re: [PATCH v3] fireinfo: support upstream proxy with authentication Date: Mon, 10 Dec 2018 16:29:51 +0100 Message-ID: <2a086efa-013f-6a45-0641-7f0a89dd4493@link38.eu> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1658615842861994882==" List-Id: --===============1658615842861994882== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello Michael, is there any chance to get this into upcoming Core Update 126? Thanks, and best regards, Peter M=C3=BCller Am 04.12.18 um 18:13 schrieb Peter M=C3=BCller: > Fireinfo could not send its profile to https://fireinfo.ipfire.org/ > if the machine is behind an upstream proxy which requires username > and password. This is fixed by tweaking urllib2's opening handler. >=20 > To apply this on existing installations, the fireinfo package > needs to be shipped during an update. >=20 > The third version of this patch fixes bogus indention, assembles > proxy authentication string more readable and preserves HTTP > proxy handler. >=20 > Fixes #11905 >=20 > Signed-off-by: Peter M=C3=BCller > Cc: Michael Tremer > --- > src/sendprofile | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > mode change 100644 =3D> 100755 src/sendprofile >=20 > diff --git a/src/sendprofile b/src/sendprofile > old mode 100644 > new mode 100755 > index b836567..3ce68b9 > --- a/src/sendprofile > +++ b/src/sendprofile > @@ -73,10 +73,20 @@ def send_profile(profile): > request.add_header("User-Agent", "fireinfo/%s" % fireinfo.__version__) > =20 > # Set upstream proxy if we have one. > - # XXX this cannot handle authentication > proxy =3D get_upstream_proxy() > + > if proxy["host"]: > - request.set_proxy(proxy["host"], "http") > + # handling upstream proxies with authentication is more tricky... > + if proxy["user"] and proxy["pass"]: > + prx_auth_string =3D "http://%s:%s@%s/" % (proxy["user"], proxy["pass"],= proxy["host"]) > + > + proxy_handler =3D urllib2.ProxyHandler({'http': prx_auth_string, 'https= ': prx_auth_string}) > + auth =3D urllib2.HTTPBasicAuthHandler() > + opener =3D urllib2.build_opener(proxy_handler, auth, urllib2.HTTPHandle= r) > + urllib2.install_opener(opener) > + else: > + request.set_proxy(proxy["host"], "http") > + request.set_proxy(proxy["host"], "https") > =20 > try: > urllib2.urlopen(request, timeout=3D60) >=20 --=20 Microsoft DNS service terminates abnormally when it recieves a response to a DNS query that was never made. Fix Information: Run your DNS service on a different platform. -- bugtraq --===============1658615842861994882==--