Skip to main content

Module net

Module net 

Source
Expand description

Network utilities — SSRF protection, HTTP client helpers.

Re-exports§

pub use crate::transport::Lane;
pub use reqwest;

Structs§

Egress
Where a request for url really 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.
HttpClient
Req
A request being built. Forwards the builder methods call sites use.
Resp
A response whose body reads stop when the network it came over changes.

Enums§

HttpError

Constants§

TRANSFER_STALL
How long a transfer may go without moving a byte before it is given up on.

Functions§

build_http_client
A client with the given total timeout, for content anyone can name.
build_http_client_for
A client for lane: Account for requests that identify as the user (signed uploads).
build_http_client_with_options
Like build_http_client, with the total timeout optional and redirect-following switchable.
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.
forget_clients
Drop every pooled client: the next request builds one for the current egress.
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.
guard_body
Upload bodies: ends the stream with an error when the epoch or live session changes.
proxied_request
A request for url on client, 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
Kept for callers that rebuilt the shared client on a Tor flip; clients are per request now.
remote_status
The HTTP status the SOURCE gives for url: 2xx means it serves, 404/410 means it is gone. None means 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
A 30 s client for frequent small fetches (image cache, wallet polling).
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 (![alt](url)) render as literal text in chat, so they pass through untouched.
tor_http_timeout
An HTTP budget (a request total, a read) for the transport in use: a circuit to a fresh host alone can take 45 s. Clearnet passes through.
transfer_stall
TRANSFER_STALL for the transport in use.
user_agent
validate_url_not_private
Reject URLs that resolve to private/loopback/link-local addresses (SSRF protection).
wait_after
Hold a transfer that hit a network change until the network is back, then let it resume. Policy refusals and other failures return at once with their text.

Type Aliases§

BodyStream
A response body as a stream; Send natively, where the browser’s isn’t.