topbit 3.2.1 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.cn.md CHANGED
@@ -1933,16 +1933,6 @@ app.run(1234)
1933
1933
 
1934
1934
  ### 7. SNI (HTTPS 多域名支持)
1935
1935
 
1936
- **描述**:用于在同一 IP 地址和端口上支持多个 HTTPS 域名证书的中间件。
1937
-
1938
- 感谢提供源代码。根据代码逻辑,`SNI` 扩展通过 `init` 方法将 `SNICallback` 注入到应用的 `config.server` 配置中,从而利用 Node.js 原生 TLS 的能力实现多域名证书支持。
1939
-
1940
- 以下是补全后的 **SNI** 文档部分:
1941
-
1942
- ---
1943
-
1944
- ### 7. SNI (HTTPS 多域名支持)
1945
-
1946
1936
  **描述**:用于在同一 IP 地址和端口上支持多个 HTTPS 域名证书的中间件。它利用 TLS 协议的 Server Name Indication 特性,根据客户端请求的域名动态加载对应的 SSL 证书。
1947
1937
 
1948
1938
  **注意**:初始化时会同步读取证书文件,请确保路径正确。如果某个域名的证书读取失败,会在控制台输出错误信息,但不会阻塞其他域名的加载。
package/demo/http2.js CHANGED
@@ -19,7 +19,15 @@ let app = new Topbit({
19
19
  loadInfoFile: '--mem',
20
20
  cert: './cert/localhost-cert.pem',
21
21
  key: './cert/localhost-privkey.pem',
22
- http2: true
22
+ http2: true,
23
+ server: {
24
+ peerMaxConcurrentStreams: 200,
25
+ settings: {
26
+ maxConcurrentStreams: 201,
27
+ maxHeaderListSize: 16384,
28
+ maxHeaderSize: 16384
29
+ }
30
+ }
23
31
  })
24
32
 
25
33
  if (app.isWorker) {
@@ -42,8 +50,32 @@ if (app.isWorker) {
42
50
  })
43
51
  }
44
52
 
53
+ app.on('connection', sock => {
54
+ console.log(sock)
55
+ })
45
56
 
46
57
  app.sched('none')
47
58
  .autoWorker(3)
48
59
  .printServInfo()
49
60
  .daemon(1234, 2)
61
+
62
+ let settings = {
63
+ maxConcurrentStreams: 200,
64
+ maxHeaderListSize: 16384
65
+ }
66
+
67
+ app.on('session', sess => {
68
+ console.log(sess.localSettings, sess.remoteSettings)
69
+
70
+ sess.on('localSettings', s => {
71
+ console.log('local', s)
72
+ })
73
+
74
+ sess.on('remoteSettings', s => {
75
+ console.log('remote', s)
76
+ })
77
+ /* sess.settings(settings, (err, setting, dura) => {
78
+ console.log(setting, dura)
79
+ }) */
80
+
81
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "topbit",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "A Server-side web framework support http/1.1 and http/2",
5
5
  "main": "src/topbit.js",
6
6
  "directories": {
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  *
5
- * 基于IP的限制,titbit已经能够处理。
5
+ * 基于IP的限制,topbit已经能够处理。
6
6
  *
7
7
  * 此限流针对的是因为http/2协议设计上特点导致单个连接请求密集。
8
8
  *
package/src/topbit.js CHANGED
@@ -780,14 +780,20 @@ class Topbit {
780
780
  if (typeof callback === 'function') {
781
781
  this.httpServ.requestError = callback;
782
782
  }
783
- return;
783
+ return this;
784
784
  }
785
-
785
+
786
+ if (this.server && this.server.on) {
787
+ this.server.on(evt, callback);
788
+ return this;
789
+ }
790
+
786
791
  if (!this.eventTable[evt]) {
787
792
  this.eventTable[evt] = [ callback ];
788
793
  } else {
789
794
  this.eventTable[evt].push(callback);
790
795
  }
796
+ return this;
791
797
  }
792
798
 
793
799
  /**