Skip to main content

Crate netray_common

Crate netray_common 

Source
Expand description

Shared utilities for the netray.info service ecosystem.

This crate provides cross-cutting concerns used by multiple backend services:

  • ip_extract – Extract real client IP from proxy headers with trusted-proxy CIDR matching.
  • error – Structured JSON error responses via the error::ApiError trait.
  • rate_limit – Keyed and global rate limiting wrappers around governor.
  • security_headers – Axum middleware for CSP, HSTS, and other security headers.

§Example

use netray_common::ip_extract::IpExtractor;

let extractor = IpExtractor::new(&["10.0.0.0/8".to_string()]);
// extractor.extract(&headers, peer_addr) returns the real client IP

Modules§

ecosystem
Ecosystem service URL configuration shared across netray.info services.
error
ip_extract
ip_filter
metrics
Metrics namespace marker trait for service-specific metric prefixes.
rate_limit
security_headers
target_policy
Unified target IP validation — SSRF blocklist covering all special ranges.