Native-node lähettää NODE_API_KEY auth-viestissä hubille

Luetaan NODE_API_KEY-ympäristömuuttuja ja lisätään api_key-kenttä
auth-viestiin. Hub tarkistaa avaimen ja hylkää solmun jos se ei täsmää.

Käyttö:
  NODE_API_KEY=kpn_sk_abc123 HUB_URL=ws://hub:3000/ws cargo run

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaakko Vanhala
2026-04-09 15:39:48 +03:00
parent 7f5bb45138
commit 4f18377a3b

View File

@@ -222,6 +222,8 @@ fn build_auth_message(allocated_gb: u32) -> String {
v v
}).collect(); }).collect();
let api_key = std::env::var("NODE_API_KEY").unwrap_or_default();
let mut msg = json!({ let mut msg = json!({
"type": "auth", "type": "auth",
"status": "agent_ready", "status": "agent_ready",
@@ -231,6 +233,10 @@ fn build_auth_message(allocated_gb: u32) -> String {
"system": sys, "system": sys,
}); });
if !api_key.is_empty() {
msg.as_object_mut().unwrap().insert("api_key".to_string(), json!(api_key));
}
if !gpu_json.is_empty() { if !gpu_json.is_empty() {
msg.as_object_mut().unwrap().insert("gpus".to_string(), json!(gpu_json)); msg.as_object_mut().unwrap().insert("gpus".to_string(), json!(gpu_json));
} }