Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ulixee
GitHub Repository: ulixee/secret-agent
Path: blob/main/plugins/default-browser-emulator/lib/utils/getTcpSettingsForOs.ts
1030 views
1
import { IVersion } from '@secret-agent/interfaces/IUserAgentOption';
2
3
export default function getTcpSettingsForOs(name: string, version: IVersion) {
4
if (!name) return null;
5
6
const ttl = expectedTtlValues[name] ?? 64;
7
8
let windowSize = expectedWindowSizes[name];
9
if (!windowSize || !windowSize.length) {
10
if (name === 'windows') {
11
if (parseInt(version.major, 10) >= 10) {
12
windowSize = expectedWindowSizes['windows-10'];
13
} else {
14
windowSize = expectedWindowSizes['windows-7'];
15
}
16
}
17
}
18
19
if (!windowSize || !windowSize.length) {
20
return null;
21
}
22
23
return {
24
ttl,
25
windowSize: windowSize[0],
26
};
27
}
28
29
const expectedTtlValues = {
30
'mac-os': 64,
31
'linux': 64,
32
'windows': 128,
33
};
34
35
const expectedWindowSizes = {
36
'mac-os': [65535],
37
'linux': [5840, 29200, 5720],
38
'windows-7': [8192],
39
'Windows-10': [64240, 65535],
40
};
41
42