From cf1f40ff98074d185b69e868869bd8c916682ead Mon Sep 17 00:00:00 2001 From: Jason Michalski Date: Fri, 17 May 2024 21:55:54 -0700 Subject: [PATCH] Allow binding more that one address. --- main.py | 2 +- meshview/http.py | 3 ++- meshview/web.py | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 3cef427..5d4ab32 100644 --- a/main.py +++ b/main.py @@ -27,7 +27,7 @@ async def main(args): if __name__ == '__main__': parser = argparse.ArgumentParser('meshview') - parser.add_argument('--bind', default='::1') + parser.add_argument('--bind', nargs='*', default='::1') parser.add_argument('--acme-challenge') parser.add_argument('--port', default=8080, type=int) parser.add_argument('--tls-cert') diff --git a/meshview/http.py b/meshview/http.py index e512c05..2859a59 100644 --- a/meshview/http.py +++ b/meshview/http.py @@ -18,5 +18,6 @@ async def run_server(bind, path): ) runner = web.AppRunner(app) await runner.setup() - site = web.TCPSite(runner, bind, 80) + for host in bind: + site = web.TCPSite(runner, host, 80) await site.start() diff --git a/meshview/web.py b/meshview/web.py index 2049588..fd94051 100644 --- a/meshview/web.py +++ b/meshview/web.py @@ -1,4 +1,5 @@ import asyncio + from dataclasses import dataclass import datetime from aiohttp_sse import sse_response @@ -395,8 +396,9 @@ async def run_server(bind, port, tls_cert): ssl_context.load_cert_chain(tls_cert) else: ssl_context = None - site = web.TCPSite(runner, bind, port, ssl_context=ssl_context) - await site.start() + for host in bind: + site = web.TCPSite(runner, host, port, ssl_context=ssl_context) + await site.start() while True: await asyncio.sleep(3600) # sleep forever