// Bitbucket Data Center MCP server — generated by mcpify. Do not hand-edit.

use std::net::IpAddr;

/// Requests from localhost get relaxed auth requirements — the same
/// localhost-vs-network binding distinction proven useful in the reference
/// servers (looser auth only when bound to localhost, never over an exposed
/// network interface).
pub fn is_localhost(addr: IpAddr) -> bool {
    addr.is_loopback()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn recognizes_loopback_addresses() {
        assert!(is_localhost("127.0.0.1".parse().unwrap()));
        assert!(is_localhost("::1".parse().unwrap()));
    }

    #[test]
    fn rejects_non_loopback_addresses() {
        assert!(!is_localhost("10.0.0.5".parse().unwrap()));
    }
}
