Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion swarmserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ module.exports.CreateSwarmServer = function (parent, db, args, certificates) {
// A client certificate is required
if ((this.tag.clientCert == null) || (this.tag.clientCert.subject == null)) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🔴 Unwrapped this.write() for no-client-cert response in swarmserver.js

In the onData function, wrapped the this.write('HTTP/1.1 200 OK...No client certificate given.') call at the no-client-cert branch in a try { ... } catch (ex) { } block, matching the existing codebase convention seen elsewhere in this same file (e.g. relaySocket.write calls) for guarding sends against already-closed sockets.

🤖 Prompt for AI agents
In swarmserver.js around line 177, review and complete this code-review fix: Unwrapped this.write() for no-client-cert response in swarmserver.js.
What the draft fix changed: In the `onData` function, wrapped the `this.write('HTTP/1.1 200 OK...No client certificate given.')` call at the no-client-cert branch in a `try { ... } catch (ex) { }` block, matching the existing codebase convention seen elsewhere in this same file (e.g. relaySocket.write calls) for guarding sends against already-closed sockets.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer

/*console.log("Swarm Connection, no client cert: " + socket.remoteAddress);*/
this.write('HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nConnection: close\r\n\r\nMeshCentral2 legacy swarm server.\r\nNo client certificate given.');
try { this.write('HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nConnection: close\r\n\r\nMeshCentral2 legacy swarm server.\r\nNo client certificate given.'); } catch (ex) { }
//this.end(); // If we don't close the connection, it may lead to less reconnection traffic.
return;
}
Expand Down Expand Up @@ -432,3 +432,4 @@ module.exports.CreateSwarmServer = function (parent, db, args, certificates) {

return obj;
};