mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-11 14:35:13 +00:00
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:
@@ -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))
|
||||
}
|
||||
Reference in New Issue
Block a user