feat(tunnel): free finished tunnels at once and wait out 429s on --remote

A tunnel closed with code 1000 is freed without the 60s grace, a shared: true API key counts tunnels per X-Client-Id, and --remote waits out Retry-After and a full tunnel cap with a countdown; responses carry X-RateLimit-* headers.
This commit is contained in:
imSp4rky
2026-11-09 15:43:33 -07:00
parent 4b6d15cc2a
commit b10fd2d3a4
13 changed files with 358 additions and 25 deletions
+6 -2
View File
@@ -2074,7 +2074,9 @@ async def tunnel(request: web.Request) -> web.StreamResponse:
description: >-
A WebSocket that a --remote client holds open. The server sends the requests of a remote session
created with proxy tunnel:<id> through it, and the client makes them from its own connection.
The first message is {"id": <tunnel id>}.
The first message is {"id": <tunnel id>}. A client that has finished closes with code 1000,
which frees the tunnel at once; after any other close the tunnel waits 60 seconds for a reconnect.
An API key with shared: true counts its tunnels for each X-Client-Id value, which its gateway sets.
parameters:
- name: id
in: query
@@ -2088,7 +2090,9 @@ async def tunnel(request: web.Request) -> web.StreamResponse:
'404':
description: No open tunnel with this id for this API key
'429':
description: The API key has the maximum number of tunnels open
description: >-
The API key has the maximum number of tunnels open, or, with a Retry-After header,
the API key is over its hourly request limit
"""
return await tunnel_handler(request)