@upx-us/shield 0.3.4 → 0.3.5
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/dist/src/index.js +29 -9
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -45,8 +45,10 @@ const version_1 = require("./version");
|
|
|
45
45
|
let running = true;
|
|
46
46
|
let lastTelemetryAt = 0;
|
|
47
47
|
let consecutiveFailures = 0;
|
|
48
|
+
let registrationOk = false;
|
|
48
49
|
const TELEMETRY_INTERVAL_MS = 5 * 60 * 1000;
|
|
49
50
|
const MAX_BACKOFF_MS = 5 * 60 * 1000;
|
|
51
|
+
const MAX_REGISTRATION_FAILURES = 10;
|
|
50
52
|
function getBackoffInterval(baseMs) {
|
|
51
53
|
if (consecutiveFailures === 0)
|
|
52
54
|
return baseMs;
|
|
@@ -86,16 +88,27 @@ async function poll() {
|
|
|
86
88
|
};
|
|
87
89
|
const result = await (0, sender_1.reportInstance)(instancePayload, config.credentials);
|
|
88
90
|
log.info('bridge', `Instance report → Platform: success=${result.ok}`);
|
|
89
|
-
if (result.ok
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
if (result.ok) {
|
|
92
|
+
registrationOk = true;
|
|
93
|
+
lastTelemetryAt = now;
|
|
94
|
+
if (result.score) {
|
|
95
|
+
log.info('bridge', `Protection score: ${result.score.badge} ${result.score.total}/100 (${result.score.grade})`);
|
|
96
|
+
if (result.score.recommendations?.length) {
|
|
97
|
+
for (const rec of result.score.recommendations) {
|
|
98
|
+
log.warn('bridge', `⚠ ${rec}`);
|
|
99
|
+
}
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
|
-
if (
|
|
98
|
-
|
|
103
|
+
else if (!registrationOk) {
|
|
104
|
+
consecutiveFailures++;
|
|
105
|
+
if (consecutiveFailures >= MAX_REGISTRATION_FAILURES) {
|
|
106
|
+
log.error('bridge', `reportInstance failed ${consecutiveFailures} consecutive times — instance not recognized. Re-run setup wizard. Exiting.`);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
log.warn('bridge', `reportInstance failed (attempt ${consecutiveFailures}/${MAX_REGISTRATION_FAILURES}) — skipping events this cycle (platform may still be syncing)`);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
99
112
|
}
|
|
100
113
|
if (entries.length > 0) {
|
|
101
114
|
let envelopes = (0, transformer_1.transformEntries)(entries);
|
|
@@ -126,8 +139,15 @@ async function poll() {
|
|
|
126
139
|
}
|
|
127
140
|
}
|
|
128
141
|
if (results.some(r => r.needsRegistration)) {
|
|
129
|
-
|
|
130
|
-
|
|
142
|
+
consecutiveFailures++;
|
|
143
|
+
registrationOk = false;
|
|
144
|
+
lastTelemetryAt = 0;
|
|
145
|
+
if (consecutiveFailures >= MAX_REGISTRATION_FAILURES) {
|
|
146
|
+
log.error('bridge', `Instance not recognized by platform after ${consecutiveFailures} attempts. Re-run the setup wizard. Exiting.`);
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
log.warn('bridge', `Instance not registered on platform (attempt ${consecutiveFailures}/${MAX_REGISTRATION_FAILURES}) — will re-register on next cycle`);
|
|
150
|
+
continue;
|
|
131
151
|
}
|
|
132
152
|
const pendingResult = results.find(r => r.pendingNamespace);
|
|
133
153
|
if (pendingResult) {
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED