fix(geo): распознать CDN-локации и добавить иконки сервисов
Docker / build (push) Failing after 22s

CDN-значения вида SE (ARN) больше не помечаются как ошибка. У каждого GeoIP-сервиса — бренд-иконка, как в разделе блокировок.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Denozordec
2026-08-25 15:54:04 +07:00
co-authored by Cursor
parent 235ae03489
commit 7480b9dc11
10 changed files with 328 additions and 30 deletions
@@ -7,8 +7,26 @@ import { normalizeIngestResult, summarizeResults } from './normalize.js'
describe('canonicalizeCountryValue', () => {
it('мапит ISO в ok', () => {
expect(canonicalizeCountryValue('RU')).toEqual({ status: 'ok', country: 'RU' })
expect(canonicalizeCountryValue(' de ')).toEqual({ status: 'ok', country: 'DE' })
expect(canonicalizeCountryValue('RU')).toEqual({ status: 'ok', country: 'RU', iata: null })
expect(canonicalizeCountryValue(' de ')).toEqual({ status: 'ok', country: 'DE', iata: null })
})
it('мапит CDN ISO + IATA', () => {
expect(canonicalizeCountryValue('SE (ARN)')).toEqual({
status: 'ok',
country: 'SE',
iata: 'ARN',
})
expect(canonicalizeCountryValue('RS (BEG)')).toEqual({
status: 'ok',
country: 'RS',
iata: 'BEG',
})
expect(canonicalizeCountryValue('(ARN)')).toEqual({
status: 'ok',
country: null,
iata: 'ARN',
})
})
it('мапит статусы ipregion', () => {
@@ -46,6 +64,31 @@ describe('ipregion normalize', () => {
expect(row.group).toBe('cdn')
})
it('сохраняет CDN ISO + IATA и N/A', () => {
const cf = normalizeIngestResult({
service: 'Cloudflare CDN',
group: 'cdn',
ipv4: 'SE (ARN)',
})
expect(cf.status).toBe('ok')
expect(cf.countryIpv4).toBe('SE (ARN)')
expect(cf.group).toBe('cdn')
const yt = normalizeIngestResult({
service: 'YouTube CDN',
ipv4: 'RS (BEG)',
})
expect(yt.status).toBe('ok')
expect(yt.countryIpv4).toBe('RS (BEG)')
const nflx = normalizeIngestResult({
service: 'Netflix CDN',
ipv4: 'N/A',
})
expect(nflx.status).toBe('na')
expect(nflx.countryIpv4).toBeNull()
})
it('считает summary и partial', () => {
const { summary, runStatus } = summarizeResults([
{ status: 'ok' },
+3 -2
View File
@@ -1,6 +1,7 @@
import {
canonicalizeCountryValue,
emptyIpregionSummary,
formatCanonicalCountry,
inferIpregionGroup,
type IpregionGroup,
type IpregionIngestResult,
@@ -29,8 +30,8 @@ export function normalizeIngestResult(item: IpregionIngestResult): NormalizedIpr
serviceKey,
serviceLabel,
group: item.group ?? inferIpregionGroup(serviceKey),
countryIpv4: ipv4.country,
countryIpv6: ipv6.country,
countryIpv4: formatCanonicalCountry(ipv4),
countryIpv6: formatCanonicalCountry(ipv6),
status,
}
}