Add ability to listen on Unix sockets

This commit is contained in:
syeopite 2021-06-05 09:11:01 -07:00
parent ca5627516a
commit ecdff3a8bf
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82
2 changed files with 12 additions and 2 deletions

View file

@ -22,6 +22,9 @@ The port and address can be changed in config.toml, located in the default OS co
```toml
# Host address to listen on
listen = "0.0.0.0:7192"
# It also supports UNIX Sockets!
# listen = "/tmp/quicproxysocket"
# Amount of workers to process quic requests
open_connections = 5
```

11
main.py
View file

@ -1,3 +1,4 @@
import os
import pathlib
import logging
import argparse
@ -78,6 +79,12 @@ async def main():
request_processor = quicclient.RequestProcessor()
if __name__ == '__main__':
process_cli_args()
listen_address = config.get("listen", "0.0.0.0:7912")
address, port = config.get("listen", "0.0.0.0:7912").split(":")
web.run_app(main(), port=port, host=address)
# Detect UNIX socket
# https://github.com/iv-org/invidious/pull/2111#issuecomment-846454891
if os.sep in listen_address or ":" not in listen_address:
web.run_app(main(), path=listen_address)
else:
host, port = config.get("listen", "0.0.0.0:7912").split(":")
web.run_app(main(), port=port, host=host)