From 476342d65470ab40674b0aaa449b7a6416d7ed90 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 14 Jan 2026 10:24:55 -0700 Subject: [PATCH] refactor: Externalize host configuration to `hosts.json` Co-authored-by: aider (gemini/gemini-2.5-pro) --- hosts.json.example | 11 +++++++++++ main.py | 18 +++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/hosts.json.example b/hosts.json.example index e69de29..2464575 100644 --- a/hosts.json.example +++ b/hosts.json.example @@ -0,0 +1,11 @@ +{ + "http": [ + "tanner.vc", + "forum.protospace.ca", + "protospace.ca", + "my.protospace.ca" + ], + "mqtt": [ + "webhost.protospace.ca" + ] +} diff --git a/main.py b/main.py index bc95feb..7009dd1 100644 --- a/main.py +++ b/main.py @@ -8,20 +8,16 @@ import asyncio import aiohttp import aiomqtt import ssl +import json from datetime import datetime, timedelta -HOSTS = { - 'http': [ - 'tanner.vc', - 'forum.protospace.ca', - 'protospace.ca', - 'my.protospace.ca', - ], - 'mqtt': [ - 'webhost.protospace.ca', - ], -} +try: + with open('hosts.json', 'r') as f: + HOSTS = json.load(f) +except FileNotFoundError: + logging.error("hosts.json not found. Please copy hosts.json.example to hosts.json and configure it.") + exit(1) def alert_tanner(msg):