mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-11 13:52:19 +00:00
CCTV Street View fallback: own per-IP Google budget inside the cctv package boundary
This commit is contained in:
1 parent
7af0453f34
commit
078a6c0db0
3 files changed
+23
-6
No files matched your search
@@ -377,7 +377,9 @@
|
|||||||
"src/data/cctvFootprint.js",
|
"src/data/cctvFootprint.js",
|
||||||
"src/sources/cctvTypes.js",
|
"src/sources/cctvTypes.js",
|
||||||
"src/sources/httpBody.js",
|
"src/sources/httpBody.js",
|
||||||
"src/i18n/marker.js"
|
"src/i18n/marker.js",
|
||||||
|
"server/providers/common/rate-limit.js",
|
||||||
|
"src/sources/rateLimit.js"
|
||||||
],
|
],
|
||||||
"external": []
|
"external": []
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -19,9 +19,22 @@ import { admitSameSiteKeyless } from './common/same-site.js';
|
|||||||
import { PROXY_SIGNALS } from '../../src/localRequestGate.mjs';
|
import { PROXY_SIGNALS } from '../../src/localRequestGate.mjs';
|
||||||
import { createHlsPuller } from './cctv/stream.js';
|
import { createHlsPuller } from './cctv/stream.js';
|
||||||
import { googleServerApiKey } from './places/google-key.js';
|
import { googleServerApiKey } from './places/google-key.js';
|
||||||
import { googleRateLimiter } from './places/google.js';
|
import { clientKey, makeCostRateLimiter } from './common/rate-limit.js';
|
||||||
import { clientKey } from './common/rate-limit.js';
|
|
||||||
export { CCTV_FRAME_FETCH_TIMEOUT_MS, fetchCctvImageFromUpstream };
|
export { CCTV_FRAME_FETCH_TIMEOUT_MS, fetchCctvImageFromUpstream };
|
||||||
|
let _streetViewRateLimiter;
|
||||||
|
/**
|
||||||
|
* Per-IP budget for the Street View fallback, on the same setting as the
|
||||||
|
* other Google routes (GEV_RATELIMIT_GOOGLE_PER_MIN; 0 disables it).
|
||||||
|
*/
|
||||||
|
function streetViewRateLimiter() {
|
||||||
|
if (_streetViewRateLimiter === undefined)
|
||||||
|
_streetViewRateLimiter = makeCostRateLimiter(
|
||||||
|
process.env.GEV_RATELIMIT_GOOGLE_PER_MIN,
|
||||||
|
120,
|
||||||
|
);
|
||||||
|
return _streetViewRateLimiter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vite plugin: CCTV camera proxy with source registry, frame/media serving,
|
* Vite plugin: CCTV camera proxy with source registry, frame/media serving,
|
||||||
* fallback chain (upstream -> Street View -> synthetic SVG), and health tracking.
|
* fallback chain (upstream -> Street View -> synthetic SVG), and health tracking.
|
||||||
@@ -549,7 +562,9 @@ export function cctvProxy({ sourceRoot = process.cwd() } = {}) {
|
|||||||
const forwarded = PROXY_SIGNALS.some(
|
const forwarded = PROXY_SIGNALS.some(
|
||||||
(name) => req.headers?.[name] !== undefined,
|
(name) => req.headers?.[name] !== undefined,
|
||||||
);
|
);
|
||||||
const googleBudget = googleServerApiKey() ? googleRateLimiter() : null;
|
const googleBudget = googleServerApiKey()
|
||||||
|
? streetViewRateLimiter()
|
||||||
|
: null;
|
||||||
const sv =
|
const sv =
|
||||||
forwarded ||
|
forwarded ||
|
||||||
!source ||
|
!source ||
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ let _googleRateLimiter;
|
|||||||
*/
|
*/
|
||||||
export const GOOGLE_DEFAULT_PER_MIN = 120;
|
export const GOOGLE_DEFAULT_PER_MIN = 120;
|
||||||
|
|
||||||
/** Google cost endpoints (nearby-places, text-search, geocoding, the CCTV Street View fallback). Null only when set to 0. */
|
/** Google cost endpoints (nearby-places, text-search, geocoding). Null only when set to 0. */
|
||||||
export function googleRateLimiter() {
|
function googleRateLimiter() {
|
||||||
if (_googleRateLimiter === undefined)
|
if (_googleRateLimiter === undefined)
|
||||||
_googleRateLimiter = makeCostRateLimiter(
|
_googleRateLimiter = makeCostRateLimiter(
|
||||||
process.env.GEV_RATELIMIT_GOOGLE_PER_MIN,
|
process.env.GEV_RATELIMIT_GOOGLE_PER_MIN,
|
||||||
|
|||||||
Reference in new issue
Block a user