From 4eb28dbd40a022557a469778c863d7de9032449c Mon Sep 17 00:00:00 2001 From: xyuanmu Date: Fri, 25 Mar 2016 10:14:51 +0800 Subject: [PATCH] release v1.2.2 --- lib/pac_server.py | 8 ++++---- lib/simple_http_server.py | 7 ++----- proxy.py | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/pac_server.py b/lib/pac_server.py index 1e22c98..68e66db 100644 --- a/lib/pac_server.py +++ b/lib/pac_server.py @@ -361,7 +361,7 @@ def do_CONNECT(self): self.wfile.write(b'HTTP/1.1 403\r\nConnection: close\r\n\r\n') def do_GET(self): - xlog.info('PAC from:%s %s %s ', self.address_string(), self.command, self.path) + xlog.info('PACServer from:%s %s %s ', self.address_string(), self.command, self.path) path = urlparse.urlparse(self.path).path # '/proxy.pac' filename = os.path.normpath('./' + path).lower() # proxy.pac @@ -389,9 +389,9 @@ def do_GET(self): data = open(cer_filename, 'rb').read() else: return - self.wfile.write(('HTTP/1.1 200\r\nContent-Disposition: attachment; filename=CA.crt\r\nContent-Type: %s\r\nContent-Length: %s\r\n\r\n' % (mimetype, len(data))).encode()) + self.wfile.write(('HTTP/1.1 200\r\nContent-Disposition: inline; filename=CA.crt\r\nContent-Type: %s\r\nContent-Length: %s\r\n\r\n' % (mimetype, len(data))).encode()) self.wfile.write(data) else: - xlog.warn("pac_server GET %s fail", filename) - return self.wfile.write(('HTTP/1.1 301\r\nContent-Length: 0\r\n\r\n').encode()) + xlog.warn("PACServer GET %s fail", filename) + return self.wfile.write(('HTTP/1.1 404\r\nContent-Length: 0\r\n\r\n').encode()) diff --git a/lib/simple_http_server.py b/lib/simple_http_server.py index d48183b..6352ff4 100644 --- a/lib/simple_http_server.py +++ b/lib/simple_http_server.py @@ -10,7 +10,6 @@ import time import json import base64 -from config import config import xlog @@ -26,7 +25,7 @@ def filter(self, handler): class AuthFilter(BaseProxyHandlerFilter): """authorization filter""" auth_info = "Proxy authentication required" - white_list = ['127.0.0.1', '%s' % config.get_listen_ip()] + white_list = ['127.0.0.1'] def __init__(self, username, password): self.username = username @@ -41,9 +40,7 @@ def check_auth_header(self, auth_header): return False def filter(self, handler): - addr = handler.client_address[0] - host = handler.headers.get('Host').partition(':')[0] if handler.headers.get('Host') else '' - if addr in self.white_list or host in self.white_list: + if handler.client_address[0] in self.white_list: return None auth_header = handler.headers.get('Proxy-Authorization') or getattr(handler, 'auth_header', None) if auth_header and self.check_auth_header(auth_header): diff --git a/proxy.py b/proxy.py index 538a43e..25256d6 100644 --- a/proxy.py +++ b/proxy.py @@ -33,7 +33,7 @@ # cnfuyu # cuixin -__version__ = '1.2.1' +__version__ = '1.2.2' import sys import os