Lines 1-54javascript
3 * netcontrol-agent.js v4.0 — Hybrid self-installing agent
7 * NC_SERVER_URL=http://server:4000 node netcontrol-agent.js
9 * Install as a permanent service (runs on boot, auto-restarts):
10 * Linux: sudo NC_SERVER_URL=http://server:4000 node netcontrol-agent.js --install
11 * Windows: (run PowerShell as Administrator)
12 * $env:NC_SERVER_URL="http://server:4000"; node netcontrol-agent.js --install
15 * Linux: sudo node netcontrol-agent.js --uninstall
16 * Windows: node netcontrol-agent.js --uninstall (as Administrator)
19 * NC_SERVER_URL — required: http(s)://host:port of your NetControl server
20 * NC_REG_SECRET — required for first-time registration: must match the
21 * server's AGENT_REGISTRATION_SECRET (see backend .env).
22 * Not needed on subsequent runs once credentials are
23 * cached, unless the agent has to re-register (e.g. the
24 * credentials file was deleted or the key was rejected).
25 * NC_INTERVAL — metrics push interval seconds (default 5, min 3)
26 * NC_CRED_FILE — override credential storage path
30const os = require('os');
31const fs = require('fs');
32const path = require('path');
33const http = require('http');
34const https = require('https');
35const { execSync, spawnSync, spawn } = require('child_process');
36
HighChild Process
Package source references child process execution.
netcontrol-agent.jsView on unpkg · L34 37// ── Config ─────────────────────────────────────────────────────────────────────
38const SERVER_URL = (process.env.NC_SERVER_URL || '').replace(/\/$/, '');
39const REG_SECRET = process.env.NC_REG_SECRET || '';
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
netcontrol-agent.jsView on unpkg · L32 40const INTERVAL_SEC = Math.max(3, parseInt(process.env.NC_INTERVAL || '5', 10));
41const IS_WINDOWS = os.platform() === 'win32';
42const AGENT_PATH = path.resolve(process.argv[1]);
44const CRED_FILE = process.env.NC_CRED_FILE || (
46 ? path.join(process.env.PROGRAMDATA || 'C:\\ProgramData', 'NetControl', 'agent.json')
47 : process.getuid?.() === 0
48 ? '/etc/netcontrol-agent.json'
49 : path.join(os.homedir(), '.netcontrol-agent.json')
50);
MediumInstall Persistence
Source writes installer persistence such as shell profile or service configuration.
netcontrol-agent.jsView on unpkg · L6 52// ── Install/Uninstall handlers ─────────────────────────────────────────────────
53if (process.argv.includes('--install')) {