Allow binding more that one address.

This commit is contained in:
Jason Michalski
2024-05-17 21:55:54 -07:00
parent c74138a8c5
commit cf1f40ff98
3 changed files with 7 additions and 4 deletions

View File

@@ -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')

View File

@@ -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()

View File

@@ -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