Ver código fonte

Merge pull request #225 from brunobg/patch-2

Allows SNICallback instead of hardcoded key/cert
Alex Sosnovskiy 4 anos atrás
pai
commit
86ba5ba1ed
2 arquivos alterados com 18 adições e 2 exclusões
  1. 17 0
      README.md
  2. 1 2
      src/index.ts

+ 17 - 0
README.md

@@ -109,6 +109,23 @@ const peerServer = PeerServer({
 });
 ```
 
+You can also pass any other [SSL options accepted by https.createServer](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistenerfrom), such as `SNICallback:
+
+```javascript
+const fs = require('fs');
+const { PeerServer } = require('peer');
+
+const peerServer = PeerServer({
+  port: 9000,
+  ssl: {
+    SNICallback: (servername, cb) => {
+        // your code here ....
+    }
+  }
+});
+```
+
+
 ## Running PeerServer behind a reverse proxy
 
 Make sure to set the `proxied` option, otherwise IP based limiting will fail.

+ 1 - 2
src/index.ts

@@ -48,8 +48,7 @@ function PeerServer(options: Optional<IConfig> = {}, callback?: (server: Server)
   let server: Server;
 
   const { ssl, ...restOptions } = newOptions;
-
-  if (ssl && ssl.key && ssl.cert) {
+  if (ssl && Object.keys(ssl).length) {
     server = https.createServer(ssl, app);
 
     newOptions = restOptions;