puppyproxy 1.1.5 → 1.1.7
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
CHANGED
package/src/PuppyProxy.js
CHANGED
|
@@ -12,7 +12,7 @@ export default class PuppyProxy {
|
|
|
12
12
|
/**
|
|
13
13
|
* @param {Object} config - The configuration object
|
|
14
14
|
*/
|
|
15
|
-
constructor(config) {
|
|
15
|
+
constructor(config = {}) {
|
|
16
16
|
this.config = config;
|
|
17
17
|
this.config.storeDir = this.config.storeDir || this.resolveDataDir();
|
|
18
18
|
console.log("Using data store directory:", this.config.storeDir);
|
|
@@ -49,6 +49,13 @@ export default class PuppyProxy {
|
|
|
49
49
|
// Load scraped proxies into memory
|
|
50
50
|
await this.scraper.runCollector(forceCollector);
|
|
51
51
|
await this.scraper.loadScrapedProxies();
|
|
52
|
+
|
|
53
|
+
if (this.config.scraper?.autoCollectProxies) {
|
|
54
|
+
log.info(id, `Auto proxy collection enabled. Running every ${this.config.scraper.autoCollectProxies} minutes.`);
|
|
55
|
+
setInterval(async () => {
|
|
56
|
+
await this.scraper.runCollector();
|
|
57
|
+
}, (this.config.scraper.autoCollectProxies) * 60e3); // minutes to ms
|
|
58
|
+
}
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
/**
|
package/src/providers/Scraper.js
CHANGED
|
@@ -91,12 +91,11 @@ export default class Scraper {
|
|
|
91
91
|
return null;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
// Worker Orchestration
|
|
95
94
|
async runCollector(force = false) {
|
|
96
95
|
let lastSaved = (Date.now() - getLastSavedTimestamp(this.outputPath)) / 1000; // ms to seconds
|
|
97
96
|
if (lastSaved && !force) {
|
|
98
97
|
console.log("lastSaved", lastSaved);
|
|
99
|
-
let timeBetweenScrapes = this.config
|
|
98
|
+
let timeBetweenScrapes = (this.config?.scraper?.timeBetweenScrapes || 10) * 60; // mins to seconds
|
|
100
99
|
if (lastSaved < timeBetweenScrapes) {
|
|
101
100
|
console.log(`Proxies saved < ${timeBetweenScrapes}s ago, skipping.`);
|
|
102
101
|
return;
|
package/src/workers/collector.js
CHANGED
|
@@ -71,7 +71,7 @@ async function checkProxy(socksOrHttpProxy) {
|
|
|
71
71
|
return false;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const maxTimeAllowed = config.scraper.timeoutMax; //in seconds, lower for less proxies but higher quality
|
|
74
|
+
const maxTimeAllowed = config.scraper.timeoutMax || 15; //in seconds, lower for less proxies but higher quality
|
|
75
75
|
|
|
76
76
|
let method = config.scraper.method || "http"; // 'ws' or 'http'
|
|
77
77
|
const wsUrl = config.scraper.wsUrl || 'wss://shellshock.io/matchmaker/';
|