mirror of
https://gitea.invidious.io/iv-org/Invidious-quic-proxy.git
synced 2024-08-15 00:43:22 +00:00
Make amount of open connections configurable
This commit is contained in:
parent
43957e90ec
commit
5180aa1192
2 changed files with 7 additions and 3 deletions
|
@ -15,6 +15,10 @@ Will use HTTP/3 to query the specified URL with the specified data, method and h
|
||||||
The port and address can be changed in config.toml, located in the default OS config location.
|
The port and address can be changed in config.toml, located in the default OS config location.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
|
# Host address to bind to
|
||||||
host = "0.0.0.0"
|
host = "0.0.0.0"
|
||||||
|
# Port to listen on
|
||||||
port = 7192
|
port = 7192
|
||||||
|
# Amount of workers to process quic requests
|
||||||
|
open_connections = 5
|
||||||
```
|
```
|
||||||
|
|
6
main.py
6
main.py
|
@ -24,7 +24,7 @@ CONFIG_FILE.touch(exist_ok=True)
|
||||||
with open(f"{CONFIG_FILE}") as config:
|
with open(f"{CONFIG_FILE}") as config:
|
||||||
config = pytomlpp.loads(config.read())
|
config = pytomlpp.loads(config.read())
|
||||||
if not config:
|
if not config:
|
||||||
config = {"port": 7192, "host": "0.0.0.0"}
|
config = {"port": 7192, "host": "0.0.0.0", "open_connections": 5}
|
||||||
routes = web.RouteTableDef()
|
routes = web.RouteTableDef()
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ async def post(request):
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
asyncio.create_task(request_processor.request_worker())
|
[asyncio.create_task(request_processor.request_worker()) for _ in range(config.get("open_connections", 5))]
|
||||||
app = web.Application()
|
app = web.Application()
|
||||||
app.add_routes(routes)
|
app.add_routes(routes)
|
||||||
return app
|
return app
|
||||||
|
@ -61,4 +61,4 @@ async def main():
|
||||||
request_processor = quicclient.RequestProcessor()
|
request_processor = quicclient.RequestProcessor()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
web.run_app(main(), **config)
|
web.run_app(main(), port=config.get("port", 7912), host=config.get("host", "0.0.0.0"))
|
||||||
|
|
Loading…
Reference in a new issue