gologin 2.1.25 → 2.1.27
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 +14 -0
- package/package.json +1 -1
- package/src/gologin.js +18 -8
- package/src/utils/http.js +17 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Combined changelog for GoLogin node.js SDK
|
|
4
4
|
|
|
5
|
+
## [2.1.26] 2025-07-02
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### New
|
|
9
|
+
|
|
10
|
+
* Added possibility to change proxy check timeout
|
|
11
|
+
|
|
12
|
+
## [2.1.26] 2025-07-02
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Fixes
|
|
16
|
+
|
|
17
|
+
* Socks 5 proxy passing
|
|
18
|
+
|
|
5
19
|
## [2.1.24] 2025-06-16
|
|
6
20
|
|
|
7
21
|
|
package/package.json
CHANGED
package/src/gologin.js
CHANGED
|
@@ -80,6 +80,8 @@ export class GoLogin {
|
|
|
80
80
|
this.processKillTimeout = 1 * 1000;
|
|
81
81
|
this.browserMajorVersion = 0;
|
|
82
82
|
this.newProxyOrbbitaMajorVersion = 135;
|
|
83
|
+
this.proxyCheckTimeout = options.proxyCheckTimeout || 13 * 1000;
|
|
84
|
+
this.proxyCheckAttempts = options.proxyCheckAttempts || 3;
|
|
83
85
|
|
|
84
86
|
if (process.env.DISABLE_TELEMETRY !== 'true') {
|
|
85
87
|
Sentry.init({
|
|
@@ -738,9 +740,15 @@ export class GoLogin {
|
|
|
738
740
|
|
|
739
741
|
const proxyUrl = `${proxy.mode}://${proxy.username}:${proxy.password}@${proxy.host}:${proxy.port}`;
|
|
740
742
|
debug(`getTimeZone start ${TIMEZONE_URL}`, proxyUrl);
|
|
741
|
-
|
|
743
|
+
|
|
744
|
+
data = await makeRequest(TIMEZONE_URL, {
|
|
745
|
+
proxy: proxyUrl,
|
|
746
|
+
timeout: this.proxyCheckTimeout,
|
|
747
|
+
maxAttempts: this.proxyCheckAttempts,
|
|
748
|
+
method: 'GET',
|
|
749
|
+
});
|
|
742
750
|
} else {
|
|
743
|
-
data = await makeRequest(TIMEZONE_URL, { timeout:
|
|
751
|
+
data = await makeRequest(TIMEZONE_URL, { timeout: this.proxyCheckTimeout, maxAttempts: this.proxyCheckAttempts, method: 'GET' });
|
|
744
752
|
}
|
|
745
753
|
|
|
746
754
|
debug('getTimeZone finish', data);
|
|
@@ -785,7 +793,7 @@ export class GoLogin {
|
|
|
785
793
|
|
|
786
794
|
const checkData = await checkSocksProxy(agent);
|
|
787
795
|
|
|
788
|
-
const body = checkData || {};
|
|
796
|
+
const body = checkData.body || {};
|
|
789
797
|
if (!body.ip && checkData.statusCode.toString().startsWith('4')) {
|
|
790
798
|
throw checkData;
|
|
791
799
|
}
|
|
@@ -810,7 +818,7 @@ export class GoLogin {
|
|
|
810
818
|
|
|
811
819
|
await makeRequest(
|
|
812
820
|
`${API_URL}/proxy/set_proxy_statuses`,
|
|
813
|
-
{ timeout:
|
|
821
|
+
{ timeout: this.proxyCheckTimeout, maxAttempts: this.proxyCheckAttempts, method: 'POST', json: statusBody },
|
|
814
822
|
{ token: this.access_token, fallbackUrl: `${FALLBACK_API_URL}/proxy/set_proxy_statuses` },
|
|
815
823
|
).catch();
|
|
816
824
|
}
|
|
@@ -929,10 +937,13 @@ export class GoLogin {
|
|
|
929
937
|
|
|
930
938
|
if (proxy) {
|
|
931
939
|
const hr_rules = `"MAP * 0.0.0.0 , EXCLUDE ${proxy_host}"`;
|
|
932
|
-
params.push(`--proxy-server=${proxy}`);
|
|
933
940
|
params.push(`--host-resolver-rules=${hr_rules}`);
|
|
934
941
|
}
|
|
935
942
|
|
|
943
|
+
if (proxy && Number(this.browserMajorVersion) < this.newProxyOrbbitaMajorVersion) {
|
|
944
|
+
params.push(`--proxy-server=${proxy}`);
|
|
945
|
+
}
|
|
946
|
+
|
|
936
947
|
if (Array.isArray(this.extra_params) && this.extra_params.length) {
|
|
937
948
|
params = params.concat(this.extra_params);
|
|
938
949
|
}
|
|
@@ -945,9 +956,8 @@ export class GoLogin {
|
|
|
945
956
|
console.log('params', params);
|
|
946
957
|
const child = execFile(ORBITA_BROWSER, params, { env });
|
|
947
958
|
this.processSpawned = child;
|
|
948
|
-
//
|
|
949
|
-
child.
|
|
950
|
-
child.stderr.on('data', (data) => console.log(data.toString()));
|
|
959
|
+
// child.stdout.on('error', (data) => console.log(data.toString()));
|
|
960
|
+
// child.stderr.on('data', (data) => console.log(data.toString()));
|
|
951
961
|
debug('SPAWN CMD', ORBITA_BROWSER, params.join(' '));
|
|
952
962
|
}
|
|
953
963
|
|
package/src/utils/http.js
CHANGED
|
@@ -3,8 +3,23 @@ import requests from 'requestretry';
|
|
|
3
3
|
|
|
4
4
|
const TIMEZONE_URL = 'https://geo.myip.link';
|
|
5
5
|
|
|
6
|
+
const createTimeoutPromise = (timeoutMs) => new Promise((_, reject) => {
|
|
7
|
+
setTimeout(() => {
|
|
8
|
+
reject(new Error(`Request timeout after ${timeoutMs}ms`));
|
|
9
|
+
}, timeoutMs);
|
|
10
|
+
});
|
|
11
|
+
|
|
6
12
|
const attemptRequest = async (requestUrl, options) => {
|
|
7
|
-
const
|
|
13
|
+
const requestPromise = requests(requestUrl, options);
|
|
14
|
+
|
|
15
|
+
let req;
|
|
16
|
+
if (options.proxy) {
|
|
17
|
+
const timeoutPromise = createTimeoutPromise(options.timeout || 30000);
|
|
18
|
+
req = await Promise.race([requestPromise, timeoutPromise]);
|
|
19
|
+
} else {
|
|
20
|
+
req = await requestPromise;
|
|
21
|
+
}
|
|
22
|
+
|
|
8
23
|
if (req.statusCode >= 400) {
|
|
9
24
|
const error = new Error(req.body);
|
|
10
25
|
error.statusCode = req.statusCode;
|
|
@@ -39,7 +54,7 @@ export const makeRequest = async (url, options, internalOptions) => {
|
|
|
39
54
|
};
|
|
40
55
|
|
|
41
56
|
export const checkSocksProxy = async (agent) => new Promise((resolve, reject) => {
|
|
42
|
-
_get(TIMEZONE_URL, { agent, timeout:
|
|
57
|
+
_get(TIMEZONE_URL, { agent, timeout: 8000 }, (res) => {
|
|
43
58
|
let resultResponse = '';
|
|
44
59
|
res.on('data', (data) => {
|
|
45
60
|
resultResponse += data;
|