@bmfk/api 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/LICENSE +21 -0
- package/README.md +1293 -2
- package/dist/apiServer/APIService.d.ts +125 -0
- package/dist/apiServer/APIService.js +769 -0
- package/dist/apiServer/BaseEndpoint.d.ts +90 -0
- package/dist/apiServer/BaseEndpoint.js +314 -0
- package/dist/apiServer/BaseService.d.ts +17 -0
- package/dist/apiServer/BaseService.js +39 -0
- package/dist/apiServer/DBService.d.ts +131 -0
- package/dist/apiServer/DBService.js +290 -0
- package/dist/apiServer/DocumentService.d.ts +9 -0
- package/dist/apiServer/DocumentService.js +65 -0
- package/dist/apiServer/LocalRequest.d.ts +3 -0
- package/dist/apiServer/LocalRequest.js +6 -0
- package/dist/apiServer/LogService.d.ts +78 -0
- package/dist/apiServer/LogService.js +349 -0
- package/dist/apiServer/MonitorService.d.ts +102 -0
- package/dist/apiServer/MonitorService.js +615 -0
- package/dist/apiServer/StatService.d.ts +4 -0
- package/dist/apiServer/StatService.js +10 -0
- package/dist/apiServer/TimeframeService.d.ts +28 -0
- package/dist/apiServer/TimeframeService.js +97 -0
- package/dist/apiServer/WebSocketServer.d.ts +39 -0
- package/dist/apiServer/WebSocketServer.js +173 -0
- package/dist/apiServer/db/IDBAdapter.d.ts +14 -0
- package/dist/apiServer/db/IDBAdapter.js +2 -0
- package/dist/apiServer/db/MysqlAdapter.d.ts +72 -0
- package/dist/apiServer/db/MysqlAdapter.js +869 -0
- package/dist/apiServer/db/PostgresAdapter.d.ts +41 -0
- package/dist/apiServer/db/PostgresAdapter.js +73 -0
- package/dist/apiServer/deployment/AccessConfigWizard.d.ts +5 -0
- package/dist/apiServer/deployment/AccessConfigWizard.js +254 -0
- package/dist/apiServer/deployment/Activate.d.ts +4 -0
- package/dist/apiServer/deployment/Activate.js +124 -0
- package/dist/apiServer/deployment/BackupManager.d.ts +33 -0
- package/dist/apiServer/deployment/BackupManager.js +174 -0
- package/dist/apiServer/deployment/Backups.d.ts +2 -0
- package/dist/apiServer/deployment/Backups.js +44 -0
- package/dist/apiServer/deployment/BlueGreenState.d.ts +31 -0
- package/dist/apiServer/deployment/BlueGreenState.js +150 -0
- package/dist/apiServer/deployment/Bundler.d.ts +12 -0
- package/dist/apiServer/deployment/Bundler.js +178 -0
- package/dist/apiServer/deployment/ConfigService.d.ts +203 -0
- package/dist/apiServer/deployment/ConfigService.js +195 -0
- package/dist/apiServer/deployment/Deploy.d.ts +4 -0
- package/dist/apiServer/deployment/Deploy.js +404 -0
- package/dist/apiServer/deployment/DeployKeyWizard.d.ts +2 -0
- package/dist/apiServer/deployment/DeployKeyWizard.js +84 -0
- package/dist/apiServer/deployment/Deployer.d.ts +13 -0
- package/dist/apiServer/deployment/Deployer.js +96 -0
- package/dist/apiServer/deployment/DeployerInit.d.ts +25 -0
- package/dist/apiServer/deployment/DeployerInit.js +214 -0
- package/dist/apiServer/deployment/DeployerService.d.ts +378 -0
- package/dist/apiServer/deployment/DeployerService.js +1553 -0
- package/dist/apiServer/deployment/HashPassword.d.ts +3 -0
- package/dist/apiServer/deployment/HashPassword.js +126 -0
- package/dist/apiServer/deployment/MigrateConfigsWizard.d.ts +1 -0
- package/dist/apiServer/deployment/MigrateConfigsWizard.js +202 -0
- package/dist/apiServer/deployment/MigrateProject.d.ts +31 -0
- package/dist/apiServer/deployment/MigrateProject.js +335 -0
- package/dist/apiServer/deployment/NginxHelper.d.ts +10 -0
- package/dist/apiServer/deployment/NginxHelper.js +111 -0
- package/dist/apiServer/deployment/Notifier.d.ts +30 -0
- package/dist/apiServer/deployment/Notifier.js +82 -0
- package/dist/apiServer/deployment/ProjectConfigWizard.d.ts +1 -0
- package/dist/apiServer/deployment/ProjectConfigWizard.js +148 -0
- package/dist/apiServer/deployment/Restore.d.ts +2 -0
- package/dist/apiServer/deployment/Restore.js +89 -0
- package/dist/apiServer/deployment/ReviewStore.d.ts +62 -0
- package/dist/apiServer/deployment/ReviewStore.js +186 -0
- package/dist/apiServer/deployment/SecretsInjector.d.ts +21 -0
- package/dist/apiServer/deployment/SecretsInjector.js +189 -0
- package/dist/apiServer/deployment/SetupConfigWizard.d.ts +1 -0
- package/dist/apiServer/deployment/SetupConfigWizard.js +238 -0
- package/dist/apiServer/deployment/Status.d.ts +2 -0
- package/dist/apiServer/deployment/Status.js +83 -0
- package/dist/apiServer/deployment/TelegramNotifier.d.ts +8 -0
- package/dist/apiServer/deployment/TelegramNotifier.js +23 -0
- package/dist/apiServer/deployment/Watchdog.d.ts +15 -0
- package/dist/apiServer/deployment/Watchdog.js +65 -0
- package/dist/apiServer/deployment/Wizards.d.ts +1 -0
- package/dist/apiServer/deployment/Wizards.js +83 -0
- package/dist/apiServer/deployment/cli.d.ts +2 -0
- package/dist/apiServer/deployment/cli.js +224 -0
- package/dist/apiServer/deployment/cliCommon.d.ts +27 -0
- package/dist/apiServer/deployment/cliCommon.js +110 -0
- package/dist/apiServer/deployment/cliPrompt.d.ts +5 -0
- package/dist/apiServer/deployment/cliPrompt.js +38 -0
- package/dist/apiServer/deployment/resolveConfig.d.ts +19 -0
- package/dist/apiServer/deployment/resolveConfig.js +139 -0
- package/dist/apiServer/documentation/Documentation.d.ts +18 -0
- package/dist/apiServer/documentation/Documentation.js +143 -0
- package/dist/apiServer/documentation/index.html +460 -0
- package/dist/apiServer/external/MicroserviceClient.d.ts +28 -0
- package/dist/apiServer/external/MicroserviceClient.js +144 -0
- package/dist/apiServer/external/MicroserviceHost.d.ts +52 -0
- package/dist/apiServer/external/MicroserviceHost.js +183 -0
- package/dist/apiServer/external/MicroserviceHostController.d.ts +6 -0
- package/dist/apiServer/external/MicroserviceHostController.js +65 -0
- package/dist/apiServer/helper/AppDataPath.d.ts +9 -0
- package/dist/apiServer/helper/AppDataPath.js +81 -0
- package/dist/apiServer/helper/ClientIp.d.ts +3 -0
- package/dist/apiServer/helper/ClientIp.js +33 -0
- package/dist/apiServer/helper/DataProvider.d.ts +18 -0
- package/dist/apiServer/helper/DataProvider.js +57 -0
- package/dist/apiServer/helper/IpAllowList.d.ts +8 -0
- package/dist/apiServer/helper/IpAllowList.js +40 -0
- package/dist/apiServer/helper/JSONStableStringify.d.ts +1 -0
- package/dist/apiServer/helper/JSONStableStringify.js +15 -0
- package/dist/apiServer/helper/PasswordHash.d.ts +5 -0
- package/dist/apiServer/helper/PasswordHash.js +52 -0
- package/dist/apiServer/helper/Sleep.d.ts +1 -0
- package/dist/apiServer/helper/Sleep.js +5 -0
- package/dist/apiServer/helper/Trace.d.ts +8 -0
- package/dist/apiServer/helper/Trace.js +30 -0
- package/dist/apiServer/helper/UID.d.ts +16 -0
- package/dist/apiServer/helper/UID.js +98 -0
- package/dist/apiServer/helper/Validator.d.ts +86 -0
- package/dist/apiServer/helper/Validator.js +560 -0
- package/dist/apiServer/helper/YYYYMMDDHH.d.ts +2 -0
- package/dist/apiServer/helper/YYYYMMDDHH.js +31 -0
- package/dist/apiServer/helper/ZipUtils.d.ts +6 -0
- package/dist/apiServer/helper/ZipUtils.js +28 -0
- package/dist/apiServer/http/Http.d.ts +183 -0
- package/dist/apiServer/http/Http.js +627 -0
- package/dist/apiServer/interceptors/InterceptorPayAuth.d.ts +19 -0
- package/dist/apiServer/interceptors/InterceptorPayAuth.js +124 -0
- package/dist/apiServer/interceptors/InterceptorSignedAuth.d.ts +40 -0
- package/dist/apiServer/interceptors/InterceptorSignedAuth.js +150 -0
- package/dist/apiServer/monitor/AccessStore.d.ts +27 -0
- package/dist/apiServer/monitor/AccessStore.js +163 -0
- package/dist/apiServer/monitor/LogFiles.d.ts +34 -0
- package/dist/apiServer/monitor/LogFiles.js +109 -0
- package/dist/apiServer/monitor/Monitor.d.ts +54 -0
- package/dist/apiServer/monitor/Monitor.js +447 -0
- package/dist/apiServer/monitor/MonitorAuth.d.ts +87 -0
- package/dist/apiServer/monitor/MonitorAuth.js +474 -0
- package/dist/apiServer/monitor/ProcessMonitor.d.ts +177 -0
- package/dist/apiServer/monitor/ProcessMonitor.js +468 -0
- package/dist/apiServer/monitor/SystemInfo.d.ts +70 -0
- package/dist/apiServer/monitor/SystemInfo.js +217 -0
- package/dist/apiServer/monitor/ThreatMonitor.d.ts +73 -0
- package/dist/apiServer/monitor/ThreatMonitor.js +239 -0
- package/dist/apiServer/monitor/index.html +591 -0
- package/dist/apiServer/review/Review.d.ts +23 -0
- package/dist/apiServer/review/Review.js +149 -0
- package/dist/apiServer/review/ReviewAuth.d.ts +56 -0
- package/dist/apiServer/review/ReviewAuth.js +147 -0
- package/dist/apiServer/review/ReviewDiff.d.ts +43 -0
- package/dist/apiServer/review/ReviewDiff.js +175 -0
- package/dist/apiServer/review/index.html +501 -0
- package/dist/apiServer/routes/Liveness.d.ts +7 -0
- package/dist/apiServer/routes/Liveness.js +27 -0
- package/dist/apiServer/routes/Readiness.d.ts +13 -0
- package/dist/apiServer/routes/Readiness.js +20 -0
- package/dist/apiServer/security/BlockedIps.d.ts +46 -0
- package/dist/apiServer/security/BlockedIps.js +185 -0
- package/dist/apiServer/structures/DefaultErrors.d.ts +36 -0
- package/dist/apiServer/structures/DefaultErrors.js +52 -0
- package/dist/apiServer/structures/HTTPStatus.d.ts +7 -0
- package/dist/apiServer/structures/HTTPStatus.js +11 -0
- package/dist/apiServer/structures/Interfaces.d.ts +55 -0
- package/dist/apiServer/structures/Interfaces.js +2 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +110 -0
- package/dist/signal/Signal.d.ts +23 -0
- package/dist/signal/Signal.js +85 -0
- package/package.json +88 -4
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MonitorAuth = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const AppDataPath_1 = require("../helper/AppDataPath");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const LogService_1 = require("../LogService");
|
|
12
|
+
const PasswordHash_1 = require("../helper/PasswordHash");
|
|
13
|
+
class MonitorAuth {
|
|
14
|
+
static ROLE_CAPS = {
|
|
15
|
+
admin: ["dashboard", "logs", "admin"],
|
|
16
|
+
it: ["dashboard", "logs"],
|
|
17
|
+
analytic: ["dashboard"],
|
|
18
|
+
};
|
|
19
|
+
static roleAllows(role, capability) {
|
|
20
|
+
const caps = MonitorAuth.ROLE_CAPS[role] ?? MonitorAuth.ROLE_CAPS.admin;
|
|
21
|
+
return caps.includes(capability);
|
|
22
|
+
}
|
|
23
|
+
static describeRole(role) {
|
|
24
|
+
const r = role;
|
|
25
|
+
return { role: MonitorAuth.ROLE_CAPS[r] ? r : "admin",
|
|
26
|
+
capabilities: MonitorAuth.ROLE_CAPS[r] ?? MonitorAuth.ROLE_CAPS.admin };
|
|
27
|
+
}
|
|
28
|
+
static authFile = null;
|
|
29
|
+
static projectKey = "default";
|
|
30
|
+
static enrolled = new Map();
|
|
31
|
+
static storeLoaded = false;
|
|
32
|
+
static fileSafe(name) {
|
|
33
|
+
const safe = String(name || "").replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^_+|_+$/g, "");
|
|
34
|
+
return safe.length > 0 ? safe.slice(0, 64) : "default";
|
|
35
|
+
}
|
|
36
|
+
static configure(opts) {
|
|
37
|
+
const authFile = opts?.authFile;
|
|
38
|
+
const authDir = opts?.authDir;
|
|
39
|
+
const project = opts?.projectName;
|
|
40
|
+
if (authFile && authFile.length > 0)
|
|
41
|
+
MonitorAuth.authFile = authFile;
|
|
42
|
+
else if (authDir && authDir.length > 0)
|
|
43
|
+
MonitorAuth.authFile = path_1.default.join(authDir, `monitor-2fa.${MonitorAuth.fileSafe(project ?? "")}.json`);
|
|
44
|
+
else {
|
|
45
|
+
const dir = AppDataPath_1.AppData.dir("");
|
|
46
|
+
MonitorAuth.authFile = dir ? path_1.default.join(dir, "monitor-2fa.json") : null;
|
|
47
|
+
}
|
|
48
|
+
MonitorAuth.projectKey = (project && project.length > 0 ? project : "default");
|
|
49
|
+
MonitorAuth.stopWatchingStore();
|
|
50
|
+
MonitorAuth.enrolled.clear();
|
|
51
|
+
MonitorAuth.storeHash = "";
|
|
52
|
+
MonitorAuth.refusedHash = "";
|
|
53
|
+
MonitorAuth.missingSince = 0;
|
|
54
|
+
MonitorAuth.storeLoaded = false;
|
|
55
|
+
MonitorAuth.loadStore();
|
|
56
|
+
if (!MonitorAuth.authFile)
|
|
57
|
+
(0, LogService_1.logWarn)(`Monitor 2FA: no monitorAuthFile / monitorAuthDir and ${AppDataPath_1.AppData.root()} can't be created — enrollments live in memory only and are LOST on restart`);
|
|
58
|
+
}
|
|
59
|
+
static storeHash = "";
|
|
60
|
+
static refusedHash = "";
|
|
61
|
+
static storeWatcher = null;
|
|
62
|
+
static storePoll = null;
|
|
63
|
+
static storeDebounce = null;
|
|
64
|
+
static missingSince = 0;
|
|
65
|
+
static sectionOf(doc) {
|
|
66
|
+
const section = doc?.projects?.[MonitorAuth.projectKey]?.users ?? doc?.users ?? {};
|
|
67
|
+
const out = new Map();
|
|
68
|
+
for (const [login, rec] of Object.entries(section ?? {})) {
|
|
69
|
+
const r = rec;
|
|
70
|
+
if (r && typeof r.secret === "string" && r.secret.length > 0)
|
|
71
|
+
out.set(login, { secret: r.secret, enrolledAt: Number(r.enrolledAt) || 0, lastCounter: Number(r.lastCounter) || 0 });
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
static loadStore() {
|
|
76
|
+
if (MonitorAuth.storeLoaded)
|
|
77
|
+
return;
|
|
78
|
+
MonitorAuth.storeLoaded = true;
|
|
79
|
+
if (!MonitorAuth.authFile)
|
|
80
|
+
return;
|
|
81
|
+
MonitorAuth.reloadStore(true);
|
|
82
|
+
MonitorAuth.watchStore();
|
|
83
|
+
}
|
|
84
|
+
static reloadStore(initial = false) {
|
|
85
|
+
const file = MonitorAuth.authFile;
|
|
86
|
+
if (!file)
|
|
87
|
+
return;
|
|
88
|
+
let raw = null;
|
|
89
|
+
try {
|
|
90
|
+
raw = fs_1.default.readFileSync(file, "utf-8");
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
if (e?.code !== "ENOENT") {
|
|
94
|
+
(0, LogService_1.logWarn)(`Monitor 2FA: cannot read ${file} (${e?.message ?? e}) — keeping current enrollments`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
let next;
|
|
99
|
+
let hash;
|
|
100
|
+
if (raw === null) {
|
|
101
|
+
if (!initial && MonitorAuth.storeHash !== "missing") {
|
|
102
|
+
if (!MonitorAuth.missingSince) {
|
|
103
|
+
MonitorAuth.missingSince = Date.now();
|
|
104
|
+
setTimeout(() => MonitorAuth.reloadStore(), 1000).unref();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (Date.now() - MonitorAuth.missingSince < 900)
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
next = new Map();
|
|
111
|
+
hash = "missing";
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
MonitorAuth.missingSince = 0;
|
|
115
|
+
hash = crypto_1.default.createHash("sha256").update(raw).digest("hex");
|
|
116
|
+
if (hash === MonitorAuth.storeHash || hash === MonitorAuth.refusedHash)
|
|
117
|
+
return;
|
|
118
|
+
try {
|
|
119
|
+
next = MonitorAuth.sectionOf(JSON.parse(raw));
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
MonitorAuth.refusedHash = hash;
|
|
123
|
+
(0, LogService_1.logError)(`Monitor 2FA: ${file} is not valid JSON (${e?.message ?? e}) — change ignored, keeping current enrollments`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
MonitorAuth.missingSince = 0;
|
|
128
|
+
if (hash === MonitorAuth.storeHash)
|
|
129
|
+
return;
|
|
130
|
+
MonitorAuth.storeHash = hash;
|
|
131
|
+
MonitorAuth.refusedHash = "";
|
|
132
|
+
for (const [login, rec] of MonitorAuth.enrolled) {
|
|
133
|
+
const now = next.get(login);
|
|
134
|
+
if (now && now.secret === rec.secret)
|
|
135
|
+
continue;
|
|
136
|
+
MonitorAuth.revokeAllFor(login);
|
|
137
|
+
MonitorAuth.usedTotpCounter.delete(login);
|
|
138
|
+
(0, LogService_1.logWarn)(`Monitor 2FA: enrollment of "${login}" ${now ? "changed" : "removed"} — sessions revoked${now ? "" : ", the next login enrolls again"}`, "MonitorAuth");
|
|
139
|
+
}
|
|
140
|
+
MonitorAuth.enrolled = next;
|
|
141
|
+
if (raw !== null) {
|
|
142
|
+
try {
|
|
143
|
+
const mode = fs_1.default.statSync(file).mode;
|
|
144
|
+
if (mode & 0o077)
|
|
145
|
+
(0, LogService_1.logWarn)(`Monitor 2FA: ${file} is readable by other users (mode ${(mode & 0o777).toString(8)}) — chmod 600 it`);
|
|
146
|
+
}
|
|
147
|
+
catch { }
|
|
148
|
+
}
|
|
149
|
+
if (initial)
|
|
150
|
+
(0, LogService_1.logInfo)(`Monitor 2FA: loaded ${next.size} enrollment(s) for project "${MonitorAuth.projectKey}" from ${file}`, "MonitorAuth");
|
|
151
|
+
else
|
|
152
|
+
(0, LogService_1.logInfo)(`Monitor 2FA: reloaded ${file} — ${next.size} enrollment(s)`, "MonitorAuth");
|
|
153
|
+
}
|
|
154
|
+
static watchStore() {
|
|
155
|
+
const file = MonitorAuth.authFile;
|
|
156
|
+
if (!file)
|
|
157
|
+
return;
|
|
158
|
+
MonitorAuth.stopWatchingStore();
|
|
159
|
+
const dir = path_1.default.dirname(file), name = path_1.default.basename(file);
|
|
160
|
+
try {
|
|
161
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
162
|
+
MonitorAuth.storeWatcher = fs_1.default.watch(dir, (_event, filename) => {
|
|
163
|
+
if (filename && filename !== name)
|
|
164
|
+
return;
|
|
165
|
+
if (MonitorAuth.storeDebounce)
|
|
166
|
+
clearTimeout(MonitorAuth.storeDebounce);
|
|
167
|
+
MonitorAuth.storeDebounce = setTimeout(() => { MonitorAuth.storeDebounce = null; MonitorAuth.reloadStore(); }, 200);
|
|
168
|
+
});
|
|
169
|
+
MonitorAuth.storeWatcher.unref();
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
(0, LogService_1.logWarn)(`Monitor 2FA: cannot watch ${dir} (${e?.message ?? e}) — changes are picked up within a minute`);
|
|
173
|
+
}
|
|
174
|
+
MonitorAuth.storePoll = setInterval(() => MonitorAuth.reloadStore(), 60_000);
|
|
175
|
+
MonitorAuth.storePoll.unref();
|
|
176
|
+
}
|
|
177
|
+
static stopWatchingStore() {
|
|
178
|
+
MonitorAuth.storeWatcher?.close();
|
|
179
|
+
MonitorAuth.storeWatcher = null;
|
|
180
|
+
if (MonitorAuth.storePoll)
|
|
181
|
+
clearInterval(MonitorAuth.storePoll);
|
|
182
|
+
MonitorAuth.storePoll = null;
|
|
183
|
+
}
|
|
184
|
+
static saveEnrollment(login, rec) {
|
|
185
|
+
const file = MonitorAuth.authFile;
|
|
186
|
+
if (!file)
|
|
187
|
+
return true;
|
|
188
|
+
try {
|
|
189
|
+
let doc = { version: 1, projects: {} };
|
|
190
|
+
try {
|
|
191
|
+
const existing = JSON.parse(fs_1.default.readFileSync(file, "utf-8"));
|
|
192
|
+
if (existing && typeof existing === "object")
|
|
193
|
+
doc = { version: 1, projects: existing.projects ?? {} };
|
|
194
|
+
if (existing?.users && !existing.projects?.[MonitorAuth.projectKey])
|
|
195
|
+
doc.projects[MonitorAuth.projectKey] = { users: existing.users };
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
if (e?.code !== "ENOENT") {
|
|
199
|
+
(0, LogService_1.logError)(`Monitor 2FA: cannot update ${file} (${e?.message ?? e}) — enrollment not saved`);
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const section = doc.projects[MonitorAuth.projectKey] ?? { users: {} };
|
|
204
|
+
section.users = { ...(section.users ?? {}), [login]: rec };
|
|
205
|
+
doc.projects[MonitorAuth.projectKey] = section;
|
|
206
|
+
const text = JSON.stringify(doc, null, 2);
|
|
207
|
+
const tmp = file + ".tmp";
|
|
208
|
+
fs_1.default.mkdirSync(path_1.default.dirname(file), { recursive: true });
|
|
209
|
+
fs_1.default.writeFileSync(tmp, text, { encoding: "utf-8", mode: 0o600 });
|
|
210
|
+
fs_1.default.renameSync(tmp, file);
|
|
211
|
+
const prev = MonitorAuth.enrolled;
|
|
212
|
+
MonitorAuth.enrolled = MonitorAuth.sectionOf(doc);
|
|
213
|
+
for (const [l, r] of prev)
|
|
214
|
+
if (!MonitorAuth.enrolled.has(l) || MonitorAuth.enrolled.get(l).secret !== r.secret) {
|
|
215
|
+
MonitorAuth.revokeAllFor(l);
|
|
216
|
+
(0, LogService_1.logWarn)(`Monitor 2FA: enrollment of "${l}" was removed on disk — sessions revoked`, "MonitorAuth");
|
|
217
|
+
}
|
|
218
|
+
MonitorAuth.storeHash = crypto_1.default.createHash("sha256").update(text).digest("hex");
|
|
219
|
+
MonitorAuth.missingSince = 0;
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
catch (e) {
|
|
223
|
+
(0, LogService_1.logWarn)("Monitor 2FA: cannot persist store: " + (e?.message ?? e));
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
static secretFor(user) {
|
|
228
|
+
MonitorAuth.loadStore();
|
|
229
|
+
if (user?.totpSecret)
|
|
230
|
+
return user.totpSecret;
|
|
231
|
+
return MonitorAuth.enrolled.get(user?.login)?.secret ?? null;
|
|
232
|
+
}
|
|
233
|
+
static isEnrolled(user) {
|
|
234
|
+
return !!MonitorAuth.secretFor(user);
|
|
235
|
+
}
|
|
236
|
+
static MIN_PASSWORD_LENGTH = 12;
|
|
237
|
+
static SESSION_IDLE_MS = 15 * 60 * 1000;
|
|
238
|
+
static SESSION_MAX_MS = 8 * 60 * 60 * 1000;
|
|
239
|
+
static MAX_FAILED_ATTEMPTS = 10;
|
|
240
|
+
static LOCKOUT_MS = 30 * 60 * 1000;
|
|
241
|
+
static sessions = new Map();
|
|
242
|
+
static failures = new Map();
|
|
243
|
+
static usedTotpCounter = new Map();
|
|
244
|
+
static passwordPolicyError(password) {
|
|
245
|
+
if (typeof password !== "string" || password.length === 0)
|
|
246
|
+
return "password is empty";
|
|
247
|
+
if (password.trim().length === 0)
|
|
248
|
+
return "password is whitespace only";
|
|
249
|
+
if (password.length < MonitorAuth.MIN_PASSWORD_LENGTH)
|
|
250
|
+
return `password must be at least ${MonitorAuth.MIN_PASSWORD_LENGTH} characters`;
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
static compliantUsers(users) {
|
|
254
|
+
return users.filter(u => u && typeof u.login === "string" && u.login.length > 0
|
|
255
|
+
&& PasswordHash_1.PasswordHash.isHash(u.password));
|
|
256
|
+
}
|
|
257
|
+
static policyReportFor(users) {
|
|
258
|
+
const out = [];
|
|
259
|
+
for (const u of users || []) {
|
|
260
|
+
const reason = !u?.login ? "login is empty"
|
|
261
|
+
: PasswordHash_1.PasswordHash.isHash(u.password) ? null
|
|
262
|
+
: MonitorAuth.PLAINTEXT_ERROR;
|
|
263
|
+
if (reason)
|
|
264
|
+
out.push(`${u?.login || "<no login>"}: ${reason}`);
|
|
265
|
+
}
|
|
266
|
+
return out;
|
|
267
|
+
}
|
|
268
|
+
static PLAINTEXT_ERROR = "password is built incorrectly — the config must hold a hash from `npx bmfk hash-password`, not the password itself";
|
|
269
|
+
static plaintextLogins(users) {
|
|
270
|
+
return (users || []).filter(u => u?.login && !PasswordHash_1.PasswordHash.isHash(u.password)).map(u => u.login);
|
|
271
|
+
}
|
|
272
|
+
static base32Decode(input) {
|
|
273
|
+
const A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
274
|
+
let bits = 0, value = 0;
|
|
275
|
+
const out = [];
|
|
276
|
+
for (const ch of input.replace(/=+$/, "").replace(/\s+/g, "").toUpperCase()) {
|
|
277
|
+
const idx = A.indexOf(ch);
|
|
278
|
+
if (idx < 0)
|
|
279
|
+
throw new Error("invalid base32 in TOTP secret");
|
|
280
|
+
value = (value << 5) | idx;
|
|
281
|
+
bits += 5;
|
|
282
|
+
if (bits >= 8) {
|
|
283
|
+
out.push((value >>> (bits - 8)) & 0xff);
|
|
284
|
+
bits -= 8;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return Buffer.from(out);
|
|
288
|
+
}
|
|
289
|
+
static hotp(secret, counter) {
|
|
290
|
+
const buf = Buffer.alloc(8);
|
|
291
|
+
buf.writeUInt32BE(Math.floor(counter / 0x100000000), 0);
|
|
292
|
+
buf.writeUInt32BE(counter >>> 0, 4);
|
|
293
|
+
const h = crypto_1.default.createHmac("sha1", secret).update(buf).digest();
|
|
294
|
+
const off = h[h.length - 1] & 0x0f;
|
|
295
|
+
const code = ((h[off] & 0x7f) << 24) | ((h[off + 1] & 0xff) << 16)
|
|
296
|
+
| ((h[off + 2] & 0xff) << 8) | (h[off + 3] & 0xff);
|
|
297
|
+
return String(code % 1000000).padStart(6, "0");
|
|
298
|
+
}
|
|
299
|
+
static verifyTotp(login, secretBase32, code) {
|
|
300
|
+
if (!/^\d{6}$/.test(String(code || "").trim()))
|
|
301
|
+
return "TOTP code must be 6 digits";
|
|
302
|
+
let secret;
|
|
303
|
+
try {
|
|
304
|
+
secret = MonitorAuth.base32Decode(secretBase32);
|
|
305
|
+
}
|
|
306
|
+
catch {
|
|
307
|
+
return "TOTP secret is not valid base32";
|
|
308
|
+
}
|
|
309
|
+
const counter = Math.floor(Date.now() / 1000 / 30);
|
|
310
|
+
const given = String(code).trim();
|
|
311
|
+
for (const c of [counter, counter - 1, counter + 1]) {
|
|
312
|
+
const expected = MonitorAuth.hotp(secret, c);
|
|
313
|
+
const a = Buffer.from(expected), b = Buffer.from(given);
|
|
314
|
+
if (a.length === b.length && crypto_1.default.timingSafeEqual(a, b)) {
|
|
315
|
+
const last = MonitorAuth.usedTotpCounter.get(login);
|
|
316
|
+
if (last !== undefined && c <= last)
|
|
317
|
+
return "TOTP code already used";
|
|
318
|
+
MonitorAuth.usedTotpCounter.set(login, c);
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return "TOTP code is invalid";
|
|
323
|
+
}
|
|
324
|
+
static base32Encode(buf) {
|
|
325
|
+
const A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
326
|
+
let bits = 0, value = 0, out = "";
|
|
327
|
+
for (const b of buf) {
|
|
328
|
+
value = (value << 8) | b;
|
|
329
|
+
bits += 8;
|
|
330
|
+
while (bits >= 5) {
|
|
331
|
+
out += A[(value >>> (bits - 5)) & 31];
|
|
332
|
+
bits -= 5;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (bits > 0)
|
|
336
|
+
out += A[(value << (5 - bits)) & 31];
|
|
337
|
+
return out;
|
|
338
|
+
}
|
|
339
|
+
static generateTotpSecret(login, issuer = "Monitor") {
|
|
340
|
+
const secret = MonitorAuth.base32Encode(crypto_1.default.randomBytes(20));
|
|
341
|
+
const safeIssuer = String(issuer || "").replace(/[:\u0000-\u001f]/g, " ").trim() || "Monitor";
|
|
342
|
+
const label = encodeURIComponent(`${safeIssuer}:${login}`);
|
|
343
|
+
const uri = `otpauth://totp/${label}?secret=${secret}&issuer=${encodeURIComponent(safeIssuer)}&algorithm=SHA1&digits=6&period=30`;
|
|
344
|
+
return { secret, uri };
|
|
345
|
+
}
|
|
346
|
+
static lockoutRemainingMs(login) {
|
|
347
|
+
const f = MonitorAuth.failures.get(login);
|
|
348
|
+
if (!f || f.lockedUntil <= Date.now())
|
|
349
|
+
return 0;
|
|
350
|
+
return f.lockedUntil - Date.now();
|
|
351
|
+
}
|
|
352
|
+
static registerFailure(login) {
|
|
353
|
+
const f = MonitorAuth.failures.get(login) ?? { count: 0, lockedUntil: 0 };
|
|
354
|
+
f.count++;
|
|
355
|
+
if (f.count >= MonitorAuth.MAX_FAILED_ATTEMPTS) {
|
|
356
|
+
f.lockedUntil = Date.now() + MonitorAuth.LOCKOUT_MS;
|
|
357
|
+
f.count = 0;
|
|
358
|
+
}
|
|
359
|
+
MonitorAuth.failures.set(login, f);
|
|
360
|
+
}
|
|
361
|
+
static clearFailures(login) {
|
|
362
|
+
MonitorAuth.failures.delete(login);
|
|
363
|
+
}
|
|
364
|
+
static sameSecret(a, b) {
|
|
365
|
+
const x = Buffer.from(String(a), "utf-8"), y = Buffer.from(String(b), "utf-8");
|
|
366
|
+
return x.length === y.length && crypto_1.default.timingSafeEqual(x, y);
|
|
367
|
+
}
|
|
368
|
+
static async authenticate(users, login, password, totp) {
|
|
369
|
+
const locked = MonitorAuth.lockoutRemainingMs(login);
|
|
370
|
+
if (locked > 0)
|
|
371
|
+
return { error: `account locked, try again in ${Math.ceil(locked / 60000)} min` };
|
|
372
|
+
const all = users || [];
|
|
373
|
+
const candidate = all.find(u => u?.login === login);
|
|
374
|
+
if (!candidate) {
|
|
375
|
+
MonitorAuth.registerFailure(login);
|
|
376
|
+
return { error: "Invalid user" };
|
|
377
|
+
}
|
|
378
|
+
if (!PasswordHash_1.PasswordHash.isHash(candidate.password)) {
|
|
379
|
+
const matches = typeof candidate.password === "string" && candidate.password.length > 0
|
|
380
|
+
&& MonitorAuth.sameSecret(candidate.password, password || "");
|
|
381
|
+
if (matches)
|
|
382
|
+
(0, LogService_1.logError)(`Monitor: "${login}" signed in with the right password, but it is stored in the config as plain text — refused; store a hash: npx bmfk hash-password`);
|
|
383
|
+
MonitorAuth.registerFailure(login);
|
|
384
|
+
return { error: "Invalid user" };
|
|
385
|
+
}
|
|
386
|
+
if (!(await PasswordHash_1.PasswordHash.verify(password || "", candidate.password))) {
|
|
387
|
+
MonitorAuth.registerFailure(login);
|
|
388
|
+
return { error: "Invalid user" };
|
|
389
|
+
}
|
|
390
|
+
const secret = MonitorAuth.secretFor(candidate);
|
|
391
|
+
if (!secret) {
|
|
392
|
+
MonitorAuth.clearFailures(login);
|
|
393
|
+
return { user: candidate, enrollmentRequired: true };
|
|
394
|
+
}
|
|
395
|
+
const totpError = MonitorAuth.verifyTotp(login, secret, totp || "");
|
|
396
|
+
if (totpError) {
|
|
397
|
+
MonitorAuth.registerFailure(login);
|
|
398
|
+
return { error: totpError };
|
|
399
|
+
}
|
|
400
|
+
MonitorAuth.clearFailures(login);
|
|
401
|
+
return { user: candidate };
|
|
402
|
+
}
|
|
403
|
+
static pendingEnrollments = new Map();
|
|
404
|
+
static ENROLLMENT_TTL_MS = 10 * 60 * 1000;
|
|
405
|
+
static beginEnrollment(login, issuer = "Monitor", label = login) {
|
|
406
|
+
const now = Date.now();
|
|
407
|
+
for (const [t, p] of MonitorAuth.pendingEnrollments)
|
|
408
|
+
if (now - p.createdAt > MonitorAuth.ENROLLMENT_TTL_MS)
|
|
409
|
+
MonitorAuth.pendingEnrollments.delete(t);
|
|
410
|
+
const { secret, uri } = MonitorAuth.generateTotpSecret(label, issuer);
|
|
411
|
+
const token = crypto_1.default.randomBytes(32).toString("hex");
|
|
412
|
+
MonitorAuth.pendingEnrollments.set(token, { login, secret, createdAt: now });
|
|
413
|
+
return { token, secret, uri };
|
|
414
|
+
}
|
|
415
|
+
static completeEnrollment(token, code) {
|
|
416
|
+
const pending = MonitorAuth.pendingEnrollments.get(token);
|
|
417
|
+
if (!pending)
|
|
418
|
+
return { error: "enrollment session expired, start again" };
|
|
419
|
+
if (Date.now() - pending.createdAt > MonitorAuth.ENROLLMENT_TTL_MS) {
|
|
420
|
+
MonitorAuth.pendingEnrollments.delete(token);
|
|
421
|
+
return { error: "enrollment session expired, start again" };
|
|
422
|
+
}
|
|
423
|
+
if (MonitorAuth.enrolled.has(pending.login))
|
|
424
|
+
return { error: "already enrolled" };
|
|
425
|
+
const err = MonitorAuth.verifyTotp(pending.login, pending.secret, code);
|
|
426
|
+
if (err)
|
|
427
|
+
return { error: err };
|
|
428
|
+
const rec = { secret: pending.secret, enrolledAt: Date.now(), lastCounter: 0 };
|
|
429
|
+
MonitorAuth.pendingEnrollments.delete(token);
|
|
430
|
+
if (MonitorAuth.authFile) {
|
|
431
|
+
if (!MonitorAuth.saveEnrollment(pending.login, rec))
|
|
432
|
+
return { error: "cannot save the enrollment on the server, try again later" };
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
MonitorAuth.enrolled.set(pending.login, rec);
|
|
436
|
+
}
|
|
437
|
+
(0, LogService_1.logInfo)(`Monitor 2FA enrolled for "${pending.login}"`, "MonitorAuth");
|
|
438
|
+
return { login: pending.login };
|
|
439
|
+
}
|
|
440
|
+
static purgeSessions(now) {
|
|
441
|
+
for (const [token, s] of MonitorAuth.sessions) {
|
|
442
|
+
if (now - s.lastSeenAt > MonitorAuth.SESSION_IDLE_MS || now - s.createdAt > MonitorAuth.SESSION_MAX_MS)
|
|
443
|
+
MonitorAuth.sessions.delete(token);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
static createSession(login) {
|
|
447
|
+
const now = Date.now();
|
|
448
|
+
MonitorAuth.purgeSessions(now);
|
|
449
|
+
const session = {
|
|
450
|
+
token: crypto_1.default.randomBytes(32).toString("hex"),
|
|
451
|
+
login, createdAt: now, lastSeenAt: now,
|
|
452
|
+
};
|
|
453
|
+
MonitorAuth.sessions.set(session.token, session);
|
|
454
|
+
return session;
|
|
455
|
+
}
|
|
456
|
+
static touchSession(token) {
|
|
457
|
+
const now = Date.now();
|
|
458
|
+
MonitorAuth.purgeSessions(now);
|
|
459
|
+
const s = MonitorAuth.sessions.get(token);
|
|
460
|
+
if (!s)
|
|
461
|
+
return null;
|
|
462
|
+
s.lastSeenAt = now;
|
|
463
|
+
return s;
|
|
464
|
+
}
|
|
465
|
+
static revokeSession(token) {
|
|
466
|
+
MonitorAuth.sessions.delete(token);
|
|
467
|
+
}
|
|
468
|
+
static revokeAllFor(login) {
|
|
469
|
+
for (const [token, s] of MonitorAuth.sessions)
|
|
470
|
+
if (s.login === login)
|
|
471
|
+
MonitorAuth.sessions.delete(token);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
exports.MonitorAuth = MonitorAuth;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
export declare class ProcessMonitor {
|
|
2
|
+
private static _inited;
|
|
3
|
+
private static _eld;
|
|
4
|
+
private static _gcObserver;
|
|
5
|
+
private static _gc;
|
|
6
|
+
private static _prevCpu;
|
|
7
|
+
private static _prevCpuAt;
|
|
8
|
+
private static _cpuPct;
|
|
9
|
+
private static _eluPrev;
|
|
10
|
+
private static _elu;
|
|
11
|
+
private static _processStartedAt;
|
|
12
|
+
private static _fdHistory;
|
|
13
|
+
private static _fdHistoryMax;
|
|
14
|
+
private static _fdSampleEveryMs;
|
|
15
|
+
static init(): void;
|
|
16
|
+
private static _sampleFdSeries;
|
|
17
|
+
private static _sampleCpu;
|
|
18
|
+
private static _sampleELU;
|
|
19
|
+
private static _mapGcKind;
|
|
20
|
+
static getSnapshot(): Promise<{
|
|
21
|
+
identity: {
|
|
22
|
+
pid: number;
|
|
23
|
+
ppid: number;
|
|
24
|
+
title: string;
|
|
25
|
+
argv: string[];
|
|
26
|
+
execPath: string;
|
|
27
|
+
cwd: string;
|
|
28
|
+
nodeVersion: string;
|
|
29
|
+
v8Version: string;
|
|
30
|
+
platform: NodeJS.Platform;
|
|
31
|
+
arch: NodeJS.Architecture;
|
|
32
|
+
hostname: string;
|
|
33
|
+
user: {
|
|
34
|
+
uid: number;
|
|
35
|
+
gid: number;
|
|
36
|
+
} | null;
|
|
37
|
+
startedAtUnix: number;
|
|
38
|
+
uptimeSec: number;
|
|
39
|
+
availableParallelism: number;
|
|
40
|
+
pm2: {
|
|
41
|
+
managed: boolean;
|
|
42
|
+
name: string | null;
|
|
43
|
+
pmId: string | null;
|
|
44
|
+
instanceId: string | null;
|
|
45
|
+
execPath: string | null;
|
|
46
|
+
cwd: string | null;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
memory: {
|
|
50
|
+
rss: number;
|
|
51
|
+
heapTotal: number;
|
|
52
|
+
heapUsed: number;
|
|
53
|
+
external: number;
|
|
54
|
+
arrayBuffers: any;
|
|
55
|
+
heap: {
|
|
56
|
+
sizeLimit: number;
|
|
57
|
+
usedHeap: number;
|
|
58
|
+
totalAvailable: number;
|
|
59
|
+
totalPhysical: number;
|
|
60
|
+
mallocedMemory: number;
|
|
61
|
+
peakMallocedMemory: number;
|
|
62
|
+
numberOfNativeContexts: number;
|
|
63
|
+
numberOfDetachedContexts: number;
|
|
64
|
+
};
|
|
65
|
+
heapSpaces: {
|
|
66
|
+
name: string;
|
|
67
|
+
size: number;
|
|
68
|
+
used: number;
|
|
69
|
+
available: number;
|
|
70
|
+
physical: number;
|
|
71
|
+
}[];
|
|
72
|
+
procStatus: Record<string, number> | null;
|
|
73
|
+
};
|
|
74
|
+
cpu: {
|
|
75
|
+
userPct: number;
|
|
76
|
+
systemPct: number;
|
|
77
|
+
userMicros: number;
|
|
78
|
+
systemMicros: number;
|
|
79
|
+
resource: any;
|
|
80
|
+
};
|
|
81
|
+
eventLoop: {
|
|
82
|
+
minMs: number;
|
|
83
|
+
maxMs: number;
|
|
84
|
+
meanMs: number;
|
|
85
|
+
stddevMs: number;
|
|
86
|
+
p50Ms: number;
|
|
87
|
+
p90Ms: number;
|
|
88
|
+
p99Ms: number;
|
|
89
|
+
utilizationPct: number;
|
|
90
|
+
activeHandles: number;
|
|
91
|
+
activeRequests: number;
|
|
92
|
+
spotLagMs: number;
|
|
93
|
+
} | null;
|
|
94
|
+
gc: {
|
|
95
|
+
totalCount: number;
|
|
96
|
+
totalTimeMs: number;
|
|
97
|
+
maxPauseMs: number;
|
|
98
|
+
byKind: Record<string, {
|
|
99
|
+
count: number;
|
|
100
|
+
timeMs: number;
|
|
101
|
+
}>;
|
|
102
|
+
lastPauses: {
|
|
103
|
+
kind: string;
|
|
104
|
+
ms: number;
|
|
105
|
+
timestamp: number;
|
|
106
|
+
}[];
|
|
107
|
+
};
|
|
108
|
+
fileDescriptors: {
|
|
109
|
+
open: number | null;
|
|
110
|
+
limitSoft: number | null;
|
|
111
|
+
limitHard: number | null;
|
|
112
|
+
};
|
|
113
|
+
sockets: {
|
|
114
|
+
total: number;
|
|
115
|
+
byState: Record<string, number>;
|
|
116
|
+
topRemotes: Array<{
|
|
117
|
+
host: string;
|
|
118
|
+
established: number;
|
|
119
|
+
}>;
|
|
120
|
+
} | null;
|
|
121
|
+
io: Record<string, number> | null;
|
|
122
|
+
limits: Record<string, {
|
|
123
|
+
soft: string;
|
|
124
|
+
hard: string;
|
|
125
|
+
unit: string;
|
|
126
|
+
}> | null;
|
|
127
|
+
}>;
|
|
128
|
+
static getPm2Identity(): {
|
|
129
|
+
managed: boolean;
|
|
130
|
+
name: string | null;
|
|
131
|
+
pmId: string | null;
|
|
132
|
+
instanceId: string | null;
|
|
133
|
+
execPath: string | null;
|
|
134
|
+
cwd: string | null;
|
|
135
|
+
};
|
|
136
|
+
static getFdReport(): Promise<{
|
|
137
|
+
now: {
|
|
138
|
+
ts: number;
|
|
139
|
+
fdOpen: number | null;
|
|
140
|
+
limitSoft: number | null;
|
|
141
|
+
limitHard: number | null;
|
|
142
|
+
sockets: {
|
|
143
|
+
total: number;
|
|
144
|
+
byState: Record<string, number>;
|
|
145
|
+
topRemotes: Array<{
|
|
146
|
+
host: string;
|
|
147
|
+
established: number;
|
|
148
|
+
}>;
|
|
149
|
+
} | null;
|
|
150
|
+
};
|
|
151
|
+
sampleEveryMs: number;
|
|
152
|
+
historyMax: number;
|
|
153
|
+
history: {
|
|
154
|
+
ts: number;
|
|
155
|
+
fdOpen: number | null;
|
|
156
|
+
fdSoftLimit: number | null;
|
|
157
|
+
socketTotal: number | null;
|
|
158
|
+
byState: Record<string, number>;
|
|
159
|
+
topRemote: {
|
|
160
|
+
host: string;
|
|
161
|
+
established: number;
|
|
162
|
+
} | null;
|
|
163
|
+
rss: number;
|
|
164
|
+
}[];
|
|
165
|
+
}>;
|
|
166
|
+
private static _readProcStatus;
|
|
167
|
+
private static _readProcIo;
|
|
168
|
+
private static _readProcLimits;
|
|
169
|
+
private static _countFds;
|
|
170
|
+
private static _readSocketBreakdown;
|
|
171
|
+
private static _tcpState;
|
|
172
|
+
private static _parseHexAddr;
|
|
173
|
+
private static _parseLimitValue;
|
|
174
|
+
private static _toMsFinite;
|
|
175
|
+
private static _safePercentileMs;
|
|
176
|
+
private static _safeCount;
|
|
177
|
+
}
|