add cursed TLS to enable crypto.subtle, thx webkit

This commit is contained in:
ed
2019-06-25 21:01:00 +00:00
parent fe83994dc6
commit 9fcd4823b5
8 changed files with 156 additions and 10 deletions

View File

@@ -2,9 +2,11 @@
# coding: utf-8
from __future__ import print_function, unicode_literals
import os
import time
import threading
from .__init__ import E
from .httpconn import HttpConn
from .authsrv import AuthSrv
@@ -27,6 +29,12 @@ class HttpSrv(object):
self.workload_thr_alive = False
self.auth = AuthSrv(args, log_func)
cert_path = os.path.join(E.cfg, "cert.pem")
if os.path.exists(cert_path):
self.cert_path = cert_path
else:
self.cert_path = None
def accept(self, sck, addr):
"""takes an incoming tcp connection and creates a thread to handle it"""
thr = threading.Thread(target=self.thr_client, args=(sck, addr, self.log))
@@ -42,7 +50,7 @@ class HttpSrv(object):
def thr_client(self, sck, addr, log):
"""thread managing one tcp client"""
cli = HttpConn(sck, addr, self.args, self.auth, log)
cli = HttpConn(sck, addr, self.args, self.auth, log, self.cert_path)
with self.mutex:
self.clients[cli] = 0
self.workload += 50
@@ -57,6 +65,7 @@ class HttpSrv(object):
cli.run()
finally:
sck.close()
with self.mutex:
del self.clients[cli]