This commit is contained in:
j 2017-05-30 12:51:21 +02:00
parent f811d74b5e
commit 3ecd742bd8

View file

@ -54,7 +54,7 @@ class TLSTCPServer(socketserver.TCPServer):
def __init__(self, server_address, HandlerClass, bind_and_activate=True): def __init__(self, server_address, HandlerClass, bind_and_activate=True):
socketserver.TCPServer.__init__(self, server_address, HandlerClass) socketserver.TCPServer.__init__(self, server_address, HandlerClass)
ctx = Context(TLSv1_2_METHOD) ctx = Context(TLSv1_2_METHOD)
ctx.use_privatekey_file (settings.ssl_key_path) ctx.use_privatekey_file(settings.ssl_key_path)
ctx.use_certificate_file(settings.ssl_cert_path) ctx.use_certificate_file(settings.ssl_cert_path)
# only allow clients with cert: # only allow clients with cert:
ctx.set_verify(VERIFY_PEER | VERIFY_CLIENT_ONCE | VERIFY_FAIL_IF_NO_PEER_CERT, self._accept) ctx.set_verify(VERIFY_PEER | VERIFY_CLIENT_ONCE | VERIFY_FAIL_IF_NO_PEER_CERT, self._accept)
@ -64,7 +64,7 @@ class TLSTCPServer(socketserver.TCPServer):
self.server_bind() self.server_bind()
self.server_activate() self.server_activate()
def shutdown_request(self,request): def shutdown_request(self, request):
try: try:
request.shutdown() request.shutdown()
except: except:
@ -90,7 +90,7 @@ def api_call(action, user_id, args):
else: else:
if u and u.pending: if u and u.pending:
logger.debug('ignore request from pending peer[%s] %s (%s)', logger.debug('ignore request from pending peer[%s] %s (%s)',
user_id, action, args) user_id, action, args)
content = {} content = {}
else: else:
content = None content = None
@ -109,7 +109,7 @@ class Handler(http.server.SimpleHTTPRequestHandler):
def log_message(self, format, *args): def log_message(self, format, *args):
if settings.DEBUG_HTTP: if settings.DEBUG_HTTP:
logger.debug("%s - - [%s] %s\n", self.address_string(), logger.debug("%s - - [%s] %s\n", self.address_string(),
self.log_date_time_string(), format%args) self.log_date_time_string(), format % args)
def do_HEAD(self): def do_HEAD(self):
return self.do_GET() return self.do_GET()
@ -117,7 +117,7 @@ class Handler(http.server.SimpleHTTPRequestHandler):
def do_GET(self): def do_GET(self):
import item.models import item.models
parts = self.path.split('/') parts = self.path.split('/')
if len(parts) == 3 and parts[1] in ('get', 'preview'): if len(parts) == 3 and parts[1] in ('get', 'preview'):
id = parts[2] id = parts[2]
preview = parts[1] == 'preview' preview = parts[1] == 'preview'
else: else:
@ -231,7 +231,7 @@ class Handler(http.server.SimpleHTTPRequestHandler):
state.update_required = True state.update_required = True
if self.headers.get('X-Node-Protocol', '') != settings.NODE_PROTOCOL: if self.headers.get('X-Node-Protocol', '') != settings.NODE_PROTOCOL:
logger.debug('protocol missmatch %s vs %s', logger.debug('protocol missmatch %s vs %s',
self.headers.get('X-Node-Protocol', ''), settings.NODE_PROTOCOL) self.headers.get('X-Node-Protocol', ''), settings.NODE_PROTOCOL)
logger.debug('headers %s', self.headers) logger.debug('headers %s', self.headers)
content = settings.release content = settings.release
else: else: