diff --git a/apps/web/src/app/nodes/page.tsx b/apps/web/src/app/nodes/page.tsx index 7bb16a92..4fe38eb0 100644 --- a/apps/web/src/app/nodes/page.tsx +++ b/apps/web/src/app/nodes/page.tsx @@ -185,6 +185,11 @@ export default async function NodesPage() { {n.name ? {n.name} : unnamed} {n.id} + {n.contact && /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z0-9-]+$/.test(n.contact) && ( + + {n.contact} + + )} {n.donates?.includes("crowdgpt") && ( donates idle to CrowdGPT @@ -279,6 +284,13 @@ $ c0mpute name # check what is set`} who gets paid: earnings go to the payout address set on the node (infernet payout set), never to a name. Needs c0mpute 0.2.64 or newer (c0mpute update).

+

+ Add a contact email too, so people who use your node (and the + network's maintainers, if it starts failing jobs) can reach you. + It is optional and shown publicly under your node's name: +

+ {`$ c0mpute contact ops@example.com # set it, then restart the worker +$ curl -fsSL https://c0mpute.com/install.sh | sh -s -- --contact ops@example.com`} {p.operators.length > 0 && ( diff --git a/apps/web/src/lib/nodes.ts b/apps/web/src/lib/nodes.ts index b82c773b..3e41d3d0 100644 --- a/apps/web/src/lib/nodes.ts +++ b/apps/web/src/lib/nodes.ts @@ -21,6 +21,12 @@ export interface NodeRow { ref: string | null; /** The operator's nickname (`c0mpute name`); absent on nodes older than 0.2.64. */ name?: string | null; + /** + * The email the operator offers for questions about this node (`c0mpute + * contact`), public by their choice; the aggregator passes only plain + * addresses. Absent when unset and on nodes older than 0.3.73. + */ + contact?: string | null; /** The operator's listing; absent on nodes older than 0.2.35. */ pricing?: Pricing | null; /** diff --git a/node/crates/c0mpute-cli/src/main.rs b/node/crates/c0mpute-cli/src/main.rs index 61988d43..f8e9732d 100644 --- a/node/crates/c0mpute-cli/src/main.rs +++ b/node/crates/c0mpute-cli/src/main.rs @@ -131,6 +131,21 @@ enum Cmd { #[arg(long, conflicts_with = "handle")] clear: bool, }, + /// Show or set the contact email for questions about this node. + /// + /// Optional and PUBLIC: it is shown next to your node on + /// c0mpute.com/nodes so callers and the network's maintainers can reach + /// you (say, when your node keeps failing jobs). `c0mpute contact` prints + /// it, `c0mpute contact ` sets it, `--clear` removes it. Stored in + /// `~/.c0mpute/contact` (`C0MPUTE_CONTACT` overrides it). A running worker + /// picks a change up on restart. + Contact { + /// The email to show, e.g. `ops@example.com`. + email: Option, + /// Remove the contact email. + #[arg(long, conflicts_with = "email")] + clear: bool, + }, /// Private mode: serve only your own machines, stay off the public list. /// /// A private node only bids on jobs whose signed publisher is one of the @@ -1812,6 +1827,7 @@ async fn run_app(cli: Cli) -> Result<()> { } Cmd::Pricing { cmd } => run_pricing(cmd, &config_path), Cmd::Name { handle, clear } => run_name(handle, clear), + Cmd::Contact { email, clear } => run_contact(email, clear), Cmd::Private { cmd } => run_private(cmd, &config_path), Cmd::Worker { cmd } => run_worker(cmd, &config_path).await, Cmd::Job { cmd } => run_job(cmd).await, @@ -2622,6 +2638,36 @@ fn run_name(handle: Option, clear: bool) -> Result<()> { Ok(()) } +fn run_contact(email: Option, clear: bool) -> Result<()> { + use c0mpute_core::capabilities::{node_contact, node_contact_path, sanitize_contact}; + let path = node_contact_path().context("cannot find a home directory for ~/.c0mpute")?; + let apply = "(apply: c0mpute worker stop && c0mpute worker start -d)"; + if clear { + match std::fs::remove_file(&path) { + Ok(()) => println!("removed {} {apply}", path.display()), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => println!("no contact email was set"), + Err(e) => return Err(e).with_context(|| format!("remove {}", path.display())), + } + } else if let Some(raw) = email { + let email = sanitize_contact(&raw) + .with_context(|| format!("{raw:?} is not a plain email address (like ops@example.com)"))?; + if let Some(dir) = path.parent() { + std::fs::create_dir_all(dir)?; + } + std::fs::write(&path, format!("{email}\n")).with_context(|| format!("write {}", path.display()))?; + println!("saved to {} {apply}", path.display()); + } + match node_contact() { + Some(e) => { + let via = if std::env::var_os("C0MPUTE_CONTACT").is_some() { " (from C0MPUTE_CONTACT)" } else { "" }; + println!("contact : {e}{via}"); + println!("shown on : https://c0mpute.com/nodes (public)"); + } + None => println!("contact : (none; add one with `c0mpute contact ` so people can reach you about this node)"), + } + Ok(()) +} + fn run_pricing(cmd: Option, config_path: &std::path::Path) -> Result<()> { use c0mpute_core::pricing::PricingMode; let mut cfg = Config::load_or_default(config_path)?; diff --git a/node/crates/c0mpute-core/src/capabilities.rs b/node/crates/c0mpute-core/src/capabilities.rs index 2a7a420f..8884c449 100644 --- a/node/crates/c0mpute-core/src/capabilities.rs +++ b/node/crates/c0mpute-core/src/capabilities.rs @@ -265,6 +265,9 @@ pub fn hardware_blob(config: &Config) -> serde_json::Value { if let Some(name) = node_name() { blob["name"] = serde_json::Value::String(name); } + if let Some(contact) = node_contact() { + blob["contact"] = serde_json::Value::String(contact); + } blob["pricing"] = config.pricing.listing(); if let Some(origin) = announced_gateway(config) { blob["gateway"] = serde_json::Value::String(origin); @@ -348,6 +351,54 @@ pub fn node_name_path() -> Option { c0mpute_home().map(|h| h.join("name")) } +/// The email the operator offers for questions about this node, if any. +/// +/// Optional and PUBLIC: it rides in the capability ad and is shown on +/// c0mpute.com/nodes, so callers and the network's maintainers can reach +/// whoever runs a node that misbehaves (2026-11-15: a node failing 3 in 4 +/// jobs had no way to be contacted). `C0MPUTE_CONTACT` wins; otherwise +/// `~/.c0mpute/contact`, written by `c0mpute contact ` or +/// `install.sh --contact `. Nothing is sent to it automatically. +pub fn node_contact() -> Option { + let raw = std::env::var("C0MPUTE_CONTACT") + .ok() + .filter(|v| !v.trim().is_empty()) + .or_else(|| std::fs::read_to_string(node_contact_path()?).ok())?; + sanitize_contact(&raw) +} + +/// Where `c0mpute contact` stores the email: `$C0MPUTE_HOME/contact`, else +/// `~/.c0mpute/contact`. +pub fn node_contact_path() -> Option { + c0mpute_home().map(|h| h.join("contact")) +} + +/// A plain email address (`local@domain.tld`), lowercased, up to 254 +/// characters, or nothing. No spaces, quotes, angle brackets or display +/// names: it is printed into a public web page as a mailto link. Shared with +/// the status aggregator, which re-checks every ad before it publishes one. +pub fn sanitize_contact(raw: &str) -> Option { + let email = raw.trim().to_ascii_lowercase(); + if email.is_empty() || email.len() > 254 { + return None; + } + let (local, domain) = email.split_once('@')?; + let ok_chars = |s: &str, extra: &[char]| { + !s.is_empty() && s.chars().all(|c| c.is_ascii_alphanumeric() || extra.contains(&c)) + }; + let ok = local.len() <= 64 + && ok_chars(local, &['.', '_', '%', '+', '-']) + && !local.starts_with('.') + && !local.ends_with('.') + && ok_chars(domain, &['.', '-']) + && domain.contains('.') + && !domain.starts_with(['.', '-']) + && !domain.ends_with(['.', '-']) + && !domain.contains("..") + && !domain.contains('@'); + ok.then_some(email) +} + fn c0mpute_home() -> Option { std::env::var_os("C0MPUTE_HOME") .map(std::path::PathBuf::from) @@ -732,6 +783,16 @@ impl Registry { mod tests { use super::*; + #[test] + fn contact_emails_are_plain_addresses_or_nothing() { + assert_eq!(sanitize_contact(" Sergey@Example.COM \n"), Some("sergey@example.com".into())); + assert_eq!(sanitize_contact("ops+c0mpute@mail.example.co.uk"), Some("ops+c0mpute@mail.example.co.uk".into())); + for bad in ["", "nobody", "a@b", "@example.com", "a@.example.com", "a@example..com", "Name ", + "a b@c.com", "a@b.com\">