@aikidosec/broker-client 1.0.2 → 1.0.3
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/app/client.js +32 -4
- package/app/resourceManager.js +8 -2
- package/package.json +1 -1
package/app/client.js
CHANGED
|
@@ -83,7 +83,6 @@ async function resolveInternalHostname(hostname) {
|
|
|
83
83
|
const dnsPromises = await import('dns/promises');
|
|
84
84
|
const result = await dnsPromises.resolve4(hostname);
|
|
85
85
|
const ip = result[0];
|
|
86
|
-
log.debug(`Resolved ${hostname} to ${ip} (system DNS)`);
|
|
87
86
|
return ip;
|
|
88
87
|
} catch (e) {
|
|
89
88
|
log.error(`Failed to resolve ${hostname}: ${e.message}`);
|
|
@@ -162,13 +161,11 @@ function isInternalUrl(url) {
|
|
|
162
161
|
// Not an IP, allow it through if we have custom DNS configured
|
|
163
162
|
// The actual resolution will happen in the forward_request handler
|
|
164
163
|
if (DNS_SERVERS !== null && DNS_SERVERS.length > 0) {
|
|
165
|
-
log.debug(`Hostname ${hostname} will be resolved with custom DNS during forward`);
|
|
166
164
|
return true;
|
|
167
165
|
}
|
|
168
166
|
|
|
169
167
|
// For system DNS, we can't do synchronous lookup here
|
|
170
168
|
// Allow all private hostnames through and validate during forward
|
|
171
|
-
log.debug(`Hostname ${hostname} will be validated during forward`);
|
|
172
169
|
return true;
|
|
173
170
|
}
|
|
174
171
|
}
|
|
@@ -283,6 +280,30 @@ socket.on('disconnect', () => {
|
|
|
283
280
|
log.warn("Disconnected from broker server");
|
|
284
281
|
});
|
|
285
282
|
|
|
283
|
+
socket.on('connect_error', (error) => {
|
|
284
|
+
log.error(`Socket.IO connection error: ${error.message}`);
|
|
285
|
+
if (error.description) {
|
|
286
|
+
log.error(` Description: ${JSON.stringify(error.description)}`);
|
|
287
|
+
}
|
|
288
|
+
if (error.context) {
|
|
289
|
+
log.error(` Context: ${JSON.stringify(error.context)}`);
|
|
290
|
+
}
|
|
291
|
+
log.error(` Type: ${error.type || 'unknown'}`);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// Manager events (on socket.io)
|
|
295
|
+
socket.io.on('error', (error) => {
|
|
296
|
+
log.error(`Socket.IO Manager error: ${error.message || JSON.stringify(error)}`);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
socket.io.on('reconnect_error', (error) => {
|
|
300
|
+
log.error(`Socket.IO reconnection error: ${error.message}`);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
socket.io.on('reconnect_failed', () => {
|
|
304
|
+
log.error(`Socket.IO reconnection failed after all attempts`);
|
|
305
|
+
});
|
|
306
|
+
|
|
286
307
|
socket.on('forward_request', async (data, callback) => {
|
|
287
308
|
/**
|
|
288
309
|
* Receive request from broker server and forward to internal resource
|
|
@@ -421,7 +442,14 @@ async function registerWithServer() {
|
|
|
421
442
|
log.warn(`Registration attempt ${attempt + 1} failed: ${response.status} - ${response.data}`);
|
|
422
443
|
}
|
|
423
444
|
} catch (error) {
|
|
424
|
-
|
|
445
|
+
if (error.response) {
|
|
446
|
+
// HTTP error response
|
|
447
|
+
log.warn(`Registration attempt ${attempt + 1} failed: ${error.response.status} - ${JSON.stringify(error.response.data)}`);
|
|
448
|
+
} else {
|
|
449
|
+
// Error setting up request
|
|
450
|
+
log.warn(`Registration attempt ${attempt + 1} failed: ${error.message}`);
|
|
451
|
+
}
|
|
452
|
+
|
|
425
453
|
if (getClientId() !== null) {
|
|
426
454
|
// If we have a client_id already, don't retry
|
|
427
455
|
// we should try once to deal with secret rotation
|
package/app/resourceManager.js
CHANGED
|
@@ -102,7 +102,7 @@ export class ResourceManager {
|
|
|
102
102
|
this._resources = { ...resourcesDict };
|
|
103
103
|
this._saveToFile();
|
|
104
104
|
} else {
|
|
105
|
-
log.
|
|
105
|
+
log.info("No resource changes detected");
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -183,7 +183,13 @@ export class ResourceManager {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
} catch (error) {
|
|
186
|
-
|
|
186
|
+
if (error.response) {
|
|
187
|
+
// HTTP error response
|
|
188
|
+
log.error(`Error fetching resources from broker: ${error.response.status} - ${JSON.stringify(error.response.data)}`);
|
|
189
|
+
} else {
|
|
190
|
+
// Error setting up request
|
|
191
|
+
log.error(`Error fetching resources from broker: ${error.message}`);
|
|
192
|
+
}
|
|
187
193
|
}
|
|
188
194
|
}
|
|
189
195
|
|
package/package.json
CHANGED