Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/web/src/app/nodes/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ export default async function NodesPage() {
<td className="py-2 pr-3">
{n.name ? <span className="accent font-bold">{n.name}</span> : <span className="text-[var(--color-dim)]">unnamed</span>}
<span className="block font-mono text-[var(--color-dim)]">{n.id}</span>
{n.contact && /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z0-9-]+$/.test(n.contact) && (
<a href={`mailto:${n.contact}`} className="block text-[var(--color-dim)] !border-0" title="The operator's contact for questions about this node">
{n.contact}
</a>
)}
{n.donates?.includes("crowdgpt") && (
<Link href="/plugins#crowdgpt" className="block text-[var(--color-dim)] !border-0" title="Donates idle compute to CrowdGPT when it has no paid work">
donates idle to CrowdGPT
Expand Down Expand Up @@ -279,6 +284,13 @@ $ c0mpute name # check what is set`}</CodeBlock>
who gets paid: earnings go to the payout address set on the node
(<code>infernet payout set</code>), never to a name. Needs c0mpute 0.2.64 or newer (<code>c0mpute update</code>).
</p>
<p className="text-sm leading-7" id="contact">
Add a contact email too, so people who use your node (and the
network&apos;s maintainers, if it starts failing jobs) can reach you.
It is optional and shown publicly under your node&apos;s name:
</p>
<CodeBlock>{`$ c0mpute contact ops@example.com # set it, then restart the worker
$ curl -fsSL https://c0mpute.com/install.sh | sh -s -- --contact ops@example.com`}</CodeBlock>
{p.operators.length > 0 && (
<table id="operators" className="w-full text-left border-collapse text-xs">
<thead className="text-[var(--color-dim)]">
Expand Down
6 changes: 6 additions & 0 deletions apps/web/src/lib/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down
46 changes: 46 additions & 0 deletions node/crates/c0mpute-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <email>` 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<String>,
/// 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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -2622,6 +2638,36 @@ fn run_name(handle: Option<String>, clear: bool) -> Result<()> {
Ok(())
}

fn run_contact(email: Option<String>, 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 <email>` so people can reach you about this node)"),
}
Ok(())
}

fn run_pricing(cmd: Option<PricingCmd>, config_path: &std::path::Path) -> Result<()> {
use c0mpute_core::pricing::PricingMode;
let mut cfg = Config::load_or_default(config_path)?;
Expand Down
61 changes: 61 additions & 0 deletions node/crates/c0mpute-core/src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -348,6 +351,54 @@ pub fn node_name_path() -> Option<std::path::PathBuf> {
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 <email>` or
/// `install.sh --contact <email>`. Nothing is sent to it automatically.
pub fn node_contact() -> Option<String> {
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<std::path::PathBuf> {
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<String> {
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::path::PathBuf> {
std::env::var_os("C0MPUTE_HOME")
.map(std::path::PathBuf::from)
Expand Down Expand Up @@ -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.com>",
"a b@c.com", "a@b.com\"><script>", "javascript:alert(1)@x.com", "a@@b.com", ".a@b.com"] {
assert_eq!(sanitize_contact(bad), None, "{bad:?} must be refused");
}
}

#[test]
fn an_ad_dated_in_the_future_is_refused_or_filed_at_now() {
let now = 10_000_000u64;
Expand Down
14 changes: 13 additions & 1 deletion node/crates/c0mpute-core/src/status_aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,10 @@ struct NodeRow {
referral: Option<String>,
/// The operator's nickname (`c0mpute name`), if the node sets one.
name: Option<String>,
/// The email its operator offers for questions (`c0mpute contact`), if
/// any. Public by the operator's choice; re-validated to a plain address.
#[serde(skip_serializing_if = "Option::is_none")]
contact: Option<String>,
/// The operator's listing (`mode`, `min_usd`, `fixed_usd`), if the node
/// advertises one. Re-validated here: only known fields, sane numbers.
pricing: Option<serde_json::Value>,
Expand Down Expand Up @@ -764,6 +768,11 @@ fn build_nodes(ads: &[(String, c0mpute_net::topics::CapabilityAd)], now: u64) ->
.get("name")
.and_then(|v| v.as_str())
.and_then(crate::capabilities::sanitize_ref),
contact: ad
.hardware
.get("contact")
.and_then(|v| v.as_str())
.and_then(crate::capabilities::sanitize_contact),
pricing: listing(&ad.hardware),
storage: storage_offer(&ad.hardware),
gateway: ad
Expand Down Expand Up @@ -1055,6 +1064,7 @@ mod tests {
"version": "0.2.32",
"ref": "chovy",
"name": "profullstack",
"contact": "Ops@Example.com",
"gateway": "http://203.0.113.7:7777/",
"cpu": "Example CPU",
"bench_at": "2026-11-01T12:00:00Z",
Expand All @@ -1070,7 +1080,7 @@ mod tests {
mk(
&["c0mpute:cpu"],
Some(100),
serde_json::json!({"ref": "<bad>", "name": "has space", "gateway": "javascript:alert(1)"}),
serde_json::json!({"ref": "<bad>", "name": "has space", "gateway": "javascript:alert(1)", "contact": "x@y.com\"><script>"}),
),
),
];
Expand All @@ -1089,6 +1099,8 @@ mod tests {
assert_eq!(p.nodes[2].bench_score, None);
assert_eq!(p.nodes[1].referral, None, "invalid ref dropped");
assert_eq!(p.nodes[1].name, None, "invalid name dropped");
assert_eq!(p.nodes[0].contact.as_deref(), Some("ops@example.com"), "a plain contact email passes, lowercased");
assert_eq!(p.nodes[1].contact, None, "a contact that is not a plain email is dropped");
assert_eq!(p.nodes[0].name.as_deref(), Some("profullstack"));
assert_eq!(
p.nodes[0].gateway.as_deref(),
Expand Down
31 changes: 31 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
# --force Reinstall over existing
# --ref <code> Credit a referrer on c0mpute.com/nodes (same as C0MPUTE_REF)
# --name <handle> Your node's nickname on c0mpute.com/nodes (same as C0MPUTE_NAME)
# --contact <email> Optional public email for questions about your node, shown
# on c0mpute.com/nodes (same as C0MPUTE_CONTACT). Asked for
# when run from a terminal; later `c0mpute contact <email>`.
# --no-house-models Don't pull Infernet house models (same as
# INFERNET_NO_HOUSE_MODELS=1). They are ON by default:
# the node pulls and serves the models listed at
Expand Down Expand Up @@ -112,6 +115,8 @@ while [ $# -gt 0 ]; do
--ref=*) C0MPUTE_REF="${1#--ref=}" ;;
--name) shift; C0MPUTE_NAME="${1:-}" ;;
--name=*) C0MPUTE_NAME="${1#--name=}" ;;
--contact) shift; C0MPUTE_CONTACT="${1:-}" ;;
--contact=*) C0MPUTE_CONTACT="${1#--contact=}" ;;
--no-house-models) INFERNET_NO_HOUSE_MODELS=1 ;;
--uncensored-models) INFERNET_UNCENSORED_MODELS=1 ;;
--no-uncensored-models) INFERNET_NO_UNCENSORED_MODELS=1 ;;
Expand Down Expand Up @@ -1258,6 +1263,32 @@ save_handle() { # <value> <file> <label>
save_ref() {
save_handle "${C0MPUTE_REF:-}" ref "referral code"
save_handle "${C0MPUTE_NAME:-}" name "node name"
save_contact
}

# Optional, PUBLIC contact email for questions about this node (shown on
# c0mpute.com/nodes). From --contact / C0MPUTE_CONTACT; otherwise asked once
# when a person is at a terminal (`curl ... | sh` still reads /dev/tty) and no
# contact is saved yet. Enter skips it. Never asked in CI or with --no-exec.
save_contact() {
email="${C0MPUTE_CONTACT:-}"
if [ -z "$email" ] && [ ! -s "$C0MPUTE_HOME/contact" ] && [ -z "${CI:-}" ] \
&& [ "${NO_EXEC:-0}" != 1 ] && [ -t 1 ] && [ -r /dev/tty ] && [ -w /dev/tty ]; then
printf '%s' "Contact email for questions about your node (optional, public on c0mpute.com/nodes; Enter to skip): " > /dev/tty
IFS= read -r email < /dev/tty || email=""
fi
# Trim the ends only: a space inside is a typo to refuse, not to close up.
email=$(printf '%s' "$email" | tr '[:upper:]' '[:lower:]' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
[ -n "$email" ] || return 0
case "$email" in
*@*.*) ;;
*) warn "ignoring contact '$email' (not an email address)"; return 0 ;;
esac
case "$email" in
*[!a-z0-9@._%+-]*|*@*@*|@*|*@.*|*.) warn "ignoring contact '$email' (use a plain address like ops@example.com)"; return 0 ;;
esac
mkdir -p "$C0MPUTE_HOME" && printf '%s\n' "$email" > "$C0MPUTE_HOME/contact" \
&& ok "contact '$email' saved (public on https://c0mpute.com/nodes; change with \`c0mpute contact\`)"
}

# ────────────────────────────────────────────────────────────────────────
Expand Down