1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-02-07 17:58:24 +00:00
Commit graph

112 commits

Author SHA1 Message Date
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
Wilhelm Schonfeldt
9db9849a59
feat(structured): release structured feature set (squash merge)
Summary:
- Add structured traceroute support with comprehensive IP enrichment (ASN/org/RDNS).
- Improve MikroTik traceroute cleaning and aggregation; collapse repeated tables into a single representative table.
- Enhance traceroute logging for visibility and add traceroute-specific cleaning helpers.
- Add/adjust IP enrichment plugins and BGP/traceroute enrichment integrations.
- UI updates for traceroute output and path visualization; update docs and configuration for structured output.

This commit squashes changes from 'structured-dev' into a single release commit.
2025-09-30 16:46:01 +02:00
Wilhelm Schonfeldt
0398966062
feat: Add structured traceroute support with comprehensive IP enrichment
MAJOR NEW ARCHITECTURE - STRUCTURED TRACEROUTE:
- Complete rewrite of traceroute data processing with structured output
- Dedicated TracerouteResult and TracerouteHop data models
- Platform-specific parsers with unified output format
- Rich metadata including ASN, organization, country, and prefix information
- AS path visualization with organization names in React Flow charts

SUPPORTED PLATFORMS:
- TraceroutePluginMikrotik: Handles MikroTik's complex multi-table format
  * Progressive statistics parsing with deduplication
  * Timeout hop handling and continuation line processing
  * Loss percentage and RTT statistics extraction
- TraceroutePluginHuawei: Unix-style traceroute format parser
  * Standard hop_number ip_address rtt format support
  * Timeout hop detection with * notation
  * Automatic cleanup of excessive trailing timeouts

COMPREHENSIVE IP ENRICHMENT SYSTEM:
- Offline enrichment using BGP.tools bulk data (1.3M+ CIDR entries)
- PeeringDB integration for IXP detection and ASN organization data
- Ultra-fast pickle cache system with combined data files
- Integer-based bitwise IP matching for maximum performance
- Bulk ASN organization lookup capabilities
- Private/reserved IP handling with AS0 fallbacks
- Country code mapping from ASN database
- Graceful fallbacks for missing enrichment data

FRONTEND ENHANCEMENTS:
- New traceroute table components with consistent formatting
- Enhanced AS path visualization with organization names
- Improved copy-to-clipboard functionality with structured data
- Unified table styling across BGP and traceroute results
- Better error handling and loading states

CONCURRENT PROCESSING INFRASTRUCTURE:
- Thread executor implementation for blocking I/O operations
- Query deduplication system to prevent resource conflicts
- Non-blocking Redis cache operations using asyncio executors
- Event coordination for waiting requests
- Background cleanup for completed operations
- Prevents website hangs during long-running queries

PLUGIN ARCHITECTURE IMPROVEMENTS:
- Platform-aware plugin system with proper execution restrictions
- Enhanced MikroTik garbage output cleaning
- IP enrichment plugins for both BGP routes and traceroute
- Conditional plugin execution based on platform detection
- Proper async/sync plugin method handling

CRITICAL BUG FIXES:
- Fixed double AS prefix bug (ASAS123456 → AS123456)
- Resolved TracerouteHop avg_rtt field/property conflicts
- Corrected Huawei traceroute source field validation
- Fixed plugin platform restriction enforcement
- Eliminated blocking I/O causing UI freezes
- Proper timeout and empty response caching prevention
- Enhanced private IP range detection and handling

PERFORMANCE OPTIMIZATIONS:
- Pickle cache system reduces startup time from seconds to milliseconds
- Bulk processing for ASN organization lookups
- Simplified IXP detection using single PeeringDB API call
- Efficient CIDR network sorting and integer-based lookups
- Reduced external API calls by 90%+
- Optimized memory usage for large datasets

API & ROUTING ENHANCEMENTS:
- Enhanced API routes with proper error handling
- Improved middleware for concurrent request processing
- Better state management and event handling
- Enhanced task processing with thread pool execution

This represents a complete transformation of hyperglass traceroute capabilities,
moving from basic text output to rich, structured data with comprehensive
network intelligence and concurrent processing support.
2025-09-28 13:48:04 +02:00
Jason Hall
cf137bd7e8
format and lint 2025-06-14 21:44:20 -04:00
thatmattlove
f340e65082 fix BGP route validation 2024-06-30 23:33:06 -04:00
thatmattlove
b617df24d1 fixes #267: fix response caching 2024-06-30 22:22:44 -04:00
thatmattlove
3b0abd5ba8 don't cache errors 2024-06-30 21:34:42 -04:00
thatmattlove
ee5a418264 fix import sorting 2024-05-27 16:25:47 -04:00
thatmattlove
dd2ce8354b fix handling of litestar.exceptions.ValidationException. Probably fixes #243 2024-05-27 16:25:26 -04:00
thatmattlove
d2f734ba1c logging overhaul 2024-04-01 23:42:07 -04:00
thatmattlove
d2e1486b5a initial migration to litestar 2024-03-26 23:59:42 -04:00
thatmattlove
1ef376fb38 improve fake output 2024-03-25 00:10:17 -04:00
thatmattlove
a8476f2ea9 fix import sorting 2024-03-17 16:04:41 -04:00
thatmattlove
77c0a31256 upgrade major dependencies 2024-03-16 23:17:54 -04:00
thatmattlove
213da6380b add logging to error handlers 2024-03-03 00:20:54 -05:00
thatmattlove
8c8e4f8109 remove trailing slash requirement for /api/query 2024-02-27 23:02:40 -05:00
thatmattlove
9c9a8469a4 replace flake8 with ruff for linting, refactor issues 2022-12-24 17:53:05 -05:00
thatmattlove
fc3ba3a8be clean up unused parameters and start work on 2.0.0 docs 2022-12-12 18:52:39 -05:00
thatmattlove
60429ebbc1 commit previous changes and dep updates 2022-12-11 17:30:20 -05:00
thatmattlove
0cd44e7fdf improve log messages 2021-12-17 20:37:03 -07:00
thatmattlove
1543f8d7c5 restructure api routes/tasks 2021-12-17 20:17:52 -07:00
thatmattlove
5bf69f7923 Fix fake output handling 2021-12-13 22:15:06 -07:00
thatmattlove
37a14b125f remove custom static file directory 2021-12-08 11:35:42 -07:00
thatmattlove
c049569cab Update black 2021-12-06 17:12:30 -07:00
thatmattlove
e73de24904 Implement input-plugin-based validation, implement common plugins 2021-09-26 11:39:46 -07:00
thatmattlove
c2240d92c6 Remove query_group from query fields 2021-09-25 21:50:51 -07:00
thatmattlove
7d5d64c0e2 Plugin/directive fixes 2021-09-21 07:54:16 -07:00
thatmattlove
1e1dce1e30 Fix leftover issues from cache refactor 2021-09-16 15:33:15 -07:00
thatmattlove
e06ea5ecb9 Add separate hooks for major state objects, add tests 2021-09-16 13:46:50 -07:00
thatmattlove
c99f98a6f0 Complete global state implementation 2021-09-15 18:25:37 -07:00
thatmattlove
a2ee4b50fa Implement global state 2021-09-15 00:57:45 -07:00
thatmattlove
74fcb5dba4 Continue output plugin implementation 2021-09-12 18:27:33 -07:00
thatmattlove
52ebf4663c Update code formatting - line length 2021-09-12 15:09:24 -07:00
thatmattlove
dc274992b8 Clean up API routes 2021-09-11 13:56:20 -07:00
thatmattlove
fb003f3248 Add GZIP support & swap Starlette classes for FastAPI classes 2021-09-11 13:10:05 -07:00
thatmattlove
99c7489441 Move UI Params into Pydantic model 2021-09-10 01:18:38 -07:00
thatmattlove
070a07d065 Implement client-side UI config fetching 2021-09-09 18:03:04 -07:00
thatmattlove
5ccfe50792 Complete directives implementation, refactor exceptions, deprecate VRFs, bump minimum Python version 2021-09-07 22:58:39 -07:00
checktheroads
aca3457011 update python dependencies 2021-04-24 10:44:40 -07:00
checktheroads
72269f38f5 consolidate name & display name fields, closes #115 2021-02-10 00:43:40 -07:00
checktheroads
042ce35672 increase default UI build timeout & add CLI option to override 2021-01-28 23:04:02 -07:00
checktheroads
6a57f346d0 replace temporary fake output with "real" fake output 2021-01-03 00:09:20 -07:00
checktheroads
2b7039943b swap to real ASNs for testing fake data [skip ci] 2020-12-22 02:00:29 -07:00
checktheroads
257f802f3b fix fake output generation bug [skip ci] 2020-12-20 01:21:10 -07:00
checktheroads
0bb19082a0 add more route types to fake output for testing [skip ci] 2020-12-17 16:37:09 -07:00
checktheroads
70e4d4edc9 improve fake output [skip ci] 2020-12-15 01:17:50 -07:00
checktheroads
6195e888de fix fake string output [skip ci] 2020-12-14 01:04:03 -07:00
checktheroads
0c1399d766 add fake output option for dev [skip ci] 2020-12-13 01:47:09 -07:00
checktheroads
ba1a91c93f add redis password authentication support, closes #82 2020-10-10 21:13:28 -07:00
checktheroads
69cb304b6d restructure location of models for cleaner importing/exporting 2020-10-05 12:09:17 -07:00