@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.
- package/changelog.md +15 -0
- package/dist_rust/rustproxy_linux_amd64 +0 -0
- package/dist_rust/rustproxy_linux_arm64 +0 -0
- package/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/core/index.d.ts +0 -1
- package/dist_ts/core/index.js +1 -2
- package/dist_ts/core/models/index.d.ts +0 -1
- package/dist_ts/core/models/index.js +1 -2
- package/dist_ts/core/utils/index.d.ts +0 -12
- package/dist_ts/core/utils/index.js +1 -13
- package/dist_ts/index.d.ts +0 -3
- package/dist_ts/index.js +2 -7
- package/dist_ts/protocols/http/index.d.ts +0 -1
- package/dist_ts/protocols/http/index.js +1 -2
- package/dist_ts/protocols/index.d.ts +0 -7
- package/dist_ts/protocols/index.js +1 -8
- package/dist_ts/proxies/smart-proxy/models/metrics-types.d.ts +20 -0
- package/dist_ts/proxies/smart-proxy/rust-metrics-adapter.d.ts +2 -1
- package/dist_ts/proxies/smart-proxy/rust-metrics-adapter.js +4 -1
- package/dist_ts/proxies/smart-proxy/socket-handler-server.js +6 -1
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.d.ts +0 -7
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.js +50 -51
- package/dist_ts/routing/index.d.ts +0 -1
- package/dist_ts/routing/index.js +1 -3
- package/package.json +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/core/index.ts +0 -1
- package/ts/core/models/index.ts +0 -1
- package/ts/core/utils/index.ts +0 -12
- package/ts/index.ts +1 -7
- package/ts/protocols/http/index.ts +1 -2
- package/ts/protocols/index.ts +0 -7
- package/ts/proxies/smart-proxy/models/metrics-types.ts +21 -0
- package/ts/proxies/smart-proxy/rust-metrics-adapter.ts +4 -1
- package/ts/proxies/smart-proxy/socket-handler-server.ts +6 -0
- package/ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.ts +60 -59
- package/ts/routing/index.ts +0 -3
- package/dist_ts/core/events/index.d.ts +0 -4
- package/dist_ts/core/events/index.js +0 -5
- package/dist_ts/core/models/socket-augmentation.d.ts +0 -15
- package/dist_ts/core/models/socket-augmentation.js +0 -18
- package/dist_ts/core/utils/async-utils.d.ts +0 -81
- package/dist_ts/core/utils/async-utils.js +0 -216
- package/dist_ts/core/utils/binary-heap.d.ts +0 -73
- package/dist_ts/core/utils/binary-heap.js +0 -193
- package/dist_ts/core/utils/enhanced-connection-pool.d.ts +0 -110
- package/dist_ts/core/utils/enhanced-connection-pool.js +0 -325
- package/dist_ts/core/utils/fs-utils.d.ts +0 -144
- package/dist_ts/core/utils/fs-utils.js +0 -252
- package/dist_ts/core/utils/ip-utils.d.ts +0 -69
- package/dist_ts/core/utils/ip-utils.js +0 -270
- package/dist_ts/core/utils/lifecycle-component.d.ts +0 -59
- package/dist_ts/core/utils/lifecycle-component.js +0 -211
- package/dist_ts/core/utils/log-deduplicator.d.ts +0 -39
- package/dist_ts/core/utils/log-deduplicator.js +0 -305
- package/dist_ts/core/utils/security-utils.d.ts +0 -111
- package/dist_ts/core/utils/security-utils.js +0 -212
- package/dist_ts/core/utils/shared-security-manager.d.ts +0 -128
- package/dist_ts/core/utils/shared-security-manager.js +0 -362
- package/dist_ts/core/utils/socket-utils.d.ts +0 -63
- package/dist_ts/core/utils/socket-utils.js +0 -249
- package/dist_ts/core/utils/template-utils.d.ts +0 -37
- package/dist_ts/core/utils/template-utils.js +0 -104
- package/dist_ts/core/utils/validation-utils.d.ts +0 -61
- package/dist_ts/core/utils/validation-utils.js +0 -149
- package/dist_ts/core/utils/websocket-utils.d.ts +0 -22
- package/dist_ts/core/utils/websocket-utils.js +0 -30
- package/dist_ts/detection/detectors/http-detector.d.ts +0 -33
- package/dist_ts/detection/detectors/http-detector.js +0 -101
- package/dist_ts/detection/detectors/quick-detector.d.ts +0 -28
- package/dist_ts/detection/detectors/quick-detector.js +0 -131
- package/dist_ts/detection/detectors/routing-extractor.d.ts +0 -28
- package/dist_ts/detection/detectors/routing-extractor.js +0 -122
- package/dist_ts/detection/detectors/tls-detector.d.ts +0 -47
- package/dist_ts/detection/detectors/tls-detector.js +0 -183
- package/dist_ts/detection/index.d.ts +0 -17
- package/dist_ts/detection/index.js +0 -22
- package/dist_ts/detection/models/detection-types.d.ts +0 -87
- package/dist_ts/detection/models/detection-types.js +0 -5
- package/dist_ts/detection/models/interfaces.d.ts +0 -97
- package/dist_ts/detection/models/interfaces.js +0 -5
- package/dist_ts/detection/protocol-detector.d.ts +0 -79
- package/dist_ts/detection/protocol-detector.js +0 -253
- package/dist_ts/detection/utils/buffer-utils.d.ts +0 -61
- package/dist_ts/detection/utils/buffer-utils.js +0 -127
- package/dist_ts/detection/utils/fragment-manager.d.ts +0 -31
- package/dist_ts/detection/utils/fragment-manager.js +0 -53
- package/dist_ts/detection/utils/parser-utils.d.ts +0 -42
- package/dist_ts/detection/utils/parser-utils.js +0 -63
- package/dist_ts/protocols/common/fragment-handler.d.ts +0 -73
- package/dist_ts/protocols/common/fragment-handler.js +0 -121
- package/dist_ts/protocols/common/index.d.ts +0 -7
- package/dist_ts/protocols/common/index.js +0 -8
- package/dist_ts/protocols/common/types.d.ts +0 -68
- package/dist_ts/protocols/common/types.js +0 -7
- package/dist_ts/protocols/http/parser.d.ts +0 -58
- package/dist_ts/protocols/http/parser.js +0 -184
- package/dist_ts/protocols/proxy/index.d.ts +0 -5
- package/dist_ts/protocols/proxy/index.js +0 -6
- package/dist_ts/protocols/proxy/types.d.ts +0 -47
- package/dist_ts/protocols/proxy/types.js +0 -6
- package/dist_ts/protocols/tls/alerts/index.d.ts +0 -4
- package/dist_ts/protocols/tls/alerts/index.js +0 -5
- package/dist_ts/protocols/tls/alerts/tls-alert.d.ts +0 -150
- package/dist_ts/protocols/tls/alerts/tls-alert.js +0 -226
- package/dist_ts/protocols/tls/index.d.ts +0 -12
- package/dist_ts/protocols/tls/index.js +0 -27
- package/dist_ts/protocols/tls/sni/client-hello-parser.d.ts +0 -100
- package/dist_ts/protocols/tls/sni/client-hello-parser.js +0 -463
- package/dist_ts/protocols/tls/sni/index.d.ts +0 -5
- package/dist_ts/protocols/tls/sni/index.js +0 -6
- package/dist_ts/protocols/tls/sni/sni-extraction.d.ts +0 -58
- package/dist_ts/protocols/tls/sni/sni-extraction.js +0 -275
- package/dist_ts/protocols/tls/utils/index.d.ts +0 -4
- package/dist_ts/protocols/tls/utils/index.js +0 -5
- package/dist_ts/protocols/tls/utils/tls-utils.d.ts +0 -158
- package/dist_ts/protocols/tls/utils/tls-utils.js +0 -187
- package/dist_ts/protocols/websocket/constants.d.ts +0 -55
- package/dist_ts/protocols/websocket/constants.js +0 -58
- package/dist_ts/protocols/websocket/index.d.ts +0 -7
- package/dist_ts/protocols/websocket/index.js +0 -8
- package/dist_ts/protocols/websocket/types.d.ts +0 -47
- package/dist_ts/protocols/websocket/types.js +0 -5
- package/dist_ts/protocols/websocket/utils.d.ts +0 -25
- package/dist_ts/protocols/websocket/utils.js +0 -103
- package/dist_ts/routing/router/http-router.d.ts +0 -89
- package/dist_ts/routing/router/http-router.js +0 -205
- package/dist_ts/routing/router/index.d.ts +0 -5
- package/dist_ts/routing/router/index.js +0 -6
- package/dist_ts/tls/index.d.ts +0 -16
- package/dist_ts/tls/index.js +0 -24
- package/dist_ts/tls/sni/index.d.ts +0 -4
- package/dist_ts/tls/sni/index.js +0 -5
- package/dist_ts/tls/sni/sni-handler.d.ts +0 -154
- package/dist_ts/tls/sni/sni-handler.js +0 -191
- package/ts/core/events/index.ts +0 -3
- package/ts/core/models/socket-augmentation.ts +0 -38
- package/ts/core/utils/async-utils.ts +0 -275
- package/ts/core/utils/binary-heap.ts +0 -225
- package/ts/core/utils/enhanced-connection-pool.ts +0 -425
- package/ts/core/utils/fs-utils.ts +0 -270
- package/ts/core/utils/ip-utils.ts +0 -303
- package/ts/core/utils/lifecycle-component.ts +0 -251
- package/ts/core/utils/log-deduplicator.ts +0 -370
- package/ts/core/utils/security-utils.ts +0 -305
- package/ts/core/utils/shared-security-manager.ts +0 -470
- package/ts/core/utils/socket-utils.ts +0 -322
- package/ts/core/utils/template-utils.ts +0 -124
- package/ts/core/utils/validation-utils.ts +0 -177
- package/ts/core/utils/websocket-utils.ts +0 -33
- package/ts/detection/detectors/http-detector.ts +0 -127
- package/ts/detection/detectors/quick-detector.ts +0 -148
- package/ts/detection/detectors/routing-extractor.ts +0 -147
- package/ts/detection/detectors/tls-detector.ts +0 -223
- package/ts/detection/index.ts +0 -25
- package/ts/detection/models/detection-types.ts +0 -102
- package/ts/detection/models/interfaces.ts +0 -115
- package/ts/detection/protocol-detector.ts +0 -319
- package/ts/detection/utils/buffer-utils.ts +0 -141
- package/ts/detection/utils/fragment-manager.ts +0 -64
- package/ts/detection/utils/parser-utils.ts +0 -77
- package/ts/protocols/common/fragment-handler.ts +0 -167
- package/ts/protocols/common/index.ts +0 -8
- package/ts/protocols/common/types.ts +0 -76
- package/ts/protocols/http/parser.ts +0 -219
- package/ts/protocols/proxy/index.ts +0 -6
- package/ts/protocols/proxy/types.ts +0 -53
- package/ts/protocols/tls/alerts/index.ts +0 -3
- package/ts/protocols/tls/alerts/tls-alert.ts +0 -259
- package/ts/protocols/tls/index.ts +0 -37
- package/ts/protocols/tls/sni/client-hello-parser.ts +0 -629
- package/ts/protocols/tls/sni/index.ts +0 -6
- package/ts/protocols/tls/sni/sni-extraction.ts +0 -353
- package/ts/protocols/tls/utils/index.ts +0 -3
- package/ts/protocols/tls/utils/tls-utils.ts +0 -201
- package/ts/protocols/websocket/constants.ts +0 -60
- package/ts/protocols/websocket/index.ts +0 -8
- package/ts/protocols/websocket/types.ts +0 -53
- package/ts/protocols/websocket/utils.ts +0 -98
- package/ts/routing/router/http-router.ts +0 -266
- package/ts/routing/router/index.ts +0 -7
- package/ts/tls/index.ts +0 -29
- package/ts/tls/sni/index.ts +0 -3
- package/ts/tls/sni/sni-handler.ts +0 -264
package/dist_ts/tls/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TLS module for smartproxy
|
|
3
|
-
* Re-exports protocol components and provides smartproxy-specific functionality
|
|
4
|
-
*/
|
|
5
|
-
// Re-export all protocol components from protocols/tls
|
|
6
|
-
export * from '../protocols/tls/index.js';
|
|
7
|
-
// Export smartproxy-specific SNI handler
|
|
8
|
-
export * from './sni/sni-handler.js';
|
|
9
|
-
// Create a namespace for SNI utilities
|
|
10
|
-
import { SniHandler } from './sni/sni-handler.js';
|
|
11
|
-
import { SniExtraction } from '../protocols/tls/sni/sni-extraction.js';
|
|
12
|
-
import { ClientHelloParser } from '../protocols/tls/sni/client-hello-parser.js';
|
|
13
|
-
// Export utility objects for convenience
|
|
14
|
-
export const SNI = {
|
|
15
|
-
// Main handler class (for backward compatibility)
|
|
16
|
-
Handler: SniHandler,
|
|
17
|
-
// Utility classes
|
|
18
|
-
Extraction: SniExtraction,
|
|
19
|
-
Parser: ClientHelloParser,
|
|
20
|
-
// Convenience functions
|
|
21
|
-
extractSNI: SniHandler.extractSNI,
|
|
22
|
-
processTlsPacket: SniHandler.processTlsPacket,
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy90bHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7OztHQUdHO0FBRUgsdURBQXVEO0FBQ3ZELGNBQWMsMkJBQTJCLENBQUM7QUFFMUMseUNBQXlDO0FBQ3pDLGNBQWMsc0JBQXNCLENBQUM7QUFFckMsdUNBQXVDO0FBQ3ZDLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUNsRCxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sd0NBQXdDLENBQUM7QUFDdkUsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sNkNBQTZDLENBQUM7QUFFaEYseUNBQXlDO0FBQ3pDLE1BQU0sQ0FBQyxNQUFNLEdBQUcsR0FBRztJQUNqQixrREFBa0Q7SUFDbEQsT0FBTyxFQUFFLFVBQVU7SUFFbkIsa0JBQWtCO0lBQ2xCLFVBQVUsRUFBRSxhQUFhO0lBQ3pCLE1BQU0sRUFBRSxpQkFBaUI7SUFFekIsd0JBQXdCO0lBQ3hCLFVBQVUsRUFBRSxVQUFVLENBQUMsVUFBVTtJQUNqQyxnQkFBZ0IsRUFBRSxVQUFVLENBQUMsZ0JBQWdCO0NBQzlDLENBQUMifQ==
|
package/dist_ts/tls/sni/index.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { Buffer } from 'node:buffer';
|
|
2
|
-
/**
|
|
3
|
-
* SNI (Server Name Indication) handler for TLS connections.
|
|
4
|
-
* Provides robust extraction of SNI values from TLS ClientHello messages
|
|
5
|
-
* with support for fragmented packets, TLS 1.3 resumption, Chrome-specific
|
|
6
|
-
* connection behaviors, and tab hibernation/reactivation scenarios.
|
|
7
|
-
*
|
|
8
|
-
* This class retains the original API but leverages the new modular implementation
|
|
9
|
-
* for better maintainability and testability.
|
|
10
|
-
*/
|
|
11
|
-
export declare class SniHandler {
|
|
12
|
-
private static readonly TLS_HANDSHAKE_RECORD_TYPE;
|
|
13
|
-
private static readonly TLS_APPLICATION_DATA_TYPE;
|
|
14
|
-
private static readonly TLS_CLIENT_HELLO_HANDSHAKE_TYPE;
|
|
15
|
-
private static readonly TLS_SNI_EXTENSION_TYPE;
|
|
16
|
-
private static readonly TLS_SESSION_TICKET_EXTENSION_TYPE;
|
|
17
|
-
private static readonly TLS_SNI_HOST_NAME_TYPE;
|
|
18
|
-
private static readonly TLS_PSK_EXTENSION_TYPE;
|
|
19
|
-
private static readonly TLS_PSK_KE_MODES_EXTENSION_TYPE;
|
|
20
|
-
private static readonly TLS_EARLY_DATA_EXTENSION_TYPE;
|
|
21
|
-
/**
|
|
22
|
-
* Checks if a buffer contains a TLS handshake message (record type 22)
|
|
23
|
-
* @param buffer - The buffer to check
|
|
24
|
-
* @returns true if the buffer starts with a TLS handshake record type
|
|
25
|
-
*/
|
|
26
|
-
static isTlsHandshake(buffer: Buffer): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Checks if a buffer contains TLS application data (record type 23)
|
|
29
|
-
* @param buffer - The buffer to check
|
|
30
|
-
* @returns true if the buffer starts with a TLS application data record type
|
|
31
|
-
*/
|
|
32
|
-
static isTlsApplicationData(buffer: Buffer): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Creates a connection ID based on source/destination information
|
|
35
|
-
* Used to track fragmented ClientHello messages across multiple packets
|
|
36
|
-
*
|
|
37
|
-
* @param connectionInfo - Object containing connection identifiers (IP/port)
|
|
38
|
-
* @returns A string ID for the connection
|
|
39
|
-
*/
|
|
40
|
-
static createConnectionId(connectionInfo: {
|
|
41
|
-
sourceIp?: string;
|
|
42
|
-
sourcePort?: number;
|
|
43
|
-
destIp?: string;
|
|
44
|
-
destPort?: number;
|
|
45
|
-
}): string;
|
|
46
|
-
/**
|
|
47
|
-
* Handles potential fragmented ClientHello messages by buffering and reassembling
|
|
48
|
-
* TLS record fragments that might span multiple TCP packets.
|
|
49
|
-
*
|
|
50
|
-
* @param buffer - The current buffer fragment
|
|
51
|
-
* @param connectionId - Unique identifier for the connection
|
|
52
|
-
* @param enableLogging - Whether to enable logging
|
|
53
|
-
* @returns A complete buffer if reassembly is successful, or undefined if more fragments are needed
|
|
54
|
-
*/
|
|
55
|
-
static handleFragmentedClientHello(buffer: Buffer, connectionId: string, enableLogging?: boolean): Buffer | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Checks if a buffer contains a TLS ClientHello message
|
|
58
|
-
* @param buffer - The buffer to check
|
|
59
|
-
* @returns true if the buffer appears to be a ClientHello message
|
|
60
|
-
*/
|
|
61
|
-
static isClientHello(buffer: Buffer): boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Checks if a ClientHello message contains session resumption indicators
|
|
64
|
-
* such as session tickets or PSK (Pre-Shared Key) extensions.
|
|
65
|
-
*
|
|
66
|
-
* @param buffer - The buffer containing a ClientHello message
|
|
67
|
-
* @param enableLogging - Whether to enable logging
|
|
68
|
-
* @returns Object containing details about session resumption and SNI presence
|
|
69
|
-
*/
|
|
70
|
-
static hasSessionResumption(buffer: Buffer, enableLogging?: boolean): {
|
|
71
|
-
isResumption: boolean;
|
|
72
|
-
hasSNI: boolean;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Detects characteristics of a tab reactivation TLS handshake
|
|
76
|
-
* These often have specific patterns in Chrome and other browsers
|
|
77
|
-
*
|
|
78
|
-
* @param buffer - The buffer containing a ClientHello message
|
|
79
|
-
* @param enableLogging - Whether to enable logging
|
|
80
|
-
* @returns true if this appears to be a tab reactivation handshake
|
|
81
|
-
*/
|
|
82
|
-
static isTabReactivationHandshake(buffer: Buffer, enableLogging?: boolean): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Extracts the SNI (Server Name Indication) from a TLS ClientHello message.
|
|
85
|
-
* Implements robust parsing with support for session resumption edge cases.
|
|
86
|
-
*
|
|
87
|
-
* @param buffer - The buffer containing the TLS ClientHello message
|
|
88
|
-
* @param enableLogging - Whether to enable detailed debug logging
|
|
89
|
-
* @returns The extracted server name or undefined if not found
|
|
90
|
-
*/
|
|
91
|
-
static extractSNI(buffer: Buffer, enableLogging?: boolean): string | undefined;
|
|
92
|
-
/**
|
|
93
|
-
* Attempts to extract SNI from the PSK extension in a TLS 1.3 ClientHello.
|
|
94
|
-
*
|
|
95
|
-
* In TLS 1.3, when a client attempts to resume a session, it may include
|
|
96
|
-
* the server name in the PSK identity hint rather than in the SNI extension.
|
|
97
|
-
*
|
|
98
|
-
* @param buffer - The buffer containing the TLS ClientHello message
|
|
99
|
-
* @param enableLogging - Whether to enable detailed debug logging
|
|
100
|
-
* @returns The extracted server name or undefined if not found
|
|
101
|
-
*/
|
|
102
|
-
static extractSNIFromPSKExtension(buffer: Buffer, enableLogging?: boolean): string | undefined;
|
|
103
|
-
/**
|
|
104
|
-
* Checks if the buffer contains TLS 1.3 early data (0-RTT)
|
|
105
|
-
* @param buffer - The buffer to check
|
|
106
|
-
* @param enableLogging - Whether to enable logging
|
|
107
|
-
* @returns true if early data is detected
|
|
108
|
-
*/
|
|
109
|
-
static hasEarlyData(buffer: Buffer, enableLogging?: boolean): boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Attempts to extract SNI from an initial ClientHello packet and handles
|
|
112
|
-
* session resumption edge cases more robustly than the standard extraction.
|
|
113
|
-
*
|
|
114
|
-
* This method handles:
|
|
115
|
-
* 1. Standard SNI extraction
|
|
116
|
-
* 2. TLS 1.3 PSK-based resumption (Chrome, Firefox, etc.)
|
|
117
|
-
* 3. Session ticket-based resumption
|
|
118
|
-
* 4. Fragmented ClientHello messages
|
|
119
|
-
* 5. TLS 1.3 Early Data (0-RTT)
|
|
120
|
-
* 6. Chrome's connection racing behaviors
|
|
121
|
-
*
|
|
122
|
-
* @param buffer - The buffer containing the TLS ClientHello message
|
|
123
|
-
* @param connectionInfo - Optional connection information for fragment handling
|
|
124
|
-
* @param enableLogging - Whether to enable detailed debug logging
|
|
125
|
-
* @returns The extracted server name or undefined if not found or more data needed
|
|
126
|
-
*/
|
|
127
|
-
static extractSNIWithResumptionSupport(buffer: Buffer, connectionInfo?: {
|
|
128
|
-
sourceIp?: string;
|
|
129
|
-
sourcePort?: number;
|
|
130
|
-
destIp?: string;
|
|
131
|
-
destPort?: number;
|
|
132
|
-
}, enableLogging?: boolean): string | undefined;
|
|
133
|
-
/**
|
|
134
|
-
* Main entry point for SNI extraction that handles all edge cases.
|
|
135
|
-
* This should be called for each TLS packet received from a client.
|
|
136
|
-
*
|
|
137
|
-
* The method uses connection tracking to handle fragmented ClientHello
|
|
138
|
-
* messages and various TLS 1.3 behaviors, including Chrome's connection
|
|
139
|
-
* racing patterns and tab reactivation behaviors.
|
|
140
|
-
*
|
|
141
|
-
* @param buffer - The buffer containing TLS data
|
|
142
|
-
* @param connectionInfo - Connection metadata (IPs and ports)
|
|
143
|
-
* @param enableLogging - Whether to enable detailed debug logging
|
|
144
|
-
* @param cachedSni - Optional cached SNI from previous connections (for racing detection)
|
|
145
|
-
* @returns The extracted server name or undefined if not found or more data needed
|
|
146
|
-
*/
|
|
147
|
-
static processTlsPacket(buffer: Buffer, connectionInfo: {
|
|
148
|
-
sourceIp: string;
|
|
149
|
-
sourcePort: number;
|
|
150
|
-
destIp: string;
|
|
151
|
-
destPort: number;
|
|
152
|
-
timestamp?: number;
|
|
153
|
-
}, enableLogging?: boolean, cachedSni?: string): string | undefined;
|
|
154
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { Buffer } from 'node:buffer';
|
|
2
|
-
import { TlsRecordType, TlsHandshakeType, TlsExtensionType, TlsUtils } from '../../protocols/tls/utils/tls-utils.js';
|
|
3
|
-
import { ClientHelloParser } from '../../protocols/tls/sni/client-hello-parser.js';
|
|
4
|
-
import { SniExtraction } from '../../protocols/tls/sni/sni-extraction.js';
|
|
5
|
-
/**
|
|
6
|
-
* SNI (Server Name Indication) handler for TLS connections.
|
|
7
|
-
* Provides robust extraction of SNI values from TLS ClientHello messages
|
|
8
|
-
* with support for fragmented packets, TLS 1.3 resumption, Chrome-specific
|
|
9
|
-
* connection behaviors, and tab hibernation/reactivation scenarios.
|
|
10
|
-
*
|
|
11
|
-
* This class retains the original API but leverages the new modular implementation
|
|
12
|
-
* for better maintainability and testability.
|
|
13
|
-
*/
|
|
14
|
-
export class SniHandler {
|
|
15
|
-
// Re-export constants for backward compatibility
|
|
16
|
-
static { this.TLS_HANDSHAKE_RECORD_TYPE = TlsRecordType.HANDSHAKE; }
|
|
17
|
-
static { this.TLS_APPLICATION_DATA_TYPE = TlsRecordType.APPLICATION_DATA; }
|
|
18
|
-
static { this.TLS_CLIENT_HELLO_HANDSHAKE_TYPE = TlsHandshakeType.CLIENT_HELLO; }
|
|
19
|
-
static { this.TLS_SNI_EXTENSION_TYPE = TlsExtensionType.SERVER_NAME; }
|
|
20
|
-
static { this.TLS_SESSION_TICKET_EXTENSION_TYPE = TlsExtensionType.SESSION_TICKET; }
|
|
21
|
-
static { this.TLS_SNI_HOST_NAME_TYPE = 0; } // NameType.HOST_NAME in RFC 6066
|
|
22
|
-
static { this.TLS_PSK_EXTENSION_TYPE = TlsExtensionType.PRE_SHARED_KEY; }
|
|
23
|
-
static { this.TLS_PSK_KE_MODES_EXTENSION_TYPE = TlsExtensionType.PSK_KEY_EXCHANGE_MODES; }
|
|
24
|
-
static { this.TLS_EARLY_DATA_EXTENSION_TYPE = TlsExtensionType.EARLY_DATA; }
|
|
25
|
-
/**
|
|
26
|
-
* Checks if a buffer contains a TLS handshake message (record type 22)
|
|
27
|
-
* @param buffer - The buffer to check
|
|
28
|
-
* @returns true if the buffer starts with a TLS handshake record type
|
|
29
|
-
*/
|
|
30
|
-
static isTlsHandshake(buffer) {
|
|
31
|
-
return TlsUtils.isTlsHandshake(buffer);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Checks if a buffer contains TLS application data (record type 23)
|
|
35
|
-
* @param buffer - The buffer to check
|
|
36
|
-
* @returns true if the buffer starts with a TLS application data record type
|
|
37
|
-
*/
|
|
38
|
-
static isTlsApplicationData(buffer) {
|
|
39
|
-
return TlsUtils.isTlsApplicationData(buffer);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Creates a connection ID based on source/destination information
|
|
43
|
-
* Used to track fragmented ClientHello messages across multiple packets
|
|
44
|
-
*
|
|
45
|
-
* @param connectionInfo - Object containing connection identifiers (IP/port)
|
|
46
|
-
* @returns A string ID for the connection
|
|
47
|
-
*/
|
|
48
|
-
static createConnectionId(connectionInfo) {
|
|
49
|
-
return TlsUtils.createConnectionId(connectionInfo);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Handles potential fragmented ClientHello messages by buffering and reassembling
|
|
53
|
-
* TLS record fragments that might span multiple TCP packets.
|
|
54
|
-
*
|
|
55
|
-
* @param buffer - The current buffer fragment
|
|
56
|
-
* @param connectionId - Unique identifier for the connection
|
|
57
|
-
* @param enableLogging - Whether to enable logging
|
|
58
|
-
* @returns A complete buffer if reassembly is successful, or undefined if more fragments are needed
|
|
59
|
-
*/
|
|
60
|
-
static handleFragmentedClientHello(buffer, connectionId, enableLogging = false) {
|
|
61
|
-
const logger = enableLogging ?
|
|
62
|
-
(message) => console.log(`[SNI Fragment] ${message}`) :
|
|
63
|
-
undefined;
|
|
64
|
-
return ClientHelloParser.handleFragmentedClientHello(buffer, connectionId, logger);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Checks if a buffer contains a TLS ClientHello message
|
|
68
|
-
* @param buffer - The buffer to check
|
|
69
|
-
* @returns true if the buffer appears to be a ClientHello message
|
|
70
|
-
*/
|
|
71
|
-
static isClientHello(buffer) {
|
|
72
|
-
return TlsUtils.isClientHello(buffer);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Checks if a ClientHello message contains session resumption indicators
|
|
76
|
-
* such as session tickets or PSK (Pre-Shared Key) extensions.
|
|
77
|
-
*
|
|
78
|
-
* @param buffer - The buffer containing a ClientHello message
|
|
79
|
-
* @param enableLogging - Whether to enable logging
|
|
80
|
-
* @returns Object containing details about session resumption and SNI presence
|
|
81
|
-
*/
|
|
82
|
-
static hasSessionResumption(buffer, enableLogging = false) {
|
|
83
|
-
const logger = enableLogging ?
|
|
84
|
-
(message) => console.log(`[Session Resumption] ${message}`) :
|
|
85
|
-
undefined;
|
|
86
|
-
return ClientHelloParser.hasSessionResumption(buffer, logger);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Detects characteristics of a tab reactivation TLS handshake
|
|
90
|
-
* These often have specific patterns in Chrome and other browsers
|
|
91
|
-
*
|
|
92
|
-
* @param buffer - The buffer containing a ClientHello message
|
|
93
|
-
* @param enableLogging - Whether to enable logging
|
|
94
|
-
* @returns true if this appears to be a tab reactivation handshake
|
|
95
|
-
*/
|
|
96
|
-
static isTabReactivationHandshake(buffer, enableLogging = false) {
|
|
97
|
-
const logger = enableLogging ?
|
|
98
|
-
(message) => console.log(`[Tab Reactivation] ${message}`) :
|
|
99
|
-
undefined;
|
|
100
|
-
return ClientHelloParser.isTabReactivationHandshake(buffer, logger);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Extracts the SNI (Server Name Indication) from a TLS ClientHello message.
|
|
104
|
-
* Implements robust parsing with support for session resumption edge cases.
|
|
105
|
-
*
|
|
106
|
-
* @param buffer - The buffer containing the TLS ClientHello message
|
|
107
|
-
* @param enableLogging - Whether to enable detailed debug logging
|
|
108
|
-
* @returns The extracted server name or undefined if not found
|
|
109
|
-
*/
|
|
110
|
-
static extractSNI(buffer, enableLogging = false) {
|
|
111
|
-
const logger = enableLogging ?
|
|
112
|
-
(message) => console.log(`[SNI Extraction] ${message}`) :
|
|
113
|
-
undefined;
|
|
114
|
-
return SniExtraction.extractSNI(buffer, logger);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Attempts to extract SNI from the PSK extension in a TLS 1.3 ClientHello.
|
|
118
|
-
*
|
|
119
|
-
* In TLS 1.3, when a client attempts to resume a session, it may include
|
|
120
|
-
* the server name in the PSK identity hint rather than in the SNI extension.
|
|
121
|
-
*
|
|
122
|
-
* @param buffer - The buffer containing the TLS ClientHello message
|
|
123
|
-
* @param enableLogging - Whether to enable detailed debug logging
|
|
124
|
-
* @returns The extracted server name or undefined if not found
|
|
125
|
-
*/
|
|
126
|
-
static extractSNIFromPSKExtension(buffer, enableLogging = false) {
|
|
127
|
-
const logger = enableLogging ?
|
|
128
|
-
(message) => console.log(`[PSK-SNI Extraction] ${message}`) :
|
|
129
|
-
undefined;
|
|
130
|
-
return SniExtraction.extractSNIFromPSKExtension(buffer, logger);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Checks if the buffer contains TLS 1.3 early data (0-RTT)
|
|
134
|
-
* @param buffer - The buffer to check
|
|
135
|
-
* @param enableLogging - Whether to enable logging
|
|
136
|
-
* @returns true if early data is detected
|
|
137
|
-
*/
|
|
138
|
-
static hasEarlyData(buffer, enableLogging = false) {
|
|
139
|
-
// This functionality has been moved to ClientHelloParser
|
|
140
|
-
// We can implement it in terms of the parse result if needed
|
|
141
|
-
const logger = enableLogging ?
|
|
142
|
-
(message) => console.log(`[Early Data] ${message}`) :
|
|
143
|
-
undefined;
|
|
144
|
-
const parseResult = ClientHelloParser.parseClientHello(buffer, logger);
|
|
145
|
-
return parseResult.isValid && parseResult.hasEarlyData;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Attempts to extract SNI from an initial ClientHello packet and handles
|
|
149
|
-
* session resumption edge cases more robustly than the standard extraction.
|
|
150
|
-
*
|
|
151
|
-
* This method handles:
|
|
152
|
-
* 1. Standard SNI extraction
|
|
153
|
-
* 2. TLS 1.3 PSK-based resumption (Chrome, Firefox, etc.)
|
|
154
|
-
* 3. Session ticket-based resumption
|
|
155
|
-
* 4. Fragmented ClientHello messages
|
|
156
|
-
* 5. TLS 1.3 Early Data (0-RTT)
|
|
157
|
-
* 6. Chrome's connection racing behaviors
|
|
158
|
-
*
|
|
159
|
-
* @param buffer - The buffer containing the TLS ClientHello message
|
|
160
|
-
* @param connectionInfo - Optional connection information for fragment handling
|
|
161
|
-
* @param enableLogging - Whether to enable detailed debug logging
|
|
162
|
-
* @returns The extracted server name or undefined if not found or more data needed
|
|
163
|
-
*/
|
|
164
|
-
static extractSNIWithResumptionSupport(buffer, connectionInfo, enableLogging = false) {
|
|
165
|
-
const logger = enableLogging ?
|
|
166
|
-
(message) => console.log(`[SNI Extraction] ${message}`) :
|
|
167
|
-
undefined;
|
|
168
|
-
return SniExtraction.extractSNIWithResumptionSupport(buffer, connectionInfo, logger);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Main entry point for SNI extraction that handles all edge cases.
|
|
172
|
-
* This should be called for each TLS packet received from a client.
|
|
173
|
-
*
|
|
174
|
-
* The method uses connection tracking to handle fragmented ClientHello
|
|
175
|
-
* messages and various TLS 1.3 behaviors, including Chrome's connection
|
|
176
|
-
* racing patterns and tab reactivation behaviors.
|
|
177
|
-
*
|
|
178
|
-
* @param buffer - The buffer containing TLS data
|
|
179
|
-
* @param connectionInfo - Connection metadata (IPs and ports)
|
|
180
|
-
* @param enableLogging - Whether to enable detailed debug logging
|
|
181
|
-
* @param cachedSni - Optional cached SNI from previous connections (for racing detection)
|
|
182
|
-
* @returns The extracted server name or undefined if not found or more data needed
|
|
183
|
-
*/
|
|
184
|
-
static processTlsPacket(buffer, connectionInfo, enableLogging = false, cachedSni) {
|
|
185
|
-
const logger = enableLogging ?
|
|
186
|
-
(message) => console.log(`[TLS Packet] ${message}`) :
|
|
187
|
-
undefined;
|
|
188
|
-
return SniExtraction.processTlsPacket(buffer, connectionInfo, logger, cachedSni);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic25pLWhhbmRsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi90cy90bHMvc25pL3NuaS1oYW5kbGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFDckMsT0FBTyxFQUNMLGFBQWEsRUFDYixnQkFBZ0IsRUFDaEIsZ0JBQWdCLEVBQ2hCLFFBQVEsRUFDVCxNQUFNLHdDQUF3QyxDQUFDO0FBQ2hELE9BQU8sRUFDTCxpQkFBaUIsRUFFbEIsTUFBTSxnREFBZ0QsQ0FBQztBQUN4RCxPQUFPLEVBQ0wsYUFBYSxFQUVkLE1BQU0sMkNBQTJDL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LENBQUMsZ0JBQWdCLENBQUMsTUFBTSxFQUFFLGNBQWMsRUFBRSxNQUFNLEVBQUUsU0FBUyxDQUFDLENBQUM7SUFDbkYsQ0FBQyJ9
|
package/ts/core/events/index.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as plugins from '../../plugins.js';
|
|
2
|
-
|
|
3
|
-
// Augment the Node.js Socket type to include TLS-related properties
|
|
4
|
-
// This helps TypeScript understand properties that are dynamically added by Node.js
|
|
5
|
-
declare module 'net' {
|
|
6
|
-
interface Socket {
|
|
7
|
-
// TLS-related properties
|
|
8
|
-
encrypted?: boolean; // Indicates if the socket is encrypted (TLS/SSL)
|
|
9
|
-
authorizationError?: Error; // Authentication error if TLS handshake failed
|
|
10
|
-
|
|
11
|
-
// TLS-related methods
|
|
12
|
-
getTLSVersion?(): string; // Returns the TLS version (e.g., 'TLSv1.2', 'TLSv1.3')
|
|
13
|
-
getPeerCertificate?(detailed?: boolean): any; // Returns the peer's certificate
|
|
14
|
-
getSession?(): Buffer; // Returns the TLS session data
|
|
15
|
-
|
|
16
|
-
// Connection tracking properties (used by HttpProxy)
|
|
17
|
-
_connectionId?: string; // Unique identifier for the connection
|
|
18
|
-
_remoteIP?: string; // Remote IP address
|
|
19
|
-
_realRemoteIP?: string; // Real remote IP (when proxied)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Export a utility function to check if a socket is a TLS socket
|
|
24
|
-
export function isTLSSocket(socket: plugins.net.Socket): boolean {
|
|
25
|
-
return 'encrypted' in socket && !!socket.encrypted;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Export a utility function to safely get the TLS version
|
|
29
|
-
export function getTLSVersion(socket: plugins.net.Socket): string | null {
|
|
30
|
-
if (socket.getTLSVersion) {
|
|
31
|
-
try {
|
|
32
|
-
return socket.getTLSVersion();
|
|
33
|
-
} catch (e) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return null;
|
|
38
|
-
}
|