@aikidosec/safe-chain 1.1.1 → 1.1.2
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/package.json
CHANGED
|
@@ -35,7 +35,9 @@ function tunnelRequestToDestination(req, clientSocket, head) {
|
|
|
35
35
|
ui.writeError(
|
|
36
36
|
`Safe-chain: error connecting to ${hostname}:${port} - ${err.message}`
|
|
37
37
|
);
|
|
38
|
-
clientSocket.
|
|
38
|
+
if (clientSocket.writable) {
|
|
39
|
+
clientSocket.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");
|
|
40
|
+
}
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -76,8 +78,12 @@ function tunnelRequestViaProxy(req, clientSocket, head, proxyUrl) {
|
|
|
76
78
|
ui.writeError(
|
|
77
79
|
`Safe-chain: proxy CONNECT failed: ${response.split("\r\n")[0]}`
|
|
78
80
|
);
|
|
79
|
-
clientSocket.
|
|
80
|
-
|
|
81
|
+
if (clientSocket.writable) {
|
|
82
|
+
clientSocket.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");
|
|
83
|
+
}
|
|
84
|
+
if (proxySocket.writable) {
|
|
85
|
+
proxySocket.end();
|
|
86
|
+
}
|
|
81
87
|
}
|
|
82
88
|
});
|
|
83
89
|
|
|
@@ -88,11 +94,15 @@ function tunnelRequestViaProxy(req, clientSocket, head, proxyUrl) {
|
|
|
88
94
|
proxy.port || 8080
|
|
89
95
|
} - ${err.message}`
|
|
90
96
|
);
|
|
91
|
-
clientSocket.
|
|
97
|
+
if (clientSocket.writable) {
|
|
98
|
+
clientSocket.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");
|
|
99
|
+
}
|
|
92
100
|
}
|
|
93
101
|
});
|
|
94
102
|
|
|
95
103
|
clientSocket.on("error", () => {
|
|
96
|
-
proxySocket.
|
|
104
|
+
if (proxySocket.writable) {
|
|
105
|
+
proxySocket.end();
|
|
106
|
+
}
|
|
97
107
|
});
|
|
98
108
|
}
|