1
0
Fork 0

added some code to be able to use ssl

This commit is contained in:
dl8tu 2021-03-14 11:42:29 +01:00 committed by GitHub
parent 3aec69e3e6
commit 3d26ac275f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,6 +15,7 @@ from urllib.parse import urlparse, parse_qs
from ansi2html import Ansi2HTMLConverter from ansi2html import Ansi2HTMLConverter
from os import popen from os import popen
import psutil import psutil
import ssl
import functools import functools
from http import HTTPStatus from http import HTTPStatus
import subprocess import subprocess
@ -332,11 +333,18 @@ def log_close(websocket, path, exception=None):
def websocketserver(): def websocketserver():
start_server = websockets.serve(view_log, config['DEFAULT']['Host'], config['DEFAULT']['Port']) if (config['DEFAULT']['Ssl'] == "True"):
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
cert_pem = config['DEFAULT']['SslCert']
key_pem = config['DEFAULT']['SslKey']
ssl_context.load_cert_chain(cert_pem, key_pem)
start_server = websockets.serve(view_log, config['DEFAULT']['Host'], config['DEFAULT']['Port'], ssl=ssl_context)
else:
start_server = websockets.serve(view_log, config['DEFAULT']['Host'], config['DEFAULT']['Port'])
asyncio.get_event_loop().run_until_complete(start_server) asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever() asyncio.get_event_loop().run_forever()
def main(): def main():
dmr_id_lookup = config['MMDVMHost']['DMR_ID_Lookup'] dmr_id_lookup = config['MMDVMHost']['DMR_ID_Lookup']
dmr_id_lookupfile = config['MMDVMHost']['DMR_ID_LookupFile'] dmr_id_lookupfile = config['MMDVMHost']['DMR_ID_LookupFile']