1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-01-29 13:29:20 +00:00
thatmattlove-hyperglass/hyperglass
Wilhelm Schonfeldt 4a1057651f
feat: comprehensive IP enrichment and traceroute improvements
MAJOR ENHANCEMENTS:

IP Enrichment Service (hyperglass/external/ip_enrichment.py):
- Increase IXP data cache duration from 24 hours to 7 days (604800s) for better performance
- Fix critical cache refresh logic: ensure_data_loaded() now properly checks expiry before using existing pickle files
- Remove 'force' refresh parameters from public APIs and admin endpoints to prevent potential abuse/DDOS
- Implement automatic refresh based on file timestamps and cache duration
- Add comprehensive debug logging gated by Settings.debug throughout the module
- Clean up verbose comments and improve code readability
- Update configuration model to enforce 7-day minimum cache timeout

MikroTik Traceroute Processing:
- Refactor trace_route_mikrotik plugin to use garbage cleaner before structured parsing
- Only log raw router output when Settings.debug is enabled to reduce log verbosity
- Simplify MikrotikTracerouteTable parser to expect pre-cleaned input from garbage cleaner
- Remove complex multi-table detection, format detection, and deduplication logic (handled by cleaner)
- Add concise debug messages for processing decisions and configuration states

Traceroute IP Enrichment (traceroute_ip_enrichment.py):
- Implement concurrent reverse DNS lookups using asyncio.to_thread and asyncio.gather
- Add async wrapper for reverse DNS with proper error handling and fallbacks
- Significant performance improvement for multi-hop traceroutes (parallel vs sequential DNS)
- Proper debug logging gates: only detailed logs when Settings.debug=True
- Upgrade operational messages to log.info level (start/completion status)
- Maintain compatibility with different event loop contexts and runtime environments

Configuration Updates:
- Update structured.ip_enrichment.cache_timeout default to 604800 seconds
- Update documentation to reflect new cache defaults and behavior
- Remove force refresh options from admin API endpoints

MIGRATION NOTES:
- Operators should ensure /etc/hyperglass/ip_enrichment directory is writable
- Any code relying on force refresh parameters must be updated
- Monitor logs for automatic refresh behavior and performance improvements
- The 7-day cache significantly reduces PeeringDB API load

PERFORMANCE BENEFITS:
- Faster traceroute enrichment due to concurrent DNS lookups
- Reduced external API calls with longer IXP cache duration
- More reliable refresh logic prevents stale cache usage
- Cleaner, more focused debug output when debug mode is disabled

TECHNICAL DETAILS:
- Uses asyncio.to_thread for non-blocking DNS operations
- Implements process-wide file locking for safe concurrent cache updates
- Robust fallbacks for various asyncio execution contexts
- Maintains backward compatibility while improving performance

FILES MODIFIED:
- hyperglass/external/ip_enrichment.py
- hyperglass/models/config/structured.py
- hyperglass/api/routes.py
- hyperglass/plugins/_builtin/trace_route_mikrotik.py
- hyperglass/models/parsing/mikrotik.py
- hyperglass/plugins/_builtin/traceroute_ip_enrichment.py
- docs/pages/configuration/config/structured-output.mdx
2025-10-05 21:25:58 +02:00
..
api feat: comprehensive IP enrichment and traceroute improvements 2025-10-05 21:25:58 +02:00
cli format and lint 2025-06-14 21:44:20 -04:00
compat Refactor code for improved readability and consistency across multiple files using black 2025-09-26 09:43:06 +02:00
configuration logging overhaul 2024-04-01 23:42:07 -04:00
defaults feat: Add structured traceroute support with comprehensive IP enrichment 2025-09-28 13:48:04 +02:00
exceptions format and lint 2025-06-14 21:44:20 -04:00
execution Merge branch 'main' into structured 2025-09-30 16:49:45 +02:00
external feat: comprehensive IP enrichment and traceroute improvements 2025-10-05 21:25:58 +02:00
frontend fix logging issues 2024-06-30 23:22:46 -04:00
images update defaults & docs with new logo 2020-07-04 15:01:25 -07:00
models feat: comprehensive IP enrichment and traceroute improvements 2025-10-05 21:25:58 +02:00
plugins feat: comprehensive IP enrichment and traceroute improvements 2025-10-05 21:25:58 +02:00
state Refactor code for improved readability and consistency across multiple files using black 2025-09-26 09:43:06 +02:00
ui feat(structured): release structured feature set (squash merge) 2025-09-30 16:46:01 +02:00
util Refactor code for improved readability and consistency across multiple files using black 2025-09-26 09:43:06 +02:00
.gitignore cleanup 2020-04-12 02:17:16 -07:00
__init__.py update module docstring 2022-12-26 10:07:04 -05:00
console.py Migrate to typer for hyperglass CLI, implement new setup 2021-09-27 01:40:49 -07:00
constants.py Refactor code for improved readability and consistency across multiple files using black 2025-09-26 09:43:06 +02:00
log.py remove unnecessary logging 2024-06-30 23:54:37 -04:00
main.py feat(structured): release structured feature set (squash merge) 2025-09-30 16:46:01 +02:00
settings.py Refactor HyperglassSettings name 2021-09-22 22:30:16 -07:00
types.py Add is_series type guard, with tests 2021-09-16 15:57:12 -07:00