Sanitize hostname by replacing illegal topic characters (#105)

Co-authored-by: Ahti Liin <ahti@mooncascade.com>
This commit is contained in:
Ahti Liin
2024-05-07 19:45:45 +03:00
committed by GitHub
parent 1a9fe58f6f
commit 5fe5d2a1c9

View File

@@ -690,7 +690,8 @@ exit_flag = False
stop_event = threading.Event()
script_dir = os.path.dirname(os.path.realpath(__file__))
# get device host name - used in mqtt topic
hostname = socket.gethostname()
# and adhere to the allowed character set
hostname = re.sub(r'[^a-zA-Z0-9_-]', '_', socket.gethostname())
if __name__ == '__main__':
args = parse_arguments();