make proxycheck hysteresis configurable

This commit is contained in:
HF 2022-09-05 23:03:36 +02:00
parent 3ba8df95f8
commit 9166adab13

View File

@ -8,6 +8,7 @@ import https from 'https';
import { HourlyCron } from './cron'; import { HourlyCron } from './cron';
const HYSTERESIS = 60;
/* /*
* class to serve proxyckec.io key * class to serve proxyckec.io key
@ -54,7 +55,7 @@ class PcKeyProvider {
const pos = Math.floor(Math.random() * keys.length); const pos = Math.floor(Math.random() * keys.length);
const keyData = keys[pos]; const keyData = keys[pos];
const availableQueries = keyData[1] - 1; const availableQueries = keyData[1] - 1;
if (availableQueries >= 30) { if (availableQueries >= HYSTERESIS) {
keyData[1] = availableQueries; keyData[1] = availableQueries;
return keyData[0]; return keyData[0];
} }
@ -145,9 +146,9 @@ class PcKeyProvider {
availableBurst, availableBurst,
false, false,
]; ];
if (burstActive || availableQueries > 30) { if (burstActive || availableQueries > HYSTERESIS) {
/* /*
* data is a few minutes old, stop at 30 * data is a few minutes old, stop at HYSTERESIS
*/ */
this.availableKeys.push(keyData); this.availableKeys.push(keyData);
} else { } else {