-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net,tls: pass a valid socket on
tlsClientError
On the 'tlsClientError' event, the `tlsSocket` instance is passed as `closed` status. Thus, users can't get information such as `remote address`, `remoteFamily`, and so on. This adds a flag to close a socket after emitting an `error` event. Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com PR-URL: #44021 Fixes: #43963 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
Showing
3 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const https = require('node:https'); | ||
const assert = require('node:assert'); | ||
|
||
const server = https.createServer(); | ||
|
||
server.on( | ||
'tlsClientError', | ||
common.mustCall((exception, tlsSocket) => { | ||
assert.strictEqual(exception !== undefined, true); | ||
assert.strictEqual(Object.keys(tlsSocket.address()).length !== 0, true); | ||
assert.strictEqual(tlsSocket.localAddress !== undefined, true); | ||
assert.strictEqual(tlsSocket.localPort !== undefined, true); | ||
assert.strictEqual(tlsSocket.remoteAddress !== undefined, true); | ||
assert.strictEqual(tlsSocket.remoteFamily !== undefined, true); | ||
assert.strictEqual(tlsSocket.remotePort !== undefined, true); | ||
}), | ||
); | ||
|
||
server.listen(0, () => { | ||
const req = https.request({ | ||
hostname: '127.0.0.1', | ||
port: server.address().port, | ||
}); | ||
req.on( | ||
'error', | ||
common.mustCall(() => server.close()), | ||
); | ||
req.end(); | ||
}); |