From 27b3073907844e121d30cc989610445fd46b4b69 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Wed, 8 Oct 2025 00:34:24 +0300 Subject: [PATCH] feat: enhance GeoIP service to include ASN information in detailed responses --- src/backend/services/geoip.ts | 3 +++ src/backend/types/index.ts | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/backend/services/geoip.ts b/src/backend/services/geoip.ts index 79f3722..3197987 100644 --- a/src/backend/services/geoip.ts +++ b/src/backend/services/geoip.ts @@ -111,9 +111,12 @@ class GeoIPService { try { const response: City = this.cityReader!.city(ip); + const asnResponse: Asn = this.asnReader!.asn(ip); + const result: DetailedGeoIPResponse = { ip, location: response as GeoIPLocation, + asn: asnResponse, }; this.cache.set(cacheKey, result); diff --git a/src/backend/types/index.ts b/src/backend/types/index.ts index cadf631..42012df 100644 --- a/src/backend/types/index.ts +++ b/src/backend/types/index.ts @@ -37,6 +37,13 @@ export interface GeoIPLocation { }; } +export interface AsnInfo { + autonomousSystemNumber?: number; + autonomousSystemOrganization?: string; + ipAddress?: string; + network?: string; +} + export interface SimplifiedGeoIPResponse { ip: string; country: string; @@ -58,6 +65,7 @@ export interface SimplifiedGeoIPResponse { export interface DetailedGeoIPResponse { ip: string; location: GeoIPLocation; + asn: AsnInfo; } export interface BatchGeoIPRequest {