internal
Endpoints used only by Caddy's forward_auth.
Caddy refuses /internal/* from clients; these handlers are reached only
through the sub-request Caddy makes to 127.0.0.1, which carries the
proxy's secret. The API port itself is bound on every interface, so
through_proxy refuses whatever else reaches them.
attributelogger= logging.getLogger(__name__)attributerouter= APIRouter(prefix='/internal', include_in_schema=False, dependencies=[Depends(through_proxy)])attributeSTOPPED_PAGE= '<!doctype html><meta charset="utf-8"><title>SealSkin</title><p>{}</p><script>close()</script>'functhrough_proxy(request) -> NoneRefuse a request that did not come through this node's Caddy, whose forward_auth sub-requests carry its secret.
The address is no guide: uvicorn takes the browser's from the
X-Forwarded-For the sub-request carries.
paramrequestRequestReturns
Nonefuncstopped_page(accept_language) -> HTMLResponseThe page a stopped session's tab loads next, which closes the tab.
A session page reloads to reconnect once its session ends, and lands here. A browser lets a tab that a script opened close itself, which the web app cannot do for a tab whose handle it lost (WebKit severs every tab its page opens) or whose origin differs from its own after giving it no opener (Chrome on a session's own origin). A tab that may not close itself shows the launcher's line for a stopped session, in the first language the browser accepts that the UI carries.
paramaccept_languagestrReturns
fastapi.responses.HTMLResponsefunc_peer_upstream(session_id, request) -> str | NoneReturn the peer listener of the node that runs a session this node does not.
Only a frontend proxies to another node, and never a request that already came over the peer listener, so no request is passed on twice.
paramsession_idstrparamrequestRequestReturns
str | Nonefuncroute(session_id, request) -> ResponseTell Caddy whether a request for a session belongs to another node.
paramsession_idstrparamrequestRequestReturns
fastapi.ResponseAn empty 200 response, with X-Upstream-Peer when another node runs
funcresolve_session(session_id, request) -> ResponseAuthorise a proxied request and tell Caddy where to send it.
paramsession_idstrparamrequestRequestReturns
fastapi.ResponseAn empty 200 response with X-Upstream-Host and X-Upstream-Auth,