//! IP address extraction from WebSocket connections

use axum::extract::ConnectInfo;
use std::net::{IpAddr, SocketAddr};

/// Extract IP address from Axum ConnectInfo
///
/// # Example
/// ```rust
/// pub async fn handler(ConnectInfo(addr): ConnectInfo<SocketAddr>) {
///     let ip = extract_ip(&addr);
///     // Use ip for logging
/// }
/// ```
pub fn extract_ip(addr: &SocketAddr) -> IpAddr {
    addr.ip()
}

/// Extract IP address as string
pub fn extract_ip_string(addr: &SocketAddr) -> String {
    addr.ip().to_string()
}
