puppyproxy 1.1.2 → 1.1.3
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/package.json +1 -1
- package/src/network/RequestClient.js +6 -1
- package/src/utils.js +9 -4
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import log from 'puppylog';
|
|
2
2
|
import id from 'puppyid';
|
|
3
3
|
import { originals } from '../constants.js';
|
|
4
|
+
import scrambled from 'puppyscrambled';
|
|
5
|
+
import { createBasicAgent } from '../utils.js';
|
|
4
6
|
|
|
5
7
|
export class ProxyRequest {
|
|
6
8
|
constructor(requestClient, url, options = {}) {
|
|
@@ -292,10 +294,13 @@ export default class RequestClient {
|
|
|
292
294
|
const uniqueProxies = [];
|
|
293
295
|
|
|
294
296
|
while (currentWithoutNew < withoutNewLimit) {
|
|
295
|
-
const pr = this.createProxyRequest(url, options);
|
|
297
|
+
const pr = this.createProxyRequest(url, { ...options });
|
|
296
298
|
const proxy = pr.options.AGENT?.USINGSCRAPED;
|
|
297
299
|
|
|
298
300
|
if (proxy && !uniqueProxies.includes(proxy)) {
|
|
301
|
+
pr.id = scrambled.getScrambled();
|
|
302
|
+
console.log(pr.id, pr.options.AGENT.___id, "added proxy to pool:", proxy);
|
|
303
|
+
pr.options.AGENT.___id = pr.id;
|
|
299
304
|
proxyRequests.push(pr);
|
|
300
305
|
uniqueProxies.push(proxy);
|
|
301
306
|
currentWithoutNew = 0;
|
package/src/utils.js
CHANGED
|
@@ -4,9 +4,14 @@ import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
|
4
4
|
|
|
5
5
|
export function createBasicAgent(proxyUrl) {
|
|
6
6
|
if (!proxyUrl) return null;
|
|
7
|
+
|
|
8
|
+
let proxy = null;
|
|
7
9
|
|
|
8
|
-
if (proxyUrl.startsWith("socks"))
|
|
9
|
-
if (proxyUrl.startsWith("https"))
|
|
10
|
-
if (proxyUrl.startsWith("http"))
|
|
11
|
-
|
|
10
|
+
if (proxyUrl.startsWith("socks")) proxy = new SocksProxyAgent(proxyUrl);
|
|
11
|
+
else if (proxyUrl.startsWith("https")) proxy = new HttpsProxyAgent(proxyUrl);
|
|
12
|
+
else if (proxyUrl.startsWith("http")) proxy = new HttpProxyAgent(proxyUrl);
|
|
13
|
+
|
|
14
|
+
proxy.USINGSCRAPED = proxyUrl;
|
|
15
|
+
|
|
16
|
+
return proxy;
|
|
12
17
|
}
|