mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-05 15:35:06 +00:00
docs: sweep docs to zero ste_lint findings and one remote session name
This commit is contained in:
@@ -344,7 +344,7 @@ network.
|
||||
!!! note "Each request crosses the tunnel twice"
|
||||
A request from the server goes to your machine and then to the service, so it takes
|
||||
longer than a request that the server sends directly. The segments do not go through the
|
||||
tunnel: the client downloads them as before.
|
||||
tunnel: the client downloads them as it does without one.
|
||||
|
||||
A service that uses a server account does not work with `--local-proxy`, because the server
|
||||
logs in with its own account. If the tunnel drops, the client connects again, and a new request
|
||||
@@ -976,53 +976,6 @@ proxy_providers:
|
||||
|
||||
The returned proxy is HTTPS on **port 443**.
|
||||
|
||||
## Developer notes
|
||||
|
||||
!!! note "One resolution path (developers)"
|
||||
`dl`, `search`, the REST API handlers and the remote-service client all load proxy
|
||||
providers through `load_proxy_providers()` in `unshackle/core/proxies/resolve.py`.
|
||||
The REST API, its download jobs and the remote-service client call it through
|
||||
`initialize_proxy_providers()`, which leaves out Gluetun because Gluetun starts a
|
||||
local Docker container. All paths read a value through `resolve_proxy_value()`, which
|
||||
returns the proxy URI with the proxy provider, the query and the log line: a
|
||||
`controld://` resolver, a `provider:query` or a bare query tried against providers in
|
||||
order, or else an explicit proxy URI or `host:port`.
|
||||
|
||||
The remote-service client resolves `--proxy` with its own
|
||||
`resolve_remote_proxy_arg()`. It changes a `controld:` query to a `controld://`
|
||||
resolver for the server with `get_remote_proxy()`, and it removes Control D from a bare
|
||||
query, because a loopback forwarder is of no use to a server on another machine.
|
||||
|
||||
!!! note "Keeping service requests on the proxy (developers)"
|
||||
`unshackle/core/utils/run_proxy.py` holds the proxy rules for service traffic:
|
||||
|
||||
- `pin(session)` stops environment and system proxies from overriding the proxy of a
|
||||
requests HTTP session, and keeps the environment CA bundle. Call it on each requests
|
||||
HTTP session that gets a proxy.
|
||||
- `fallback_session()` gives a core helper with no HTTP session (a manifest parser, a DRM
|
||||
class) a session on the proxy of the service that called it.
|
||||
- An audit hook on `socket.getaddrinfo` and on `socket.connect` to a host name, and a
|
||||
check in `RnetSession.request`, warn about requests from service code that do not use
|
||||
the proxy. A service sets
|
||||
`proxy_exempt = True` on an HTTP session that goes direct on purpose.
|
||||
|
||||
!!! note "Implementing a new provider (developers)"
|
||||
Every proxy provider subclasses `unshackle.core.proxies.proxy.Proxy` and has three
|
||||
methods:
|
||||
|
||||
- `__init__(self, **kwargs)` receives its `proxy_providers` sub-dict splatted as
|
||||
keyword arguments, so YAML keys map 1:1 to constructor parameters. Check the
|
||||
configuration here, but make no request: every `dl` run builds every configured
|
||||
proxy provider, even for a run with no proxy. Read the server or location catalogue
|
||||
through a `functools.cached_property`, so the first query fetches it.
|
||||
- `__repr__(self)` is a human summary, conventionally `"{n} Countries ({m} Servers)"`.
|
||||
- `get_proxy(self, query)` returns a Requests-compatible proxy URI, or `None` only
|
||||
when the query was valid but no proxy exists. Raise on genuine errors or bad queries.
|
||||
|
||||
Optionally add `get_connection_info(query)` (as Gluetun does) or
|
||||
`last_connection_display()` (as ExpressVPN and Proton VPN do) to make `dl` print a
|
||||
friendly connection line instead of the raw proxy URL.
|
||||
|
||||
## See also
|
||||
|
||||
- [Downloading](downloading.md): the full `dl` command guide, including where proxy
|
||||
|
||||
Reference in New Issue
Block a user