8000 [pull] main from jason5ng32:main by pull[bot] · Pull Request #29 · comanche2008/MyIP · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
2401889
Improvements
jason5ng32 Jul 30, 2026
7bfb071
Improvements
jason5ng32 Aug 1, 2026
e09bae2
Improvements
jason5ng32 Aug 1, 2026
049f7ba
Improvements
jason5ng32 Aug 1, 2026
837a756
Fix(api): handle stream errors in google-map passthrough
jason5ng32 Aug 6, 2026
db58393
Fix(ui): retry screenshot capture without webfonts on SecurityError
jason5ng32 Aug 6, 2026
3edf426
Refactor(prefs): drop legacy preference migration
jason5ng32 Aug 6, 2026
ae0eaee
Chore(deps): bump dependencies
jason5ng32 Aug 6, 2026
e20d8ad
Chore(ui): sync shadcn-vue tabs primitives with upstream
jason5ng32 Aug 6, 2026
fe3883f
Feat(connectivity): importable curated target lists
jason5ng32 Aug 6, 2026
cebef7e
Improvements
jason5ng32 Aug 6, 2026
c8ad469
Improvements
jason5ng32 Aug 6, 2026
153457d
Improvements
jason5ng32 Aug 6, 2026
a88d6e1
Improvements
jason5ng32 Aug 6, 2026
df36a97
Improvements
jason5ng32 Aug 6, 2026
87b085f
Improvements
jason5ng32 Aug 6, 2026
66f0534
Improvements
jason5ng32 Aug 7, 2026
2f924b3
Improvements
jason5ng32 Aug 9, 2026
89d5452
Improvements
jason5ng32 Aug 9, 2026
a56eb6c
Improvements
jason5ng32 Aug 9, 2026
23c0bde
feat: earth online
jason5ng32 Aug 9, 2026
6a886f6
Improvements
jason5ng32 Aug 9, 2026
93a4b1a
Improvements
jason5ng32 Aug 9, 2026
f172810
Change word map dependent
jason5ng32 Aug 9, 2026
94a465b
Improvements
jason5ng32 Aug 9, 2026
2ac70b4
Improvements
jason5ng32 Aug 9, 2026
19d21c7
Improvements
jason5ng32 Aug 9, 2026
3c7191f
Improvements
jason5ng32 Aug 9, 2026
ed650d6
Improvements
jason5ng32 Aug 9, 2026
60e544e
Improvements
jason5ng32 Aug 9, 2026
1da3d45
Improvements
jason5ng32 Aug 9, 2026
0281d4d
Feat(achievements): six new unlockable badges
jason5ng32 Aug 10, 2026
f490b71
Fix(achievements): hold rule evaluation until the remote snapshot lands
jason5ng32 Aug 10, 2026
bdf3384
Feat(pulse): limited-time festival statuses
jason5ng32 Aug 10, 2026
e73f8bb
Improvements
jason5ng32 Aug 10, 2026
e56eb3e
Feat(pulse): celebration animations on status sends
jason5ng32 Aug 10, 2026
ae1ca8a
Feat(pulse): global internet outage broadcast
jason5ng32 Aug 11, 2026
2195c46
Style(pulse): outage status reads as recovery
jason5ng32 Aug 11, 2026
5b9ad89
Refactor(pulse): share relative-time formatting
jason5ng32 Aug 11, 2026
686cade
Improvements
jason5ng32 Aug 11, 2026
c25fc5d
Improvements
jason5ng32 Aug 11, 2026
974ac3a
Fix(whois): short-circuit non-public IPs, split expected 4xx from fai…
jason5ng32 Aug 11, 2026
d405ac1
Refactor(valid-ip): frame the check as isUsablePublicIP, close IPv6 gaps
jason5ng32 Aug 11, 2026
f0a424e
Feat(ip-forms): reject unreachable targets before any request goes out
jason5ng32 Aug 11, 2026
6c679b2
Feat(guards): require a publicly routable IP on every ?ip= route
jason5ng32 Aug 11, 2026
83bdd54
Feat(ip-infos): show each IP's time zone, derived from its own coordi…
jason5ng32 Aug 12, 2026
95ed958
Improvements
jason5ng32 Aug 12, 2026
93fd71d
Improvements
jason5ng32 Aug 12, 2026
dbf62d5
Fix(dnsleaks): validate resolved IPs before the MaxMind lookup
jason5ng32 Aug 12, 2026
445d306
Refactor(getips): centralize IP validation and fallback in a chain ru…
jason5ng32 Aug 12, 2026
2fc511c
Improvements
jason5ng32 Aug 12, 2026
6e18ba2
Improvements
jason5ng32 Aug 13, 2026
73e2ca0
Improvements
jason5ng32 Aug 14, 2026
4c41f2a
Improvements
jason5ng32 Aug 14, 2026
79f8b6c
Improvements
jason5ng32 Aug 14, 2026
3edb781
Improvements
jason5ng32 Aug 14, 2026
bd2d9b3
Improvements
jason5ng32 Aug 14, 2026
3cd76db
Improvements
jason5ng32 Aug 14, 2026
e01c77d
Merge pull request #366 from jason5ng32/dev
jason5ng32 Aug 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ VITE_SITE_URL="https://ipcheck.ing"
# DOCS SITE — origin of the GitBook docs site powering the in-app
# assistant and the Help Center link. Empty disables both.
VITE_DOCS_URL=""
# EARTH ONLINE — full URL of the pulse backend (trailing slashes stripped).
# Empty disables the feature entirely (build-time, like Sentry).
VITE_PULSE_URL=""
# CURL API
VITE_CURL_IPV4_DOMAIN=""
VITE_CURL_IPV6_DOMAIN=""
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ halves: a Vue 3 SPA front-end and an Express 5 back-end API.
| Error monitoring | Sentry — optional & env-gated on both halves: `@sentry/vue` (no `VITE_SENTRY_DSN_FRONTEND`, no Sentry in the build — see frontend/AGENTS.md) + `@sentry/node` (no `SENTRY_DSN_BACKEND`, never loaded — see api/AGENTS.md) |
| PWA | `manifest.webmanifest` only — installable but online-only, no service worker |
| Tests | Node built-in test runner (`node --test`) |
| Runtime libs | chart.js · svgmap · @cloudflare/speedtest · maxmind · whoiser · thumbmarkjs · ua-parser-js · detect-gpu · @vueuse/core |
| Runtime libs | chart.js · chartjs-chart-geo · @cloudflare/speedtest · maxmind · whoiser · thumbmarkjs · ua-parser-js · detect-gpu · @vueuse/core |

## Commands

Expand Down Expand Up @@ -115,7 +115,7 @@ use npm / yarn — they'd produce a competing lockfile.
Access control and timeouts live in shared middleware, not handlers
(details in @api/AGENTS.md):

- `requireReferer` is global on `/api/*`; `requireValidIP()` per-route —
- `requireReferer` is global on `/api/*`; `requirePublicIP()` per-route —
handlers never repeat these checks.
- Every upstream HTTP call goes through `fetchUpstream`
(`common/fetch-with-timeout.js`, 8s timeout). Never a bare `fetch()` in `api/`.
Expand Down
41 changes: 32 additions & 9 deletions api/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ services, service-status poller), parts of which the frontend also imports
Roughly one handler file per route: IP-geolocation sources (`ipinfo-io` /
`ipapi-com` / `ipapi-is` / `ip2location-io` / `ip-sb` / `ipcheck-ing` /
`maxmind`), tool backends (`get-whois` / `dns-resolver` / `mac-checker` /
`cf-radar` / `asn-history` / `asn-connectivity` / `ooni-blocking` /
`globalping-probes` / `service-status` / `google-map` / `github-stars` /
`invisibility-test` / `dns-leak-test`), user
`cf-radar` / `net-outages` / `asn-history` / `asn-connectivity` /
`ooni-blocking` / `globalping-probes` / `service-status` / `google-map` /
`github-stars` / `invisibility-test` / `dns-leak-test`), user
proxies (`get-user-info` / `update-user-achievement`), platform
(`configs` / `sentry-tunnel` / `share-report`). Each file's header comment
states its route and purpose — read those for specifics.
Expand All @@ -37,7 +37,8 @@ states its route and purpose — read those for specifics.
these verbatim.
- **Response shape.** IP-geolocation handlers normalize to the canonical
frontend shape (`ip` / `country_code` / `latitude` / `asn` / `org` / …);
new sources match it.
new sources match it. `timezone` is the exception — no handler produces it;
see "Response enrichment" below.
- **Logging.** Shared logger only, `logger.error({ err, ...ctx }, 'msg')`;
no `console.*`, no "received request" lines (`pino-http` covers those when
enabled).
Expand All @@ -63,7 +64,11 @@ states its route and purpose — read those for specifics.
these checks:

- `requireReferer` — global on `/api/*` (ALLOWED_DOMAINS + localhost).
- `requireValidIP()` — per-route for `?ip=`; handler sees a well-formed IP.
- `requirePublicIP()` — per-route for `?ip=`; handler sees a well-formed,
publicly routable IP. Reserved space (RFC 1918, loopback, CGNAT, link-local,
documentation, …) is rejected here, so no geo source is ever asked about an
address it can't answer for — `isUsablePublicIP` in `common/valid-ip.js` is
the single definition, shared with the front-end IP forms.
- `requireValidDomain()` — `?domain=`, lowercases in place so the edge cache
sees one canonical key.
- `requireValidPrefix()` — `?prefix=` (CIDR); lets the frontend quantize to
Expand All @@ -76,6 +81,22 @@ these checks:
New param shape → new guard in `common/guards.js`, attached in
`backend-server.js`; never open-coded in the handler.

### Response enrichment lives in middleware too

`withTimeZone()` (`common/ip-timezone.js`), attached to all seven geo routes,
derives `timezone` (IANA name) from the `latitude` / `longitude` the handler
just returned and adds it on the way out — 2xx only, same res.json hook and
same rule as `cacheable`. No handler computes or forwards a timezone, not even
the private-API pass-throughs.

Deriving it from the response's own coordinates is what keeps the zone from
contradicting the city beside it; a second database asked about the same IP
would eventually disagree. Only the zone name ships — the frontend renders the
UTC offset from it, because these routes sit behind a 24h edge cache and a
cached offset goes an hour wrong at every DST switch.

A new geo source inherits the field by adding the middleware to its route.

### Private-API header pass-through (intentional exception)

Handlers proxying our private IPCheck.ing API (`ipcheck-ing`,
Expand Down Expand Up @@ -104,10 +125,12 @@ to the upstream that owns the auth context.

## Testing

- Every handler has smoke tests in `tests/api-handlers.test.js`: method
gating, param branches, "API key missing" early returns.
- Never hit real upstreams — assert only on branches that return before the
first `fetchUpstream`.
- Handlers get smoke tests in `tests/api-handlers.test.js`: method gating,
param branches, "API key missing" early returns. Most are covered; a new
or touched handler ships its block in the same change.
- Never hit real upstreams — assert on branches that return before the first
`fetchUpstream`, or stub `globalThis.fetch` when the behavior under test
lives past it (google-map stream tests; restored in the shared `afterEach`).
- Middleware is covered by `tests/guards.test.js`; don't duplicate its
assertions per-handler. Fetch timeout/abort behavior:
`tests/fetch-with-timeout.test.js`.
8 changes: 7 additions & 1 deletion api/get-whois.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import whoiser from 'whoiser';
import { isValidIP } from '../common/valid-ip.js';
import { isValidIP, isUsablePublicIP } from '../common/valid-ip.js';
import { rdapDomain, rdapIp } from '../common/rdap.js';
import logger from '../common/logger.js';

Expand Down Expand Up @@ -29,6 +29,12 @@ export default async (req, res) => {
if (!isValidIP(query) && !isValidDomain(query)) {
return res.status(400).json({ error: 'Invalid IP or address' });
}
// Only publicly routable addresses have a registry record — asking RDAP
// or WHOIS about anything else burns an upstream call to earn a
// guaranteed failure. Visitors paste their LAN address routinely.
if (isValidIP(query) && !isUsablePublicIP(query)) {
return res.status(400).json({ error: 'Not a public IP address' });
}

// IP path: RDAP first — authoritative-RIR HTTPS + JSON, immune to the
// port-43 referral mess (rwhois://host:port referrals point at a
Expand Down
15 changes: 11 additions & 4 deletions api/google-map.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Readable } from 'node:stream';
import { pipeline } from 'node:stream/promises';
import { fetchUpstream } from '../common/fetch-with-timeout.js';
import logger from '../common/logger.js';

Expand Down Expand Up @@ -71,8 +72,9 @@ export default async (req, res) => {
const url = `https://maps.googleapis.com/maps/api/staticmap?center=${latitude},${longitude}&markers=color:blue%7C${latitude},${longitude}&scale=${scale}&zoom=${zoom}&maptype=roadmap&language=${language}&format=${fmt}&size=${mapSize}&style=${styleParam}&key=${apiKey}`;

// Unlike the JSON handlers, the Static Maps response is a binary JPEG
// and must be passed through to the client. Convert the WHATWG ReadableStream
// from fetch into a Node Readable and pipe it at the Express response.
// and must be passed through to the client. pipeline() propagates errors
// both ways: an upstream reset destroys the response, a client
// disconnect cancels the upstream body.
try {
const apiRes = await fetchUpstream(url);
if (!apiRes.ok) {
Expand All @@ -84,9 +86,14 @@ export default async (req, res) => {
if (res.locals.cacheControl) {
res.setHeader('Cache-Control', res.locals.cacheControl);
}
Readable.fromWeb(apiRes.body).pipe(res);
await pipeline(Readable.fromWeb(apiRes.body), res);
} catch (e) {
// Visitors abandoning a half-loaded image are routine, not a failure.
if (e?.code === 'ERR_STREAM_PREMATURE_CLOSE') return;
logger.error({ err: e, latitude, longitude, language, CanvasMode }, 'google-map handler failed');
res.status(500).json({ error: e.message });
if (!res.headersSent && !res.destroyed) {
return res.status(500).json({ error: e.message });
}
if (!res.destroyed) res.destroy();
}
};
11 changes: 11 additions & 0 deletions api/invisibility-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ export default async (req, res) => {
return res.json({ status: 'pending' });
}

// Upstream 401/403. Pass the status through so the frontend prompts
// sign-in instead of retrying; keep it off the error logger.
if (apiResponse.status === 401 || apiResponse.status === 403) {
let detail = 'Sign in required';
try {
const errorData = await apiResponse.json();
detail = errorData.message || detail;
} catch { /* unreadable body — keep the generic detail */ }
return res.status(apiResponse.status).json({ error: detail });
}

// Catch upstream error
if (!apiResponse.ok) {
let errorDetail = '';
Expand Down
3 changes: 2 additions & 1 deletion api/ipcheck-ing.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { fetchUpstream } from '../common/fetch-with-timeout.js';
import logger from '../common/logger.js';

export default async (req, res) => {
// IP presence + validity guaranteed by requireValidIP middleware.
// Presence, validity and public routability guaranteed by the
// requirePublicIP middleware — a reserved address never reaches here.
const ipAddress = req.query.ip;

const key = process.env.IPCHECKING_API_KEY;
Expand Down
3 changes: 2 additions & 1 deletion api/maxmind.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import logger from '../common/logger.js';
import { pickLang } from '../common/langs.js';

export default (req, res) => {
// IP presence + validity guaranteed by requireValidIP middleware.
// Presence, validity and public routability guaranteed by the
// requirePublicIP middleware — a reserved address never reaches here.
const ip = req.query.ip;

// Get request language
Expand Down
119 changes: 119 additions & 0 deletions api/net-outages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Handler for /api/outages — global internet outage feed for the Pulse panel.
// Merges two Cloudflare Radar sources into one recent-events list:
// - /radar/annotations/outages (manually verified outages, with a cause)
// - /radar/traffic_anomalies (auto-detected drops, all statuses)
// A verified anomaly is often promoted to an outage entry for the same event,
// so anomalies that match an outage's subject and start time are dropped.
import { fetchUpstream } from '../common/fetch-with-timeout.js';
import logger from '../common/logger.js';

const DATE_RANGE = '30d';
const MAX_EVENTS = 30;
// An anomaly counts as a duplicate of an outage when they share a subject
// (location or ASN) and start within this window of each other.
const DEDUPE_WINDOW_MS = 24 * 60 * 60 * 1000;

const fetchFromRadar = async (endpoint) => {
const url = `https://api.cloudflare.com/client/v4${endpoint}`;
const response = await fetchUpstream(url, {
headers: {
'Authorization': `Bearer ${process.env.CLOUDFLARE_API_KEY || process.env.CLOUDFLARE_API}`,
'Content-Type': 'application/json',
},
});
if (!response.ok) {
throw new Error(`Cloudflare Radar responded ${response.status}`);
}
return response.json();
};

// Both kinds normalize to one flat shape; anomaly-only fields stay null on
// outages and vice versa. `endDate: null` means the event is still ongoing.
export const normalizeOutages = (annotations) => annotations.map((entry) => ({
kind: 'outage',
id: `o-${entry.id}`,
startDate: entry.startDate,
endDate: entry.endDate || null,
locations: (entry.locationsDetails || []).map((loc) => loc.code),
asns: (entry.asnsDetails || []).map((detail) => ({ asn: Number(detail.asn), name: detail.name })),
cause: entry.outage?.outageCause || 'UNKNOWN',
level: entry.outage?.outageType || null,
description: entry.description || null,
scope: entry.scope || null,
linkedUrl: entry.linkedUrl || null,
}));

// Anomaly statuses hidden from the feed. Live data carries values beyond the
// documented VERIFIED/UNVERIFIED pair (e.g. TP = third-party confirmed), so
// this is a blocklist, not an allowlist. Empty today — every status ships;
// add 'UNVERIFIED' here to restrict the feed to confirmed events only.
const EXCLUDED_ANOMALY_STATUSES = new Set([]);

export const normalizeAnomalies = (anomalies) => anomalies
.filter((entry) => !EXCLUDED_ANOMALY_STATUSES.has(entry.status))
.map((entry) => ({
kind: 'anomaly',
id: `a-${entry.uuid}`,
startDate: entry.startDate,
endDate: entry.endDate || null,
locations: entry.locationDetails?.code ? [entry.locationDetails.code] : [],
asns: entry.asnDetails?.asn
? [{ asn: Number(entry.asnDetails.asn), name: entry.asnDetails.name }]
: [],
cause: null,
level: null,
description: null,
scope: null,
linkedUrl: null,
}));

export const mergeEvents = (outages, anomalies) => {
const isDuplicate = (anomaly) => outages.some((outage) => {
const sharesSubject = anomaly.locations.some((code) => outage.locations.includes(code))
|| anomaly.asns.some((a) => outage.asns.some((o) => o.asn === a.asn));
if (!sharesSubject) return false;
return Math.abs(Date.parse(anomaly.startDate) - Date.parse(outage.startDate)) <= DEDUPE_WINDOW_MS;
});
// Two-level order, consumed by the frontend as-is: ongoing events first
// (endDate null), ended ones after, newest-first inside each group. The
// cap then favors ongoing events by construction.
return [...outages, ...anomalies.filter((anomaly) => !isDuplicate(anomaly))]
.sort((a, b) => {
const aOngoing = a.endDate === null;
const bOngoing = b.endDate === null;
if (aOngoing !== bOngoing) return aOngoing ? -1 : 1;
return Date.parse(b.startDate) - Date.parse(a.startDate);
})
.slice(0, MAX_EVENTS);
};

export default async (req, res) => {
if (req.method !== 'GET') {
return res.status(405).json({ error: 'Method Not Allowed' });
}
if (!process.env.CLOUDFLARE_API_KEY && !process.env.CLOUDFLARE_API) {
return res.status(500).json({ error: 'API key is missing' });
}

// One failed source degrades to a partial feed; both failing is an error.
const [outagesResult, anomaliesResult] = await Promise.allSettled([
fetchFromRadar(`/radar/annotations/outages?dateRange=${DATE_RANGE}&limit=50`),
fetchFromRadar(`/radar/traffic_anomalies?dateRange=${DATE_RANGE}&limit=100`),
]);

if (outagesResult.status === 'rejected' && anomaliesResult.status === 'rejected') {
logger.error({ err: outagesResult.reason }, 'net-outages: both Radar sources failed');
return res.status(500).json({ error: 'Internal server error' });
}
if (outagesResult.status === 'rejected' || anomaliesResult.status === 'rejected') {
const failed = outagesResult.status === 'rejected' ? outagesResult : anomaliesResult;
logger.warn({ err: failed.reason }, 'net-outages: one Radar source failed');
}

const outages = normalizeOutages(
outagesResult.status === 'fulfilled' ? outagesResult.value?.result?.annotations || [] : []);
const anomalies = normalizeAnomalies(
anomaliesResult.status === 'fulfilled' ? anomaliesResult.value?.result?.trafficAnomalies || [] : []);

res.json({ events: mergeEvents(outages, anomalies) });
};
20 changes: 12 additions & 8 deletions backend-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { slowDown } from 'express-slow-down'
import rateLimit from 'express-rate-limit';
import pinoHttp from 'pino-http';
import logger from './common/logger.js';
import { requireReferer, requireValidIP, requireValidPrefix, requireValidASN, requireValidDomain, requireValidProviderId, requireValidReportId } from './common/guards.js';
import { requireReferer, requirePublicIP, requireValidPrefix, requireValidASN, requireValidDomain, requireValidProviderId, requireValidReportId } from './common/guards.js';
import { withTimeZone } from './common/ip-timezone.js';

// Backend APIs
import mapHandler from './api/google-map.js';
Expand All @@ -21,6 +22,7 @@ import ipsbHandler from './api/ip-sb.js';
import maxmindHandler from './api/maxmind.js';
// Others
import cfHander from './api/cf-radar.js';
import netOutagesHandler from './api/net-outages.js';
import asnHistoryHandler from './api/asn-history.js';
import asnConnectivityHandler from './api/asn-connectivity.js';
import ooniBlockingHandler from './api/ooni-blocking.js';
Expand Down Expand Up @@ -240,17 +242,19 @@ const ONE_YEAR_CACHE = 365 * 24 * 60 * 60;
app.get('/api/service-status', cacheable(FIVE_MIN_CACHE), serviceStatusHandler);
app.get('/api/service-status/detail', requireValidProviderId(), cacheable(FIVE_MIN_CACHE), serviceStatusDetailHandler);
// Cache for 1 day
app.get('/api/ipinfo', requireValidIP(), cacheable(ONE_DAY_CACHE), ipinfoHandler);
app.get('/api/ipapicom', requireValidIP(), cacheable(ONE_DAY_CACHE), ipapicomHandler);
app.get('/api/ipsb', requireValidIP(), cacheable(ONE_DAY_CACHE), ipsbHandler);
app.get('/api/ipapiis', requireValidIP(), cacheable(ONE_DAY_CACHE), ipapiisHandler);
app.get('/api/ip2location', requireValidIP(), cacheable(ONE_DAY_CACHE), ip2locationHandler);
app.get('/api/maxmind', requireValidIP(), cacheable(ONE_DAY_CACHE), maxmindHandler);
app.get('/api/ipinfo', requirePublicIP(), withTimeZone(), cacheable(ONE_DAY_CACHE), ipinfoHandler);
app.get('/api/ipapicom', requirePublicIP(), withTimeZone(), cacheable(ONE_DAY_CACHE), ipapicomHandler);
app.get('/api/ipsb', requirePublicIP(), withTimeZone(), cacheable(ONE_DAY_CACHE), ipsbHandler);
app.get('/api/ipapiis', requirePublicIP(), withTimeZone(), cacheable(ONE_DAY_CACHE), ipapiisHandler);
app.get('/api/ip2location', requirePublicIP(), withTimeZone(), cacheable(ONE_DAY_CACHE), ip2locationHandler);
app.get('/api/maxmind', requirePublicIP(), withTimeZone(), cacheable(ONE_DAY_CACHE), maxmindHandler);
app.get('/api/whois', cacheable(ONE_DAY_CACHE), getWhois);
app.get('/api/github-stars', cacheable(ONE_DAY_CACHE), githubStarsHandler);
// Feature flags derived from env vars — they only change on a redeploy, so
// an hour of caching is safe.
app.get('/api/configs', cacheable(ONE_HOUR_CACHE), validateConfigs);
// Radar's outage feed moves on an hourly-ish cadence
app.get('/api/outages', cacheable(ONE_HOUR_CACHE), netOutagesHandler);
// OONI aggregates cover a 30-day window aligned to UTC days — the payload
// only drifts as new measurements land, so 1 day of edge cache keeps us polite
// to OONI's free API without the view going meaningfully stale.
Expand All @@ -268,7 +272,7 @@ app.get('/api/macchecker', cacheable(THIRTY_DAYS_CACHE), macChecker);
// Long Cache
app.get('/api/map', cacheable(ONE_YEAR_CACHE), mapHandler);
// Non-cacheable routes — auth-context, debug tools, or per-request lookups.
app.get('/api/ipchecking', requireValidIP(), ipCheckingHandler);
app.get('/api/ipchecking', requirePublicIP(), withTimeZone(), ipCheckingHandler);
app.get('/api/dnsresolver', dnsResolver);
app.get('/api/dnsleaktest/session/:token', dnsLeakGetResult);
app.get('/api/invisibility', invisibilitytestHandler);
Expand Down
3 changes: 2 additions & 1 deletion common/geo-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import logger from './logger.js';

export function makeGeoHandler({ name, buildUrl, normalize }) {
return async (req, res) => {
// IP presence + validity guaranteed by requireValidIP middleware.
// Presence, validity and public routability guaranteed by the
// requirePublicIP middleware — a reserved address never reaches here.
const ipAddress = req.query.ip;

const built = buildUrl(req);
Expand Down
Loading
Loading
0