Expand description
Network utilities — SSRF protection, HTTP client helpers.
Re-exports§
pub use reqwest;
Structs§
- Egress
- Where a request for
urlreally goes, and what it carries: the proxy’s address with a signed authorization when the privacy setting routes it through Magnitude, or the URL itself.
Constants§
- TRANSFER_
STALL - How long a transfer may go without moving a byte before it is given up on.
Functions§
- build_
http_ client - Build an HTTP client with the given total timeout.
- build_
http_ client_ with_ options - egress
- Resolve the destination for
url. Every outbound fetch of somebody else’s content asks here first, so the setting has exactly one place to act. - get_
remote_ file_ size - Get the size of a remote file via HEAD request or Range fallback. Returns None if the URL is private, unreachable, or size can’t be determined.
- proxied_
request - A request for
urlonclient, already pointed at the right place and carrying the proxy authorization when there is one. - raise_
fd_ limit - Lift the open-file ceiling to what the OS allows.
- rebuild_
shared_ http_ client - Rebuild the shared client. Call this when Tor state flips so the next request goes through the freshly-configured proxy. In-flight requests on the old client continue to completion on the previous Arc.
- remote_
status - The HTTP status the SOURCE gives for
url: 2xx means it serves, 404/410 means it is gone.Nonemeans nothing definitive could be learned (the host, or the proxy, was unreachable). Through the proxy a HEAD carries no body, so one byte is asked for instead and the source’s status read from the proxy’s answer; direct, a HEAD is tried first and a one-byte GET when the host refuses HEAD. - set_
app_ version - Name the app’s version in the user agent. Call once at startup; a second call is ignored.
- shared_
http_ client - Get a shared HTTP client. Cheap clone (Arc), proxy-aware, picks up Tor
toggles on the next call after
rebuild_shared_http_client()runs. - strip_
md_ link_ claims - Rewrite markdown links so a preview-URL scan sees only real DESTINATIONS:
[text](href)keeps the href and drops the display text — a URL claimed in the text must never win the OG preview over where the link actually goes —[text](<href>)drops entirely (angle brackets are the no-preview syntax), and[text][ref]drops the label (its destination is a definition scanned on its own elsewhere in the text). Images () render as literal text in chat, so they pass through untouched. - user_
agent - validate_
url_ not_ private - Reject URLs that resolve to private/loopback/link-local addresses (SSRF protection).