@push.rocks/smartproxy 25.17.10 → 26.1.0

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.
Files changed (184) hide show
  1. package/changelog.md +15 -0
  2. package/dist_rust/rustproxy_linux_amd64 +0 -0
  3. package/dist_rust/rustproxy_linux_arm64 +0 -0
  4. package/dist_ts/00_commitinfo_data.js +2 -2
  5. package/dist_ts/core/index.d.ts +0 -1
  6. package/dist_ts/core/index.js +1 -2
  7. package/dist_ts/core/models/index.d.ts +0 -1
  8. package/dist_ts/core/models/index.js +1 -2
  9. package/dist_ts/core/utils/index.d.ts +0 -12
  10. package/dist_ts/core/utils/index.js +1 -13
  11. package/dist_ts/index.d.ts +0 -3
  12. package/dist_ts/index.js +2 -7
  13. package/dist_ts/protocols/http/index.d.ts +0 -1
  14. package/dist_ts/protocols/http/index.js +1 -2
  15. package/dist_ts/protocols/index.d.ts +0 -7
  16. package/dist_ts/protocols/index.js +1 -8
  17. package/dist_ts/proxies/smart-proxy/models/metrics-types.d.ts +20 -0
  18. package/dist_ts/proxies/smart-proxy/rust-metrics-adapter.d.ts +2 -1
  19. package/dist_ts/proxies/smart-proxy/rust-metrics-adapter.js +4 -1
  20. package/dist_ts/proxies/smart-proxy/socket-handler-server.js +6 -1
  21. package/dist_ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.d.ts +0 -7
  22. package/dist_ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.js +50 -51
  23. package/dist_ts/routing/index.d.ts +0 -1
  24. package/dist_ts/routing/index.js +1 -3
  25. package/package.json +1 -1
  26. package/ts/00_commitinfo_data.ts +1 -1
  27. package/ts/core/index.ts +0 -1
  28. package/ts/core/models/index.ts +0 -1
  29. package/ts/core/utils/index.ts +0 -12
  30. package/ts/index.ts +1 -7
  31. package/ts/protocols/http/index.ts +1 -2
  32. package/ts/protocols/index.ts +0 -7
  33. package/ts/proxies/smart-proxy/models/metrics-types.ts +21 -0
  34. package/ts/proxies/smart-proxy/rust-metrics-adapter.ts +4 -1
  35. package/ts/proxies/smart-proxy/socket-handler-server.ts +6 -0
  36. package/ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.ts +60 -59
  37. package/ts/routing/index.ts +0 -3
  38. package/dist_ts/core/events/index.d.ts +0 -4
  39. package/dist_ts/core/events/index.js +0 -5
  40. package/dist_ts/core/models/socket-augmentation.d.ts +0 -15
  41. package/dist_ts/core/models/socket-augmentation.js +0 -18
  42. package/dist_ts/core/utils/async-utils.d.ts +0 -81
  43. package/dist_ts/core/utils/async-utils.js +0 -216
  44. package/dist_ts/core/utils/binary-heap.d.ts +0 -73
  45. package/dist_ts/core/utils/binary-heap.js +0 -193
  46. package/dist_ts/core/utils/enhanced-connection-pool.d.ts +0 -110
  47. package/dist_ts/core/utils/enhanced-connection-pool.js +0 -325
  48. package/dist_ts/core/utils/fs-utils.d.ts +0 -144
  49. package/dist_ts/core/utils/fs-utils.js +0 -252
  50. package/dist_ts/core/utils/ip-utils.d.ts +0 -69
  51. package/dist_ts/core/utils/ip-utils.js +0 -270
  52. package/dist_ts/core/utils/lifecycle-component.d.ts +0 -59
  53. package/dist_ts/core/utils/lifecycle-component.js +0 -211
  54. package/dist_ts/core/utils/log-deduplicator.d.ts +0 -39
  55. package/dist_ts/core/utils/log-deduplicator.js +0 -305
  56. package/dist_ts/core/utils/security-utils.d.ts +0 -111
  57. package/dist_ts/core/utils/security-utils.js +0 -212
  58. package/dist_ts/core/utils/shared-security-manager.d.ts +0 -128
  59. package/dist_ts/core/utils/shared-security-manager.js +0 -362
  60. package/dist_ts/core/utils/socket-utils.d.ts +0 -63
  61. package/dist_ts/core/utils/socket-utils.js +0 -249
  62. package/dist_ts/core/utils/template-utils.d.ts +0 -37
  63. package/dist_ts/core/utils/template-utils.js +0 -104
  64. package/dist_ts/core/utils/validation-utils.d.ts +0 -61
  65. package/dist_ts/core/utils/validation-utils.js +0 -149
  66. package/dist_ts/core/utils/websocket-utils.d.ts +0 -22
  67. package/dist_ts/core/utils/websocket-utils.js +0 -30
  68. package/dist_ts/detection/detectors/http-detector.d.ts +0 -33
  69. package/dist_ts/detection/detectors/http-detector.js +0 -101
  70. package/dist_ts/detection/detectors/quick-detector.d.ts +0 -28
  71. package/dist_ts/detection/detectors/quick-detector.js +0 -131
  72. package/dist_ts/detection/detectors/routing-extractor.d.ts +0 -28
  73. package/dist_ts/detection/detectors/routing-extractor.js +0 -122
  74. package/dist_ts/detection/detectors/tls-detector.d.ts +0 -47
  75. package/dist_ts/detection/detectors/tls-detector.js +0 -183
  76. package/dist_ts/detection/index.d.ts +0 -17
  77. package/dist_ts/detection/index.js +0 -22
  78. package/dist_ts/detection/models/detection-types.d.ts +0 -87
  79. package/dist_ts/detection/models/detection-types.js +0 -5
  80. package/dist_ts/detection/models/interfaces.d.ts +0 -97
  81. package/dist_ts/detection/models/interfaces.js +0 -5
  82. package/dist_ts/detection/protocol-detector.d.ts +0 -79
  83. package/dist_ts/detection/protocol-detector.js +0 -253
  84. package/dist_ts/detection/utils/buffer-utils.d.ts +0 -61
  85. package/dist_ts/detection/utils/buffer-utils.js +0 -127
  86. package/dist_ts/detection/utils/fragment-manager.d.ts +0 -31
  87. package/dist_ts/detection/utils/fragment-manager.js +0 -53
  88. package/dist_ts/detection/utils/parser-utils.d.ts +0 -42
  89. package/dist_ts/detection/utils/parser-utils.js +0 -63
  90. package/dist_ts/protocols/common/fragment-handler.d.ts +0 -73
  91. package/dist_ts/protocols/common/fragment-handler.js +0 -121
  92. package/dist_ts/protocols/common/index.d.ts +0 -7
  93. package/dist_ts/protocols/common/index.js +0 -8
  94. package/dist_ts/protocols/common/types.d.ts +0 -68
  95. package/dist_ts/protocols/common/types.js +0 -7
  96. package/dist_ts/protocols/http/parser.d.ts +0 -58
  97. package/dist_ts/protocols/http/parser.js +0 -184
  98. package/dist_ts/protocols/proxy/index.d.ts +0 -5
  99. package/dist_ts/protocols/proxy/index.js +0 -6
  100. package/dist_ts/protocols/proxy/types.d.ts +0 -47
  101. package/dist_ts/protocols/proxy/types.js +0 -6
  102. package/dist_ts/protocols/tls/alerts/index.d.ts +0 -4
  103. package/dist_ts/protocols/tls/alerts/index.js +0 -5
  104. package/dist_ts/protocols/tls/alerts/tls-alert.d.ts +0 -150
  105. package/dist_ts/protocols/tls/alerts/tls-alert.js +0 -226
  106. package/dist_ts/protocols/tls/index.d.ts +0 -12
  107. package/dist_ts/protocols/tls/index.js +0 -27
  108. package/dist_ts/protocols/tls/sni/client-hello-parser.d.ts +0 -100
  109. package/dist_ts/protocols/tls/sni/client-hello-parser.js +0 -463
  110. package/dist_ts/protocols/tls/sni/index.d.ts +0 -5
  111. package/dist_ts/protocols/tls/sni/index.js +0 -6
  112. package/dist_ts/protocols/tls/sni/sni-extraction.d.ts +0 -58
  113. package/dist_ts/protocols/tls/sni/sni-extraction.js +0 -275
  114. package/dist_ts/protocols/tls/utils/index.d.ts +0 -4
  115. package/dist_ts/protocols/tls/utils/index.js +0 -5
  116. package/dist_ts/protocols/tls/utils/tls-utils.d.ts +0 -158
  117. package/dist_ts/protocols/tls/utils/tls-utils.js +0 -187
  118. package/dist_ts/protocols/websocket/constants.d.ts +0 -55
  119. package/dist_ts/protocols/websocket/constants.js +0 -58
  120. package/dist_ts/protocols/websocket/index.d.ts +0 -7
  121. package/dist_ts/protocols/websocket/index.js +0 -8
  122. package/dist_ts/protocols/websocket/types.d.ts +0 -47
  123. package/dist_ts/protocols/websocket/types.js +0 -5
  124. package/dist_ts/protocols/websocket/utils.d.ts +0 -25
  125. package/dist_ts/protocols/websocket/utils.js +0 -103
  126. package/dist_ts/routing/router/http-router.d.ts +0 -89
  127. package/dist_ts/routing/router/http-router.js +0 -205
  128. package/dist_ts/routing/router/index.d.ts +0 -5
  129. package/dist_ts/routing/router/index.js +0 -6
  130. package/dist_ts/tls/index.d.ts +0 -16
  131. package/dist_ts/tls/index.js +0 -24
  132. package/dist_ts/tls/sni/index.d.ts +0 -4
  133. package/dist_ts/tls/sni/index.js +0 -5
  134. package/dist_ts/tls/sni/sni-handler.d.ts +0 -154
  135. package/dist_ts/tls/sni/sni-handler.js +0 -191
  136. package/ts/core/events/index.ts +0 -3
  137. package/ts/core/models/socket-augmentation.ts +0 -38
  138. package/ts/core/utils/async-utils.ts +0 -275
  139. package/ts/core/utils/binary-heap.ts +0 -225
  140. package/ts/core/utils/enhanced-connection-pool.ts +0 -425
  141. package/ts/core/utils/fs-utils.ts +0 -270
  142. package/ts/core/utils/ip-utils.ts +0 -303
  143. package/ts/core/utils/lifecycle-component.ts +0 -251
  144. package/ts/core/utils/log-deduplicator.ts +0 -370
  145. package/ts/core/utils/security-utils.ts +0 -305
  146. package/ts/core/utils/shared-security-manager.ts +0 -470
  147. package/ts/core/utils/socket-utils.ts +0 -322
  148. package/ts/core/utils/template-utils.ts +0 -124
  149. package/ts/core/utils/validation-utils.ts +0 -177
  150. package/ts/core/utils/websocket-utils.ts +0 -33
  151. package/ts/detection/detectors/http-detector.ts +0 -127
  152. package/ts/detection/detectors/quick-detector.ts +0 -148
  153. package/ts/detection/detectors/routing-extractor.ts +0 -147
  154. package/ts/detection/detectors/tls-detector.ts +0 -223
  155. package/ts/detection/index.ts +0 -25
  156. package/ts/detection/models/detection-types.ts +0 -102
  157. package/ts/detection/models/interfaces.ts +0 -115
  158. package/ts/detection/protocol-detector.ts +0 -319
  159. package/ts/detection/utils/buffer-utils.ts +0 -141
  160. package/ts/detection/utils/fragment-manager.ts +0 -64
  161. package/ts/detection/utils/parser-utils.ts +0 -77
  162. package/ts/protocols/common/fragment-handler.ts +0 -167
  163. package/ts/protocols/common/index.ts +0 -8
  164. package/ts/protocols/common/types.ts +0 -76
  165. package/ts/protocols/http/parser.ts +0 -219
  166. package/ts/protocols/proxy/index.ts +0 -6
  167. package/ts/protocols/proxy/types.ts +0 -53
  168. package/ts/protocols/tls/alerts/index.ts +0 -3
  169. package/ts/protocols/tls/alerts/tls-alert.ts +0 -259
  170. package/ts/protocols/tls/index.ts +0 -37
  171. package/ts/protocols/tls/sni/client-hello-parser.ts +0 -629
  172. package/ts/protocols/tls/sni/index.ts +0 -6
  173. package/ts/protocols/tls/sni/sni-extraction.ts +0 -353
  174. package/ts/protocols/tls/utils/index.ts +0 -3
  175. package/ts/protocols/tls/utils/tls-utils.ts +0 -201
  176. package/ts/protocols/websocket/constants.ts +0 -60
  177. package/ts/protocols/websocket/index.ts +0 -8
  178. package/ts/protocols/websocket/types.ts +0 -53
  179. package/ts/protocols/websocket/utils.ts +0 -98
  180. package/ts/routing/router/http-router.ts +0 -266
  181. package/ts/routing/router/index.ts +0 -7
  182. package/ts/tls/index.ts +0 -29
  183. package/ts/tls/sni/index.ts +0 -3
  184. package/ts/tls/sni/sni-handler.ts +0 -264
@@ -1,259 +0,0 @@
1
- import * as plugins from '../../../plugins.js';
2
- import { TlsAlertLevel, TlsAlertDescription, TlsVersion } from '../utils/tls-utils.js';
3
-
4
- /**
5
- * TlsAlert class for creating and sending TLS alert messages
6
- */
7
- export class TlsAlert {
8
- // Use enum values from TlsAlertLevel
9
- static readonly LEVEL_WARNING = TlsAlertLevel.WARNING;
10
- static readonly LEVEL_FATAL = TlsAlertLevel.FATAL;
11
-
12
- // Use enum values from TlsAlertDescription
13
- static readonly CLOSE_NOTIFY = TlsAlertDescription.CLOSE_NOTIFY;
14
- static readonly UNEXPECTED_MESSAGE = TlsAlertDescription.UNEXPECTED_MESSAGE;
15
- static readonly BAD_RECORD_MAC = TlsAlertDescription.BAD_RECORD_MAC;
16
- static readonly DECRYPTION_FAILED = TlsAlertDescription.DECRYPTION_FAILED;
17
- static readonly RECORD_OVERFLOW = TlsAlertDescription.RECORD_OVERFLOW;
18
- static readonly DECOMPRESSION_FAILURE = TlsAlertDescription.DECOMPRESSION_FAILURE;
19
- static readonly HANDSHAKE_FAILURE = TlsAlertDescription.HANDSHAKE_FAILURE;
20
- static readonly NO_CERTIFICATE = TlsAlertDescription.NO_CERTIFICATE;
21
- static readonly BAD_CERTIFICATE = TlsAlertDescription.BAD_CERTIFICATE;
22
- static readonly UNSUPPORTED_CERTIFICATE = TlsAlertDescription.UNSUPPORTED_CERTIFICATE;
23
- static readonly CERTIFICATE_REVOKED = TlsAlertDescription.CERTIFICATE_REVOKED;
24
- static readonly CERTIFICATE_EXPIRED = TlsAlertDescription.CERTIFICATE_EXPIRED;
25
- static readonly CERTIFICATE_UNKNOWN = TlsAlertDescription.CERTIFICATE_UNKNOWN;
26
- static readonly ILLEGAL_PARAMETER = TlsAlertDescription.ILLEGAL_PARAMETER;
27
- static readonly UNKNOWN_CA = TlsAlertDescription.UNKNOWN_CA;
28
- static readonly ACCESS_DENIED = TlsAlertDescription.ACCESS_DENIED;
29
- static readonly DECODE_ERROR = TlsAlertDescription.DECODE_ERROR;
30
- static readonly DECRYPT_ERROR = TlsAlertDescription.DECRYPT_ERROR;
31
- static readonly EXPORT_RESTRICTION = TlsAlertDescription.EXPORT_RESTRICTION;
32
- static readonly PROTOCOL_VERSION = TlsAlertDescription.PROTOCOL_VERSION;
33
- static readonly INSUFFICIENT_SECURITY = TlsAlertDescription.INSUFFICIENT_SECURITY;
34
- static readonly INTERNAL_ERROR = TlsAlertDescription.INTERNAL_ERROR;
35
- static readonly INAPPROPRIATE_FALLBACK = TlsAlertDescription.INAPPROPRIATE_FALLBACK;
36
- static readonly USER_CANCELED = TlsAlertDescription.USER_CANCELED;
37
- static readonly NO_RENEGOTIATION = TlsAlertDescription.NO_RENEGOTIATION;
38
- static readonly MISSING_EXTENSION = TlsAlertDescription.MISSING_EXTENSION;
39
- static readonly UNSUPPORTED_EXTENSION = TlsAlertDescription.UNSUPPORTED_EXTENSION;
40
- static readonly CERTIFICATE_REQUIRED = TlsAlertDescription.CERTIFICATE_REQUIRED;
41
- static readonly UNRECOGNIZED_NAME = TlsAlertDescription.UNRECOGNIZED_NAME;
42
- static readonly BAD_CERTIFICATE_STATUS_RESPONSE = TlsAlertDescription.BAD_CERTIFICATE_STATUS_RESPONSE;
43
- static readonly BAD_CERTIFICATE_HASH_VALUE = TlsAlertDescription.BAD_CERTIFICATE_HASH_VALUE;
44
- static readonly UNKNOWN_PSK_IDENTITY = TlsAlertDescription.UNKNOWN_PSK_IDENTITY;
45
- static readonly CERTIFICATE_REQUIRED_1_3 = TlsAlertDescription.CERTIFICATE_REQUIRED_1_3;
46
- static readonly NO_APPLICATION_PROTOCOL = TlsAlertDescription.NO_APPLICATION_PROTOCOL;
47
-
48
- /**
49
- * Create a TLS alert buffer with the specified level and description code
50
- *
51
- * @param level Alert level (warning or fatal)
52
- * @param description Alert description code
53
- * @param tlsVersion TLS version bytes (default is TLS 1.2: 0x0303)
54
- * @returns Buffer containing the TLS alert message
55
- */
56
- static create(
57
- level: number,
58
- description: number,
59
- tlsVersion: [number, number] = [TlsVersion.TLS1_2[0], TlsVersion.TLS1_2[1]]
60
- ): Buffer {
61
- return Buffer.from([
62
- 0x15, // Alert record type
63
- tlsVersion[0],
64
- tlsVersion[1], // TLS version (default to TLS 1.2: 0x0303)
65
- 0x00,
66
- 0x02, // Length
67
- level, // Alert level
68
- description, // Alert description
69
- ]);
70
- }
71
-
72
- /**
73
- * Create a warning-level TLS alert
74
- *
75
- * @param description Alert description code
76
- * @returns Buffer containing the warning-level TLS alert message
77
- */
78
- static createWarning(description: number): Buffer {
79
- return this.create(this.LEVEL_WARNING, description);
80
- }
81
-
82
- /**
83
- * Create a fatal-level TLS alert
84
- *
85
- * @param description Alert description code
86
- * @returns Buffer containing the fatal-level TLS alert message
87
- */
88
- static createFatal(description: number): Buffer {
89
- return this.create(this.LEVEL_FATAL, description);
90
- }
91
-
92
- /**
93
- * Send a TLS alert to a socket and optionally close the connection
94
- *
95
- * @param socket The socket to send the alert to
96
- * @param level Alert level (warning or fatal)
97
- * @param description Alert description code
98
- * @param closeAfterSend Whether to close the connection after sending the alert
99
- * @param closeDelay Milliseconds to wait before closing the connection (default: 200ms)
100
- * @returns Promise that resolves when the alert has been sent
101
- */
102
- static async send(
103
- socket: plugins.net.Socket,
104
- level: number,
105
- description: number,
106
- closeAfterSend: boolean = false,
107
- closeDelay: number = 200
108
- ): Promise<void> {
109
- const alert = this.create(level, description);
110
-
111
- return new Promise<void>((resolve, reject) => {
112
- try {
113
- // Ensure the alert is written as a single packet
114
- socket.cork();
115
- const writeSuccessful = socket.write(alert, (err) => {
116
- if (err) {
117
- reject(err);
118
- return;
119
- }
120
-
121
- if (closeAfterSend) {
122
- setTimeout(() => {
123
- socket.end();
124
- resolve();
125
- }, closeDelay);
126
- } else {
127
- resolve();
128
- }
129
- });
130
- socket.uncork();
131
-
132
- // If write wasn't successful immediately, wait for drain
133
- if (!writeSuccessful && !closeAfterSend) {
134
- socket.once('drain', () => {
135
- resolve();
136
- });
137
- }
138
- } catch (err) {
139
- reject(err);
140
- }
141
- });
142
- }
143
-
144
- /**
145
- * Pre-defined TLS alert messages
146
- */
147
- static readonly alerts = {
148
- // Warning level alerts
149
- closeNotify: TlsAlert.createWarning(TlsAlert.CLOSE_NOTIFY),
150
- unsupportedExtension: TlsAlert.createWarning(TlsAlert.UNSUPPORTED_EXTENSION),
151
- certificateRequired: TlsAlert.createWarning(TlsAlert.CERTIFICATE_REQUIRED),
152
- unrecognizedName: TlsAlert.createWarning(TlsAlert.UNRECOGNIZED_NAME),
153
- noRenegotiation: TlsAlert.createWarning(TlsAlert.NO_RENEGOTIATION),
154
- userCanceled: TlsAlert.createWarning(TlsAlert.USER_CANCELED),
155
-
156
- // Warning level alerts for session resumption
157
- certificateExpiredWarning: TlsAlert.createWarning(TlsAlert.CERTIFICATE_EXPIRED),
158
- handshakeFailureWarning: TlsAlert.createWarning(TlsAlert.HANDSHAKE_FAILURE),
159
- insufficientSecurityWarning: TlsAlert.createWarning(TlsAlert.INSUFFICIENT_SECURITY),
160
-
161
- // Fatal level alerts
162
- unexpectedMessage: TlsAlert.createFatal(TlsAlert.UNEXPECTED_MESSAGE),
163
- badRecordMac: TlsAlert.createFatal(TlsAlert.BAD_RECORD_MAC),
164
- recordOverflow: TlsAlert.createFatal(TlsAlert.RECORD_OVERFLOW),
165
- handshakeFailure: TlsAlert.createFatal(TlsAlert.HANDSHAKE_FAILURE),
166
- badCertificate: TlsAlert.createFatal(TlsAlert.BAD_CERTIFICATE),
167
- certificateExpired: TlsAlert.createFatal(TlsAlert.CERTIFICATE_EXPIRED),
168
- certificateUnknown: TlsAlert.createFatal(TlsAlert.CERTIFICATE_UNKNOWN),
169
- illegalParameter: TlsAlert.createFatal(TlsAlert.ILLEGAL_PARAMETER),
170
- unknownCA: TlsAlert.createFatal(TlsAlert.UNKNOWN_CA),
171
- accessDenied: TlsAlert.createFatal(TlsAlert.ACCESS_DENIED),
172
- decodeError: TlsAlert.createFatal(TlsAlert.DECODE_ERROR),
173
- decryptError: TlsAlert.createFatal(TlsAlert.DECRYPT_ERROR),
174
- protocolVersion: TlsAlert.createFatal(TlsAlert.PROTOCOL_VERSION),
175
- insufficientSecurity: TlsAlert.createFatal(TlsAlert.INSUFFICIENT_SECURITY),
176
- internalError: TlsAlert.createFatal(TlsAlert.INTERNAL_ERROR),
177
- unrecognizedNameFatal: TlsAlert.createFatal(TlsAlert.UNRECOGNIZED_NAME),
178
- };
179
-
180
- /**
181
- * Utility method to send a warning-level unrecognized_name alert
182
- * Specifically designed for SNI issues to encourage the client to retry with SNI
183
- *
184
- * @param socket The socket to send the alert to
185
- * @returns Promise that resolves when the alert has been sent
186
- */
187
- static async sendSniRequired(socket: plugins.net.Socket): Promise<void> {
188
- return this.send(socket, this.LEVEL_WARNING, this.UNRECOGNIZED_NAME);
189
- }
190
-
191
- /**
192
- * Utility method to send a close_notify alert and close the connection
193
- *
194
- * @param socket The socket to send the alert to
195
- * @param closeDelay Milliseconds to wait before closing the connection (default: 200ms)
196
- * @returns Promise that resolves when the alert has been sent and the connection closed
197
- */
198
- static async sendCloseNotify(socket: plugins.net.Socket, closeDelay: number = 200): Promise<void> {
199
- return this.send(socket, this.LEVEL_WARNING, this.CLOSE_NOTIFY, true, closeDelay);
200
- }
201
-
202
- /**
203
- * Utility method to send a certificate_expired alert to force new TLS session
204
- *
205
- * @param socket The socket to send the alert to
206
- * @param fatal Whether to send as a fatal alert (default: false)
207
- * @param closeAfterSend Whether to close the connection after sending the alert (default: true)
208
- * @param closeDelay Milliseconds to wait before closing the connection (default: 200ms)
209
- * @returns Promise that resolves when the alert has been sent
210
- */
211
- static async sendCertificateExpired(
212
- socket: plugins.net.Socket,
213
- fatal: boolean = false,
214
- closeAfterSend: boolean = true,
215
- closeDelay: number = 200
216
- ): Promise<void> {
217
- const level = fatal ? this.LEVEL_FATAL : this.LEVEL_WARNING;
218
- return this.send(socket, level, this.CERTIFICATE_EXPIRED, closeAfterSend, closeDelay);
219
- }
220
-
221
- /**
222
- * Send a sequence of alerts to force SNI from clients
223
- * This combines multiple alerts to ensure maximum browser compatibility
224
- *
225
- * @param socket The socket to send the alerts to
226
- * @returns Promise that resolves when all alerts have been sent
227
- */
228
- static async sendForceSniSequence(socket: plugins.net.Socket): Promise<void> {
229
- try {
230
- // Send unrecognized_name (warning)
231
- socket.cork();
232
- socket.write(this.alerts.unrecognizedName);
233
- socket.uncork();
234
-
235
- // Give the socket time to send the alert
236
- return new Promise((resolve) => {
237
- setTimeout(resolve, 50);
238
- });
239
- } catch (err) {
240
- return Promise.reject(err);
241
- }
242
- }
243
-
244
- /**
245
- * Send a fatal level alert that immediately terminates the connection
246
- *
247
- * @param socket The socket to send the alert to
248
- * @param description Alert description code
249
- * @param closeDelay Milliseconds to wait before closing the connection (default: 100ms)
250
- * @returns Promise that resolves when the alert has been sent and the connection closed
251
- */
252
- static async sendFatalAndClose(
253
- socket: plugins.net.Socket,
254
- description: number,
255
- closeDelay: number = 100
256
- ): Promise<void> {
257
- return this.send(socket, this.LEVEL_FATAL, description, true, closeDelay);
258
- }
259
- }
@@ -1,37 +0,0 @@
1
- /**
2
- * TLS Protocol Module
3
- * Contains generic TLS protocol knowledge including parsers, constants, and utilities
4
- */
5
-
6
- // Export all sub-modules
7
- export * from './alerts/index.js';
8
- export * from './sni/index.js';
9
- export * from './utils/index.js';
10
-
11
- // Re-export main utilities and types for convenience
12
- export {
13
- TlsUtils,
14
- TlsRecordType,
15
- TlsHandshakeType,
16
- TlsExtensionType,
17
- TlsAlertLevel,
18
- TlsAlertDescription,
19
- TlsVersion
20
- } from './utils/tls-utils.js';
21
- export { TlsAlert } from './alerts/tls-alert.js';
22
- export { ClientHelloParser } from './sni/client-hello-parser.js';
23
- export { SniExtraction } from './sni/sni-extraction.js';
24
-
25
- // Export tlsVersionToString helper
26
- export function tlsVersionToString(major: number, minor: number): string | null {
27
- if (major === 0x03) {
28
- switch (minor) {
29
- case 0x00: return 'SSLv3';
30
- case 0x01: return 'TLSv1.0';
31
- case 0x02: return 'TLSv1.1';
32
- case 0x03: return 'TLSv1.2';
33
- case 0x04: return 'TLSv1.3';
34
- }
35
- }
36
- return null;
37
- }