From 3d26ac275fec7473bf40a4685117d1a9044fb8b9 Mon Sep 17 00:00:00 2001 From: dl8tu Date: Sun, 14 Mar 2021 11:42:29 +0100 Subject: [PATCH 1/2] added some code to be able to use ssl --- logtailer.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/logtailer.py b/logtailer.py index c211aee..42ad9cf 100644 --- a/logtailer.py +++ b/logtailer.py @@ -15,6 +15,7 @@ from urllib.parse import urlparse, parse_qs from ansi2html import Ansi2HTMLConverter from os import popen import psutil +import ssl import functools from http import HTTPStatus import subprocess @@ -332,11 +333,18 @@ def log_close(websocket, path, exception=None): 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_forever() - def main(): dmr_id_lookup = config['MMDVMHost']['DMR_ID_Lookup'] dmr_id_lookupfile = config['MMDVMHost']['DMR_ID_LookupFile'] From dececd9372d6b0ac2e2e2592481dd0cc9b4467c4 Mon Sep 17 00:00:00 2001 From: dl8tu Date: Sun, 14 Mar 2021 11:47:43 +0100 Subject: [PATCH 2/2] added config settings for ssl --- logtailer.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/logtailer.ini b/logtailer.ini index c5702b4..216238a 100644 --- a/logtailer.ini +++ b/logtailer.ini @@ -7,6 +7,11 @@ Host=0.0.0.0 # new WebSocket("ws://" + window.location.hostname ... Port=5678 +# set to True if SSL will be used +Ssl=False +SslCert=/path/to/cert +SslKey=/path/to/keyfile + # This defines the maximum amount of loglines to be sent on initial opening of the dashboard MaxLines=500