pub struct IicpNode { /* private fields */ }Expand description
IICP provider node — handles registration, heartbeats, and task serving.
Implementations§
Source§impl IicpNode
impl IicpNode
pub fn new(cfg: NodeConfig) -> Self
Sourcepub fn set_saved_node_name(&mut self, name: impl Into<String>)
pub fn set_saved_node_name(&mut self, name: impl Into<String>)
Persist refreshed directory credentials into this saved node identity. This is intentionally opt-in so library users that construct transient nodes do not write local config files.
Sourcepub fn set_endpoint(&self, endpoint: String)
pub fn set_endpoint(&self, endpoint: String)
#527 — handle for the tunnel watchdog to publish a rotated Quick Tunnel
URL from its sync thread; the heartbeat loop re-registers on the change.
#527 — update the effective endpoint at runtime. endpoint is stored as
an override so the background watchdog can push rotations into the same
running node instance (and the loop re-registers when it changes).
pub fn endpoint_override_handle(&self) -> Arc<RwLock<Option<String>>> ⓘ
pub fn runtime_available_handle(&self) -> Arc<AtomicBool> ⓘ
Sourcepub fn node_hmac_key(&self) -> String
pub fn node_hmac_key(&self) -> String
Current HMAC key in use for ADR-019 pricing signatures (empty if unregistered AND no operator-provisioned key).
Sourcepub fn cfg(&self) -> &NodeConfig
pub fn cfg(&self) -> &NodeConfig
Borrow this node’s configuration. Useful for callers (e.g.
crate::conformance::run_conformance_checks) that need to inspect
directory_url, endpoint, or node_id without owning the config.
Sourcepub fn registered_models(&self) -> &Arc<RwLock<Vec<String>>> ⓘ
pub fn registered_models(&self) -> &Arc<RwLock<Vec<String>>> ⓘ
#494 — expose registered_models for test inspection and background-task wiring.
Sourcepub async fn check_model_drift_and_reregister(&self)
pub async fn check_model_drift_and_reregister(&self)
#494 — check for model drift and re-register if the live set differs from registered. Used by tests; production uses the same logic inlined in the heartbeat background task.
Sourcepub fn set_relay_worker_endpoint(&mut self, endpoint: String)
pub fn set_relay_worker_endpoint(&mut self, endpoint: String)
Set the relay-worker endpoint after construction. Used by the CLI when a
relay is auto-elected post-NAT-detection (tier ≥ 3): serve() reads
self.cfg.relay_worker_endpoint to start the outbound relay session.
Sourcepub fn set_transport_endpoint(&mut self, endpoint: String)
pub fn set_transport_endpoint(&mut self, endpoint: String)
#457 / ADR-040 — set the native binary transport_endpoint advertised at register
(the single-port multiplexer serves it on the same socket as the HTTP endpoint).
Sourcepub fn apply_nat_profile(&mut self, profile: &NatProfile)
pub fn apply_nat_profile(&mut self, profile: &NatProfile)
Populate endpoint, transport_endpoint, and the NAT observability
fields from a NatProfile produced by crate::nat_detection::detect_nat.
Operators typically call this right after detect_nat() and before
register() so the directory receives the discovered public endpoint
- transport_method/nat_type/transport_metadata in the same payload.
Defensive: tier-4 (unreachable) profiles do NOT overwrite a manually-
set endpoint, and transport_method == "unreachable" is filtered out
before register.
Sourcepub async fn revoke_pinhole(&self) -> bool
pub async fn revoke_pinhole(&self) -> bool
#343 — close the UPnP IPv6 firewall pinhole if one is tracked. Best-effort.
Sourcepub fn seed_token(&self, token: &str)
pub fn seed_token(&self, token: &str)
Tell the directory this node is going away.
Mirrors iicp_client.IicpNode.deregister (Python iter-1471) and
IicpNode.deregister (TS iter-1474). Best-effort: shutdown paths
swallow failures so a flaky directory connection doesn’t block exit.
Phase 2 (#529/#55) — seed a previously-cached node_token so the next
register() proves ownership via current_node_token (IICP-E050 path).
Sourcepub async fn deregister(&self, node_token: Option<&str>) -> Result<()>
pub async fn deregister(&self, node_token: Option<&str>) -> Result<()>
Deregister from the directory. node_token defaults to the token stashed by
register() (BUG-5) when None — pass Some(token) to override.
pub async fn register(&self) -> Result<String>
Sourcepub async fn heartbeat(&self, node_token: &str) -> Result<()>
pub async fn heartbeat(&self, node_token: &str) -> Result<()>
Send a single heartbeat to the directory.