Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

Commit

Permalink
release v1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xyuanmu committed Mar 25, 2016
1 parent 909e7dc commit 4eb28db
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/pac_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())

7 changes: 2 additions & 5 deletions lib/simple_http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import time
import json
import base64
from config import config


import xlog
Expand All @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# cnfuyu <cnfuyu@gmail.com>
# cuixin <steven.cuixin@gmail.com>

__version__ = '1.2.1'
__version__ = '1.2.2'

import sys
import os
Expand Down

0 comments on commit 4eb28db

Please sign in to comment.