refactor: Extract health checks and utility modules from packet-gateway ebpf module

- Extract health check handlers to new health.rs module (health, liveness, readiness, metrics endpoints)
- Extract IP conversion utilities to new ip_utils.rs module (u32_to_ipv4_string, ipv4_string_to_u32)
- Extract Redis synchronization logic to new redis_sync.rs module (RedisSyncer with sync_packet_stats, sync_credit_info, sync_credits_from_redis, sync_blocked_from_redis, sync_batch_entry methods)
- Refactor EbpfManager
This commit is contained in:
nutcas3
2026-04-25 03:51:23 +03:00
parent 5467e22d22
commit f90882b4b2
5 changed files with 276 additions and 209 deletions
+15
View File
@@ -0,0 +1,15 @@
use anyhow::{Context, Result};
use std::net::Ipv4Addr;
/// Converts a u32 IP address to an IPv4 string
pub fn u32_to_ipv4_string(ip: u32) -> String {
let ip_addr = Ipv4Addr::from(ip);
ip_addr.to_string()
}
/// Converts an IPv4 string to a u32 IP address
pub fn ipv4_string_to_u32(ip_str: &str) -> Result<u32> {
let ip_addr: Ipv4Addr = ip_str.parse()
.context("Invalid IP address format")?;
Ok(u32::from(ip_addr))
}