Watch
0
0
Fork
You've already forked hyperhive
0

send agent traffic through squid once its hive announces it

This commit is contained in:
atlas 2026-10-28 14:35:08 +01:00
commit b551eb02ff
2 changed files with 885 additions and 27 deletions

View file

@ -141,8 +141,8 @@ pub fn network_isolation_from_env() -> Result<hive_priv_sock::NetworkIsolation>
}
/// The hive's facts every container is handed at runtime, so that no agent
/// build carries a value that differs between hosts. The name, domain, OTEL
/// resource labels and queue address come from hive-c0re's own unit environment
/// build carries a value that differs between hosts. The name, domain, egress
/// proxy and its direct hosts, OTEL resource labels and queue address come from hive-c0re's own unit environment
/// (`nix/host-modules/hive-c0re/environment.nix`), where an unset or empty
/// variable is `None`; the dashboard port and pinned claude from `hive`.
fn hive_facts(hive: &HiveEnv) -> hive_priv_sock::HiveFacts {
@ -162,6 +162,8 @@ fn hive_facts_from(
claude_code_path: hive.claude_code_path.clone(),
otel_extra_resource_attributes: read("HYPERHIVE_OTEL_EXTRA_RESOURCE_ATTRIBUTES"),
agent_nats_url: read("HIVE_AGENT_NATS_URL"),
squid_proxy: read("HIVE_SQUID_PROXY"),
egress_no_proxy: read("HIVE_EGRESS_NO_PROXY"),
}
}

View file

@ -541,6 +541,8 @@ fn hive_facts_carry_the_per_host_values() {
let facts = hive_facts_from(&hive, |name| match name {
"HYPERHIVE_OTEL_EXTRA_RESOURCE_ATTRIBUTES" => Some("team=a".to_owned()),
"HIVE_AGENT_NATS_URL" => Some("tls://nats.t.local:4222".to_owned()),
"HIVE_SQUID_PROXY" => Some("10.42.0.1:3128".to_owned()),
"HIVE_EGRESS_NO_PROXY" => Some("10.42.0.1,t.local".to_owned()),
_ => None,
});
assert_eq!(facts.dashboard_port, Some(7123));
@ -556,6 +558,8 @@ fn hive_facts_carry_the_per_host_values() {
facts.agent_nats_url.as_deref(),
Some("tls://nats.t.local:4222")
);
assert_eq!(facts.squid_proxy.as_deref(), Some("10.42.0.1:3128"));
assert_eq!(facts.egress_no_proxy.as_deref(), Some("10.42.0.1,t.local"));
}
/// Unset and empty both leave a fact out, so the agent falls back to its
@ -568,5 +572,7 @@ fn hive_facts_leave_unset_values_out() {
assert_eq!(facts.claude_code_path, None);
assert_eq!(facts.otel_extra_resource_attributes, None);
assert_eq!(facts.agent_nats_url, None);
assert_eq!(facts.squid_proxy, None);
assert_eq!(facts.egress_no_proxy, None);
assert_eq!(facts.name, None);
}