summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannis R <mail@jannisr.de>2020-08-05 14:08:40 +0200
committerJannis R <mail@jannisr.de>2020-08-05 14:08:40 +0200
commit852d9a28ef7a4a1bc722e1b60584fa265d2f1a94 (patch)
treed8ef7b532605bb776820b56767eeb2ff6d3d6283
parent99fe5cdecb18c2dfe63a3ee4950f9503f11db1ab (diff)
add verifyAlpnId() hook
-rw-r--r--client.js9
-rw-r--r--server.js4
2 files changed, 11 insertions, 2 deletions
diff --git a/client.js b/client.js
index ebb2b66..e4a3427 100644
--- a/client.js
+++ b/client.js
@@ -16,10 +16,17 @@ const HOUR = 60 * 60 * 1000
const _request = (pathOrUrl, opt, cb) => {
debug('_request', pathOrUrl, opt)
+ const {
+ verifyAlpnId,
+ } = {
+ verifyAlpnId: alpnId => alpnId === ALPN_ID,
+ ...opt,
+ }
+
connect(opt, (err, socket) => {
if (err) return cb(err)
- if (socket.alpnProtocol !== ALPN_ID) {
+ if (verifyAlpnId(socket.alpnProtocol) !== true) {
socket.destroy()
return cb(new Error('invalid or missing ALPN protocol'))
}
diff --git a/server.js b/server.js
index aa7afb7..88d3a2d 100644
--- a/server.js
+++ b/server.js
@@ -17,15 +17,17 @@ const createGeminiServer = (opt = {}, onRequest) => {
const {
cert, key, passphrase,
tlsOpt,
+ verifyAlpnId,
} = {
cert: null, key: null, passphrase: null,
tlsOpt: {},
+ verifyAlpnId: alpnId => alpnId === ALPN_ID,
...opt,
}
const onConnection = (socket) => {
// todo: clarify if this is desired behavior
- if (socket.alpnProtocol !== ALPN_ID) {
+ if (verifyAlpnId(socket.alpnProtocol) !== true) {
socket.destroy()
return;
}