Expand description
Per-domain network policy for outbound network calls (#135).
Three small pieces:
Decision—Allow | Deny | Prompt.NetworkPolicy— a list of allow/deny hostnames + a default decision, with deny-wins precedence: a host that matches an entry indenyis denied even if it also matchesallow.NetworkAuditor— appends one plaintext line per outbound call to~/.deepseek/audit.login the format described below.
In addition, NetworkSessionCache holds in-process “approve once for
this session” state for the Prompt flow, and NetworkDenied is the
structured error surfaced to callers when a host is blocked.
§Host-matching rules
- Exact match — an entry like
api.deepseek.commatches only the hostapi.deepseek.com(case-insensitive). - Subdomain match — an entry that starts with a leading dot, e.g.
.example.com, matches any subdomain (api.example.com,a.b.example.com) but not the apexexample.com. To match both, list both.
Matching is case-insensitive and trims a single trailing dot from the host
(so example.com. and example.com are equivalent).
§Audit-log format
<RFC3339-timestamp> network <host> <tool> <Allow|Deny|Prompt-Approved|Prompt-Denied>Plaintext, one line per call, appended to <audit_path> (defaults to
~/.deepseek/audit.log). Best-effort: write failures are logged but do
not block the call.
Structs§
- Network
Auditor - Best-effort writer for the network audit log.
- Network
Denied - Structured error surfaced to callers when an outbound call is blocked.
- Network
Policy - Per-domain allow/deny list with a default fallback.
- Network
Policy Decider - Glue type that bundles a
NetworkPolicywith a session cache and an auditor. Tools callNetworkPolicyDecider::evaluatebefore any HTTP transport is constructed; the result decides whether to proceed, deny, or prompt the user. - Network
Session Cache - In-process cache of “approve once for this session” decisions. Keyed by normalized host. Thread-safe.
Enums§
- Decision
- What the policy decided about an outbound network call.
- Decision
Toml - Wire-format wrapper for
Decisionused in serde-derived TOML/JSON. The runtime API exposesDecisiondirectly; this type only exists sodefault = "prompt"round-trips cleanly through TOML.
Functions§
- host_
from_ url - Extract the host portion of a URL, lowercased. Returns
Noneif the URL can’t be parsed or has no host.