puppyproxy 1.1.6 → 1.1.8

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "puppyproxy",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "Node.js library for managing, scraping, and using proxies with fetch and WebSocket support",
5
5
  "type": "module",
6
6
  "types": "./src/index.d.ts",
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);
@@ -57,6 +57,9 @@ export class ProxyRequest {
57
57
  return response;
58
58
  } else {
59
59
  this.failure();
60
+ if (this.options.rejectedCodes && this.options.rejectedCodes.includes(response.status)) {
61
+ throw new Error(`exit`);
62
+ }
60
63
  throw new Error(`Failed to fetch ${url} status ${response.status}`);
61
64
  }
62
65
  } catch (error) {
@@ -74,6 +77,10 @@ export class ProxyRequest {
74
77
  if (attempt === retries - 1) {
75
78
  throw error;
76
79
  }
80
+ if (error.message === "exit") {
81
+ this.client.config.LOG?.error && log.error(id, `Exiting retries for ${url} due to exit signal`);
82
+ throw error;
83
+ }
77
84
  }
78
85
  }
79
86
  }
@@ -95,7 +95,7 @@ export default class Scraper {
95
95
  let lastSaved = (Date.now() - getLastSavedTimestamp(this.outputPath)) / 1000; // ms to seconds
96
96
  if (lastSaved && !force) {
97
97
  console.log("lastSaved", lastSaved);
98
- let timeBetweenScrapes = this.config.scraper.timeBetweenScrapes * 60; // mins to seconds
98
+ let timeBetweenScrapes = (this.config?.scraper?.timeBetweenScrapes || 10) * 60; // mins to seconds
99
99
  if (lastSaved < timeBetweenScrapes) {
100
100
  console.log(`Proxies saved < ${timeBetweenScrapes}s ago, skipping.`);
101
101
  return;
@@ -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/';