-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
fixed TLSSocket documentation error from Issue #3963. #14062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
55f3170
09f8564
cbbe60c
7e766ff
8b945f8
5144cf4
fda1b66
de3d050
872132e
5c41572
955ad0f
9658ac3
077508d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -876,6 +876,27 @@ socket.on('end', () => { | |
| }); | ||
| ``` | ||
|
|
||
| When using an instance of `net.Socket`, use `net.Socket` to upgrade an existing socket. Do not wrap the `net.Socket` in a `TLSSocket`. See the example below for usage of upgrading an existing socket: | ||
|
||
|
|
||
| ```js | ||
| const Socket = require('net').Socket; | ||
|
||
| const tls = require('tls'); | ||
| const sock = new Socket(); | ||
|
||
| const secureSock = tls.connect({ socket: s }, () => { | ||
| console.log('The tls socket connected.'); | ||
|
||
| }); | ||
| sock.connect({ port: 6697, host: 'irc.freenode.net' }); | ||
|
||
| ``` | ||
|
|
||
| If using TLS as the initial default rather than net.Socket, use only `tls.connect()` to upgrade the socket: | ||
|
|
||
| ```js | ||
| const tls = require('tls'); | ||
| const secureSock = tls.connect({ port: 6697, host: 'irc.freenode.net' }, () => { | ||
| console.log('The tls socket connected.'); | ||
| }); | ||
| ``` | ||
|
|
||
| ## tls.connect(path[, options][, callback]) | ||
| <!-- YAML | ||
| added: v0.11.3 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this sentence is misleading. Users still need to use
tls.connect(). Perhaps something likeWhat do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's much more clear - the original issue had a user trying to do this:
const tlsSocket = new TlsSocket(new NetSocket());And I think your wording will keep them from doing that much more clearly. Will update now!