Fix linter issues

This commit is contained in:
Sander Declerck 2025-10-31 13:56:35 +01:00
parent 04751df30c
commit 3721ca9113
No known key found for this signature in database
2 changed files with 11 additions and 11 deletions

View file

@ -14,7 +14,8 @@
}, },
"rules": { "rules": {
"eslint/no-console": "error", "eslint/no-console": "error",
"eslint/no-empty": "error" "eslint/no-empty": "error",
"eslint/no-undef": "error"
}, },
"overrides": [ "overrides": [
{ {

View file

@ -14,6 +14,15 @@ export function mitmConnect(req, clientSocket, isAllowed) {
const server = createHttpsServer(hostname, isAllowed); const server = createHttpsServer(hostname, isAllowed);
server.on("error", (err) => {
ui.writeError(`Safe-chain: HTTPS server error: ${err.message}`);
if (!clientSocket.headersSent) {
clientSocket.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");
} else if (clientSocket.writable) {
clientSocket.end();
}
});
// Establish the connection // Establish the connection
clientSocket.write("HTTP/1.1 200 Connection Established\r\n\r\n"); clientSocket.write("HTTP/1.1 200 Connection Established\r\n\r\n");
@ -46,16 +55,6 @@ function createHttpsServer(hostname, isAllowed) {
handleRequest handleRequest
); );
server.on("error", (err) => {
ui.writeError(`Safe-chain: HTTPS server error: ${err.message}`);
if (!res.headersSent) {
res.writeHead(502);
res.end("Bad Gateway");
} else if (res.writable) {
res.destroy();
}
});
return server; return server;
} }