From 65ff21f4e17fa46e75d891e7acf1ab1a6e2cbe26 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 1 Aug 2015 10:50:14 -0700 Subject: [PATCH] Only serve proxy.pac when hostname is localhost. --- tools/proxy.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/proxy.py b/tools/proxy.py index 017217de9..a846af445 100755 --- a/tools/proxy.py +++ b/tools/proxy.py @@ -14,12 +14,15 @@ class ExtensionReplacer(http.server.BaseHTTPRequestHandler): self.do_GET() def do_GET(self): - if self.path == '/proxy.pac': - self.send_response(200, 'OK') - self.send_header('Content-Length', len(proxyConfig)) - self.end_headers() - if self.command != 'HEAD': - self.wfile.write(proxyConfig) + if self.headers.get('Host', '').split(':')[0] == 'localhost': + if self.path == '/proxy.pac': + self.send_response(200) + self.send_header('Content-Length', len(proxyConfig)) + self.end_headers() + if self.command != 'HEAD': + self.wfile.write(proxyConfig) + else: + self.send_error(404) else: del self.headers['Accept-Encoding'] conn = http.client.HTTPConnection('boards.4chan.org')