windows: autoProxy keeps to its exclusions, and its listing to its scope

proxy.autoProxy.exclude is never probed or routed: learn and probe
requests for an excluded host are refused, and a site learned whole
(example.com) routes no excluded name under it (intranet.example.com):
the learned rule skips them.

Without the secrets scope, proxy-ctl proxy auto lists the sites routed
and counts: the hosts probed, those left to zapret and the sites behind
each strike are browsing history, as the logs are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 5.5 committed 2026-10-27 16:36:00 +03:00
1 parent 5a89b8d11d
commit 694e176353
5 files changed
+82 -12

No files matched your search

+9 -1
View File
@@ -581,7 +581,7 @@ pub async fn handle(req: Request, peer: &Peer, shared: &Shared) -> Response {
Request::AutoList => {
let s = shared.lock().await;
let exits = crate::autoproxy::exits(&s);
Response::ok(crate::autoproxy::listing(s.paths(), exits.as_ref(), &s.cfg().proxy.auto_proxy))
Response::ok(crate::autoproxy::listing(s.paths(), exits.as_ref(), &s.cfg().proxy.auto_proxy, has_secrets(s.cfg(), peer)))
}
Request::AutoProbe { target, exits, via, keep_going } => {
@@ -604,6 +604,14 @@ pub async fn handle(req: Request, peer: &Peer, shared: &Shared) -> Response {
if !bad.is_empty() {
return Response::err(format!("not host names: {}", bad.iter().map(|h| h.as_str()).collect::<Vec<_>>().join(", ")));
}
let opts = &s.cfg().proxy.auto_proxy;
let skipped: Vec<&String> = hosts.iter().filter(|h| crate::autoproxy::excluded(opts, &h.trim().to_ascii_lowercase())).collect();
if !skipped.is_empty() {
return Response::err(format!(
"in proxy.autoProxy.exclude, never probed: {}",
skipped.iter().map(|h| h.as_str()).collect::<Vec<_>>().join(", ")
));
}
let queued = {
let mut r = s.ap.requests.lock().unwrap();
// Bounded: every request is a probe.
+35 -7
View File
@@ -96,6 +96,8 @@ pub fn publish(exits: &[ProbeExit], state: &State) -> Result<()> {
pub struct Exits {
pub list: Vec<ProbeExit>,
pub login: (String, String),
/// autoProxy.exclude: never probed.
pub opts: Options,
}
impl Exits {
@@ -133,6 +135,9 @@ impl Exits {
if !ap::host_ok(domain) {
bail!("'{domain}' is not a host name");
}
if excluded(&self.opts, &domain.to_ascii_lowercase()) {
bail!("{domain} is in proxy.autoProxy.exclude: never probed");
}
if !self.up().await {
bail!("the probe listeners are not up: is the local proxy running?");
}
@@ -248,10 +253,14 @@ pub fn exits(s: &crate::service::Service) -> Option<Exits> {
return None;
}
let list = s.last.as_ref()?.probe_exits.clone();
(!list.is_empty()).then(|| Exits { list, login: (s.store.secrets.hop_user.clone(), s.store.secrets.hop_password.clone()) })
(!list.is_empty()).then(|| Exits {
list,
login: (s.store.secrets.hop_user.clone(), s.store.secrets.hop_password.clone()),
opts: cfg.proxy.auto_proxy.clone(),
})
}
fn excluded(opts: &Options, host: &str) -> bool {
pub fn excluded(opts: &Options, host: &str) -> bool {
opts.exclude.iter().any(|x| {
let x = x.trim_start_matches('.').to_ascii_lowercase();
host == x || host.ends_with(&format!(".{x}"))
@@ -391,7 +400,7 @@ pub async fn run(shared: &Shared, mode: Mode) {
let taken: Vec<String> = std::mem::take(&mut *requests);
for h in taken {
let h = h.trim().to_ascii_lowercase();
if !ap::host_ok(&h) || !seen.insert(h.clone()) {
if !ap::host_ok(&h) || excluded(&opts, &h) || !seen.insert(h.clone()) {
continue;
}
if let Some(d) = ap::registrable(&h) {
@@ -530,16 +539,35 @@ pub async fn sample(shared: Shared) {
}
}
/// What `proxy-ctl proxy auto` lists.
pub fn listing(paths: &Paths, exits: Option<&Exits>, opts: &Options) -> Value {
/// What `proxy-ctl proxy auto` lists. Without `detail` (the secrets scope) the sites routed
/// and the counts only: the hosts probed, those left to zapret and the sites behind each
/// strike are browsing history, as the logs are.
pub fn listing(paths: &Paths, exits: Option<&Exits>, opts: &Options, detail: bool) -> Value {
let s = load(paths);
let domains: Vec<Value> = s.domains.iter().map(|(d, r)| json!({ "domain": d, "exit": r.exit, "verdict": r.verdict, "host": r.host, "at": r.at })).collect();
let domains: Vec<Value> = s
.domains
.iter()
.map(|(d, r)| {
let mut v = json!({ "domain": d, "exit": r.exit, "verdict": r.verdict, "at": r.at });
if detail {
v["host"] = r.host.clone().into();
}
v
})
.collect();
let exit_list: Vec<Value> = s
.exits
.iter()
.map(|(t, e)| json!({ "tag": t, "ip": e.ip, "asn": e.asn, "bad": e.bad, "badBy": e.bad_by }))
.map(|(t, e)| {
let mut v = json!({ "tag": t, "ip": e.ip, "asn": e.asn, "bad": e.bad, "strikes": e.strikes.len() });
if detail {
v["badBy"] = json!(e.bad_by);
}
v
})
.collect();
let censored: Vec<&String> = s.hosts.iter().filter(|(_, h)| h.verdict == "censor").map(|(h, _)| h).collect();
let censored = if detail { json!(censored) } else { json!(censored.len()) };
json!({
"enabled": opts.enable,
"running": exits.is_some(),