Skip to content

Commit d5cd0f3

Browse files
committed
feat(external): real-time IP/ASN enrichment service (replaces bgptools)
Replace the bgp.tools WHOIS helper module with a richer ip_enrichment service that exposes the same network_info / network_info_sync API plus on-demand helpers (lookup_ip, lookup_asn_name, lookup_asn_country, lookup_asns_bulk) used for ASN organization, country and IXP enrichment. Update the webhook task and external package exports to the new module. Stacked series (6/10): builds on pr/bgp-filtered-flag.
1 parent c4e2089 commit d5cd0f3

6 files changed

Lines changed: 671 additions & 231 deletions

File tree

docs/pages/configuration/config/structured-output.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,9 @@ structured:
8989
"65000:100": "Customer Route"
9090
"65000:200": "Peer Route"
9191
```
92+
93+
## IP Enrichment
94+
95+
hyperglass can enrich structured responses with ASN, organization, country, and IXP metadata resolved in real time from [bgp.tools](https://bgp.tools/). This data powers the organization names shown on AS paths and next-hops, and the per-hop detail in structured traceroute.
96+
97+
Enrichment is performed by an internal service that issues bulk WHOIS lookups to bgp.tools; results are cached in-memory for the life of the process. No configuration is required to make the service available — it is enabled per-feature via the [`structured.ip_enrichment`](#ip-enrichment-configuration) settings documented below.

hyperglass/api/tasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# Project
1212
from hyperglass.log import log
13-
from hyperglass.external import Webhook, bgptools
13+
from hyperglass.external import Webhook, network_info
1414
from hyperglass.models.api import Query
1515

1616
if t.TYPE_CHECKING:
@@ -52,15 +52,15 @@ async def send_webhook(
5252
else:
5353
host = request.client.host
5454

55-
network_info = await bgptools.network_info(host)
55+
network_result = await network_info(host)
5656

5757
async with Webhook(params.logging.http) as hook:
5858
await hook.send(
5959
query={
6060
**data.dict(),
6161
"headers": headers,
6262
"source": host,
63-
"network": network_info.get(host, {}),
63+
"network": network_result.get(host, {}),
6464
"timestamp": timestamp,
6565
}
6666
)

hyperglass/external/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
from .slack import SlackHook
66
from .generic import BaseExternal
77
from .msteams import MSTeams
8-
from .bgptools import network_info, network_info_sync
8+
from .ip_enrichment import (
9+
network_info,
10+
network_info_sync,
11+
lookup_ip,
12+
lookup_asn_name,
13+
lookup_asn_country,
14+
)
915
from .webhooks import Webhook
1016
from .http_client import HTTPClient
1117

hyperglass/external/bgptools.py

Lines changed: 0 additions & 178 deletions
This file was deleted.

0 commit comments

Comments
 (0)