From c93fad12bc008279401b5b8c2ca6d2aeb6d8c6d5 Mon Sep 17 00:00:00 2001 From: HF Date: Sun, 21 Aug 2022 20:54:49 +0200 Subject: [PATCH] change isAllowedCache prefix fix proxycheck key update add small stuff to wins --- src/data/redis/isAllowedCache.js | 2 +- src/store/reducers/win.js | 1 + src/utils/ProxyCheck.js | 17 +++++++---------- src/win.js | 6 ++++++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/data/redis/isAllowedCache.js b/src/data/redis/isAllowedCache.js index ebb971a..a5378c3 100644 --- a/src/data/redis/isAllowedCache.js +++ b/src/data/redis/isAllowedCache.js @@ -5,7 +5,7 @@ import client from './client'; -const PREFIX = 'isal:'; +const PREFIX = 'isal'; const CACHE_DURATION = 14 * 24 * 3600; export function cacheAllowed(ip, status) { diff --git a/src/store/reducers/win.js b/src/store/reducers/win.js index 48473bf..5dc111f 100644 --- a/src/store/reducers/win.js +++ b/src/store/reducers/win.js @@ -7,6 +7,7 @@ const initialState = { windowType: 'SETTINGS', title: '', args: {}, + isPopup: window.opener && !window.opener.closed, }; export default function win( diff --git a/src/utils/ProxyCheck.js b/src/utils/ProxyCheck.js index 5e967f3..2284c6b 100644 --- a/src/utils/ProxyCheck.js +++ b/src/utils/ProxyCheck.js @@ -6,7 +6,6 @@ import https from 'https'; -import { HOUR } from '../core/constants'; import { HourlyCron } from './cron'; @@ -89,8 +88,9 @@ class PcKeyProvider { * @param keys Array of key strings */ async getKeysUsage(keys) { - for (let i = 0; i < keys.length; i += 1) { - let key = keys[i]; + const tmpKeys = [...keys]; + for (let i = 0; i < tmpKeys.length; i += 1) { + let key = tmpKeys[i]; if (typeof key !== 'string') { [key] = key; } @@ -196,13 +196,6 @@ class PcKeyProvider { }); } - /* - * wrapper to update keys - */ - updateKeys() { - this.pcKeyProvider.updateKeys(); - } - /* * report denied key (over daily quota, rate limited, blocked,...) * @param key @@ -327,6 +320,10 @@ class ProxyCheck { }); } + updateKeys() { + return this.pcKeyProvider.updateKeys(); + } + async checkFromQueue() { const { ipQueue } = this; if (!ipQueue.length) { diff --git a/src/win.js b/src/win.js index 72fbcc6..a39f456 100644 --- a/src/win.js +++ b/src/win.js @@ -15,4 +15,10 @@ document.addEventListener('DOMContentLoaded', () => { // eslint-disable-next-line no-console console.log('hello'); renderAppWin(document.getElementById('app'), store); + + /* + * check if popup or independent window + */ + if (!window.opener || window.opener.closed) { + } });