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

59 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
Wilhelm Schonfeldt
4414d2ec03 fix(ui): improve BGP table field display formatting
- Fix MED field showing N/A when value is 0 (now correctly shows 0)
- Hide Originator field when empty instead of showing N/A
- Hide Age field when not available instead of showing N/A
- Add HideableField component for fields that should be hidden when empty
- Update string output formatting to skip hidden fields in text export

Resolves display issues where valid zero values and unavailable fields
were showing as N/A instead of proper formatting or being hidden.
2025-09-26 13:30:44 +02:00
Wilhelm Schonfeldt
716687db63 fix(plugins): improve MikroTik traceroute output deduplication
- Add IPv6 address pattern matching alongside IPv4
- Extract SENT count from traceroute lines to prioritize complete data
- Keep lines with highest SENT count (final results) instead of first occurrence
- Maintain original hop order while using best data for each IP
- Prefer non-timeout results when SENT counts are equal

Fixes issues where IPv4 showed early results (SENT=1) instead of final (SENT=3)
and IPv6 showed all intermediate steps instead of final consolidated results.
2025-09-26 13:03:23 +02:00
Wilhelm Schonfeldt
5ace4fdf97 fix(plugins): improve type checking for structured output
- Split type checking into two separate conditions for clarity
- Add early return when output contains non-string objects
- Ensure structured output like MikrotikBGPRouteTable passes through unchanged
- Prevent AttributeError on .strip() for tuple containing structured data

Resolves remaining crashes when processing already-structured BGP route data.
2025-09-26 12:45:10 +02:00
Wilhelm Schonfeldt
10ab164ee6 fix(plugins): handle non-string output in MikroTik garbage plugin
- Add type checking to handle already-processed structured output
- Skip processing when output is not raw strings (e.g., BGPRouteTable objects)
- Prevents AttributeError when trying to call .strip() on tuple/structured data

Fixes crash when MikroTik garbage plugin runs after structured parsing plugins.
2025-09-26 12:40:55 +02:00
Wilhelm Schonfeldt
120af851d1 fix(plugins): improve MikroTik output cleaning for all directives
- Change MikrotikGarbageOutput to apply to ALL MikroTik platform commands using common=True
- Add specialized traceroute output cleaning to handle progressive output and paging prompts
- Remove interactive paging prompts (-- [Q quit|C-z pause])
- Deduplicate traceroute hops to show only final results
- Clean up command echoes and empty progress lines
- Apply to custom directives automatically without manual configuration

Fixes messy traceroute output with repeated progress updates and interactive prompts.
2025-09-26 12:30:27 +02:00
Wilhelm Schonfeldt
ae6a1a0bb8 Refactor code for improved readability and consistency across multiple files using black 2025-09-26 09:43:06 +02:00
Carlos Santos
1dfe987a6e
Update bgp_route_huawei.py 2025-09-13 03:21:22 -03:00
Carlos Santos
d72e5f98a6
Create bgp_routestr_huawei.py 2025-09-13 00:17:51 -03:00
Carlos Santos
16c1674d7e
Create mikrotik_normalize_input.py 2025-09-13 00:17:00 -03:00
Carlos Santos
504c0f1463
Update mikrotik_garbage_output.py 2025-09-13 00:16:17 -03:00
Carlos Santos
4432f48f9b
Create bgp_routestr_mikrotik.py 2025-09-13 00:15:56 -03:00
Carlos Santos
ff0bed6257
Update __init__.py 2025-09-13 00:15:15 -03:00
Jason Hall
cf137bd7e8
format and lint 2025-06-14 21:44:20 -04:00
Jelson Stoelben Rodrigues
f67c676a2d feat: add Huawei BGP Route Input Plugin
Create builtin plugin to transform input field before passing to Huawei device
2025-06-09 21:37:14 -04:00
Chris Wiggins
51c7f9eef6 feat: Add FRR structured output for BGP Routes 2025-06-09 21:12:18 -04:00
thatmattlove
41248231ae fix logging issues 2024-06-30 23:22:46 -04:00
thatmattlove
30fda91bc8 closes #262: fix mikrotik error 2024-06-16 16:54:14 -04:00
thatmattlove
e84cc4ac00 remove deprecated pydantic constr usage 2024-05-27 14:41:04 -04:00
thatmattlove
d2f734ba1c logging overhaul 2024-04-01 23:42:07 -04:00
thatmattlove
a8476f2ea9 fix import sorting 2024-03-17 16:04:41 -04:00
thatmattlove
d706ff1959 fix test fixtures 2024-03-17 15:59:34 -04:00
thatmattlove
77c0a31256 upgrade major dependencies 2024-03-16 23:17:54 -04:00
thatmattlove
2c7456c317 replace legacy mikrotik parsing with builtin plugin 2022-12-26 11:05:46 -05:00
thatmattlove
9c9a8469a4 replace flake8 with ruff for linting, refactor issues 2022-12-24 17:53:05 -05:00
thatmattlove
a19f0aa7d9 Fix plugin import error 2021-12-17 20:32:08 -07:00
thatmattlove
c8892f43ea Implement Arista table output plugin and default directive 2021-12-08 17:13:56 -07:00
thatmattlove
c049569cab Update black 2021-12-06 17:12:30 -07:00
thatmattlove
fe7abddd4e Fix tests 2021-10-04 01:43:02 -07:00
thatmattlove
28eb803a8e Add plugins CLI 2021-10-04 01:39:00 -07:00
thatmattlove
8013c48ae9 Copy plugins to module instead of kludgy import 2021-10-04 01:38:44 -07:00
thatmattlove
e73de24904 Implement input-plugin-based validation, implement common plugins 2021-09-26 11:39:46 -07:00
thatmattlove
89568dc8e5 Deprecate Device.network 2021-09-24 00:16:26 -07:00
thatmattlove
f5e4c1e282 fix test regressions 2021-09-23 01:00:26 -07:00
thatmattlove
7d5d64c0e2 Plugin/directive fixes 2021-09-21 07:54:16 -07:00
thatmattlove
e62af507ee Pass full query to output plugin instead of device 2021-09-18 12:47:56 -07:00
thatmattlove
cd87c254e4 Overhaul configuration initialization process, add missing device to directive association 2021-09-17 18:15:59 -07:00
thatmattlove
7adb6ae0ec Add directives to global state 2021-09-17 09:04:59 -07:00
thatmattlove
6bc6cf0e1c Fix missing items from Device.platform refactor 2021-09-17 01:11:18 -07:00
thatmattlove
85d7f8876e Refactor Device.type to Device.platform 2021-09-16 22:04:15 -07:00
thatmattlove
cb5459a72a Add failure_reason to InputPlugin, add BGP Community builtin plugin and tests 2021-09-16 18:32:59 -07:00
thatmattlove
dda73cb370 Refactor and restructure directive model 2021-09-16 17:12:30 -07:00
thatmattlove
6bdfa9e645 Fix string output type checks 2021-09-16 15:57:33 -07:00
thatmattlove
e06ea5ecb9 Add separate hooks for major state objects, add tests 2021-09-16 13:46:50 -07:00
thatmattlove
a2ee4b50fa Implement global state 2021-09-15 00:57:45 -07:00
thatmattlove
f1b664f09d Add processing checks for BGP route table plugin 2021-09-13 14:11:55 -07:00
thatmattlove
ac1e938bd3 Fix plugin registration for builtins 2021-09-13 14:10:50 -07:00
thatmattlove
f2cb15d0e2 Fix typing issues 2021-09-13 14:10:32 -07:00