選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
Muqriz 48f16bfc3e initail first 4ヶ月前
..
LICENSE initail first 4ヶ月前
README.md initail first 4ヶ月前
index.js initail first 4ヶ月前
package.json initail first 4ヶ月前

README.md

resolve-alpn

Node CI codecov

API

resolveALPN(options, connect = tls.connect)

Returns an object with an alpnProtocol property. The socket property may be also present.

const result = await resolveALPN({
	host: 'nghttp2.org',
	port: 443,
	ALPNProtocols: ['h2', 'http/1.1'],
	servername: 'nghttp2.org'
});

console.log(result); // {alpnProtocol: 'h2'}

Note: While the servername option is not required in this case, many other servers do. It’s best practice to set it anyway.

Note: If the socket times out, the promise will resolve and result.timeout will be set to true.

options

Same as TLS options.

options.resolveSocket

By default, the socket gets destroyed and the promise resolves.
If you set this to true, it will return the socket in a socket property.

const result = await resolveALPN({
	host: 'nghttp2.org',
	port: 443,
	ALPNProtocols: ['h2', 'http/1.1'],
	servername: 'nghttp2.org',
	resolveSocket: true
});

console.log(result); // {alpnProtocol: 'h2', socket: tls.TLSSocket}

// Remember to destroy the socket if you don't use it!
result.socket.destroy();

connect

Type: Function<TLSSocket> | AsyncFunction<TLSSocket>\ Default: tls.connect

Note: No matter which function is used (synchronous or asynchronous), it must accept a callback function as a second argument. The callback function gets executed when the socket has successfully connected.

License

MIT