socket-function 0.9.3 → 0.9.4
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/.eslintrc.js +50 -50
- package/SocketFunction.ts +280 -280
- package/SocketFunctionTypes.ts +90 -90
- package/hot/HotReloadController.ts +105 -105
- package/mobx/UrlParam.ts +39 -39
- package/mobx/observer.tsx +49 -49
- package/mobx/promiseToObservable.tsx +41 -41
- package/package.json +1 -1
- package/require/CSSShim.ts +19 -19
- package/require/RequireController.ts +252 -252
- package/require/buffer.js +2368 -2368
- package/require/compileFlags.ts +44 -44
- package/require/require.html +13 -13
- package/require/require.js +462 -462
- package/spec.txt +115 -115
- package/src/CallFactory.ts +389 -389
- package/src/JSONLACKS/JSONLACKS.generated.js +17 -17
- package/src/JSONLACKS/JSONLACKS.pegjs +247 -247
- package/src/JSONLACKS/JSONLACKS.ts +429 -429
- package/src/args.ts +21 -21
- package/src/batching.ts +170 -170
- package/src/caching.ts +324 -318
- package/src/callHTTPHandler.ts +203 -203
- package/src/callManager.ts +134 -134
- package/src/certStore.ts +29 -29
- package/src/fixLargeNetworkCalls.ts +8 -8
- package/src/formatting/colors.ts +78 -78
- package/src/formatting/format.ts +160 -160
- package/src/formatting/logColors.ts +17 -17
- package/src/misc.ts +303 -302
- package/src/nodeCache.ts +92 -92
- package/src/nodeProxy.ts +54 -54
- package/src/profiling/getOwnTime.ts +142 -142
- package/src/profiling/measure.ts +273 -273
- package/src/profiling/stats.ts +212 -212
- package/src/profiling/tcpLagProxy.ts +63 -63
- package/src/storagePath.ts +10 -10
- package/src/tlsParsing.ts +96 -96
- package/src/types.ts +8 -8
- package/src/webSocketServer.ts +250 -250
- package/test/client.css +2 -2
- package/test/client.ts +46 -46
- package/test/server.ts +43 -43
- package/test/shared.ts +52 -52
- package/tsconfig.json +26 -26
package/src/tlsParsing.ts
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
export function parseTLSHello(buffer: Buffer): {
|
|
2
|
-
extensions: {
|
|
3
|
-
type: number;
|
|
4
|
-
data: Buffer;
|
|
5
|
-
}[];
|
|
6
|
-
} {
|
|
7
|
-
let output: {
|
|
8
|
-
extensions: {
|
|
9
|
-
type: number;
|
|
10
|
-
data: Buffer;
|
|
11
|
-
}[];
|
|
12
|
-
} = {
|
|
13
|
-
extensions: []
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
let pos = 0;
|
|
18
|
-
|
|
19
|
-
function readShort() {
|
|
20
|
-
let high = buffer[pos++];
|
|
21
|
-
let low = buffer[pos++];
|
|
22
|
-
return high * 256 + low;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let type = buffer[pos++];
|
|
26
|
-
let version = readShort();
|
|
27
|
-
|
|
28
|
-
var contentLength = readShort();
|
|
29
|
-
|
|
30
|
-
let clientMessageType = buffer[pos++];
|
|
31
|
-
// High length byte (how would this be used if contentLength is only 2 bytes?)
|
|
32
|
-
pos++;
|
|
33
|
-
let clientMessageLength = readShort();
|
|
34
|
-
|
|
35
|
-
// Client version
|
|
36
|
-
let clientVersion = readShort();
|
|
37
|
-
|
|
38
|
-
// Client random
|
|
39
|
-
pos += 32;
|
|
40
|
-
|
|
41
|
-
// Session id
|
|
42
|
-
let sessionIdLength = buffer[pos++];
|
|
43
|
-
pos += sessionIdLength;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
let cipherSuiteLength = readShort();
|
|
47
|
-
pos += cipherSuiteLength;
|
|
48
|
-
|
|
49
|
-
let compressionLength = buffer[pos++];
|
|
50
|
-
pos += compressionLength;
|
|
51
|
-
|
|
52
|
-
let extensionsLength = readShort();
|
|
53
|
-
let extensionsEnd = pos + extensionsLength;
|
|
54
|
-
while (pos < extensionsEnd) {
|
|
55
|
-
let extensionType = readShort();
|
|
56
|
-
let length = readShort();
|
|
57
|
-
|
|
58
|
-
output.extensions.push({
|
|
59
|
-
type: extensionType, data: viewSliceBuffer(buffer, pos, length)
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
pos += length;
|
|
63
|
-
}
|
|
64
|
-
} catch { }
|
|
65
|
-
|
|
66
|
-
return output;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export const SNIType = 0x0;
|
|
70
|
-
export function parseSNIExtension(data: Buffer): string[] {
|
|
71
|
-
let pos = 0;
|
|
72
|
-
function readShort() {
|
|
73
|
-
let high = data[pos++];
|
|
74
|
-
let low = data[pos++];
|
|
75
|
-
return high * 256 + low;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let snis: string[] = [];
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
while (pos < data.length) {
|
|
82
|
-
let len = readShort();
|
|
83
|
-
let end = pos + len;
|
|
84
|
-
let type = data[pos++];
|
|
85
|
-
let len2 = readShort();
|
|
86
|
-
snis.push(viewSliceBuffer(data, pos, len2).toString());
|
|
87
|
-
pos = end;
|
|
88
|
-
}
|
|
89
|
-
} catch { }
|
|
90
|
-
|
|
91
|
-
return snis;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function viewSliceBuffer(data: Buffer, index: number, count?: number) {
|
|
95
|
-
count = count ?? (data.length - index);
|
|
96
|
-
return Buffer.from(data.buffer, data.byteOffset + index, count);
|
|
1
|
+
export function parseTLSHello(buffer: Buffer): {
|
|
2
|
+
extensions: {
|
|
3
|
+
type: number;
|
|
4
|
+
data: Buffer;
|
|
5
|
+
}[];
|
|
6
|
+
} {
|
|
7
|
+
let output: {
|
|
8
|
+
extensions: {
|
|
9
|
+
type: number;
|
|
10
|
+
data: Buffer;
|
|
11
|
+
}[];
|
|
12
|
+
} = {
|
|
13
|
+
extensions: []
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
let pos = 0;
|
|
18
|
+
|
|
19
|
+
function readShort() {
|
|
20
|
+
let high = buffer[pos++];
|
|
21
|
+
let low = buffer[pos++];
|
|
22
|
+
return high * 256 + low;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let type = buffer[pos++];
|
|
26
|
+
let version = readShort();
|
|
27
|
+
|
|
28
|
+
var contentLength = readShort();
|
|
29
|
+
|
|
30
|
+
let clientMessageType = buffer[pos++];
|
|
31
|
+
// High length byte (how would this be used if contentLength is only 2 bytes?)
|
|
32
|
+
pos++;
|
|
33
|
+
let clientMessageLength = readShort();
|
|
34
|
+
|
|
35
|
+
// Client version
|
|
36
|
+
let clientVersion = readShort();
|
|
37
|
+
|
|
38
|
+
// Client random
|
|
39
|
+
pos += 32;
|
|
40
|
+
|
|
41
|
+
// Session id
|
|
42
|
+
let sessionIdLength = buffer[pos++];
|
|
43
|
+
pos += sessionIdLength;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
let cipherSuiteLength = readShort();
|
|
47
|
+
pos += cipherSuiteLength;
|
|
48
|
+
|
|
49
|
+
let compressionLength = buffer[pos++];
|
|
50
|
+
pos += compressionLength;
|
|
51
|
+
|
|
52
|
+
let extensionsLength = readShort();
|
|
53
|
+
let extensionsEnd = pos + extensionsLength;
|
|
54
|
+
while (pos < extensionsEnd) {
|
|
55
|
+
let extensionType = readShort();
|
|
56
|
+
let length = readShort();
|
|
57
|
+
|
|
58
|
+
output.extensions.push({
|
|
59
|
+
type: extensionType, data: viewSliceBuffer(buffer, pos, length)
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
pos += length;
|
|
63
|
+
}
|
|
64
|
+
} catch { }
|
|
65
|
+
|
|
66
|
+
return output;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const SNIType = 0x0;
|
|
70
|
+
export function parseSNIExtension(data: Buffer): string[] {
|
|
71
|
+
let pos = 0;
|
|
72
|
+
function readShort() {
|
|
73
|
+
let high = data[pos++];
|
|
74
|
+
let low = data[pos++];
|
|
75
|
+
return high * 256 + low;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let snis: string[] = [];
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
while (pos < data.length) {
|
|
82
|
+
let len = readShort();
|
|
83
|
+
let end = pos + len;
|
|
84
|
+
let type = data[pos++];
|
|
85
|
+
let len2 = readShort();
|
|
86
|
+
snis.push(viewSliceBuffer(data, pos, len2).toString());
|
|
87
|
+
pos = end;
|
|
88
|
+
}
|
|
89
|
+
} catch { }
|
|
90
|
+
|
|
91
|
+
return snis;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function viewSliceBuffer(data: Buffer, index: number, count?: number) {
|
|
95
|
+
count = count ?? (data.length - index);
|
|
96
|
+
return Buffer.from(data.buffer, data.byteOffset + index, count);
|
|
97
97
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type MaybePromise<T> = T | Promise<T>;
|
|
2
|
-
|
|
3
|
-
export type Args<T> = T extends (...args: infer V) => any ? V : never;
|
|
4
|
-
|
|
5
|
-
export type AnyFunction = (...args: any) => any;
|
|
6
|
-
|
|
7
|
-
export function canHaveChildren(value: unknown): value is { [key in PropertyKey]: unknown } {
|
|
8
|
-
return typeof value === "object" && value !== null || typeof value === "function";
|
|
1
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
2
|
+
|
|
3
|
+
export type Args<T> = T extends (...args: infer V) => any ? V : never;
|
|
4
|
+
|
|
5
|
+
export type AnyFunction = (...args: any) => any;
|
|
6
|
+
|
|
7
|
+
export function canHaveChildren(value: unknown): value is { [key in PropertyKey]: unknown } {
|
|
8
|
+
return typeof value === "object" && value !== null || typeof value === "function";
|
|
9
9
|
}
|