pub struct CloudflareIpCache { /* private fields */ }Expand description
In-memory cache of Cloudflare edge CIDR ranges with a fast contains check.
Implementations§
Source§impl CloudflareIpCache
impl CloudflareIpCache
Sourcepub fn new_with_fallback() -> Arc<Self>
pub fn new_with_fallback() -> Arc<Self>
Build a cache populated from the hardcoded fallback list. No network.
Sourcepub async fn fetch_from_upstream() -> Arc<Self>
pub async fn fetch_from_upstream() -> Arc<Self>
GET the two upstream CF URLs, parse CIDRs, and return a new cache.
Falls back to the baked-in list on any error (network failure, DNS, timeout, non-200 status, parse error for both lists). If one of the two fetches succeeds and the other fails, the successful half is merged with the fallback for the failing half.
Sourcepub fn spawn_auto_refresh(interval: Duration) -> Arc<Self>
pub fn spawn_auto_refresh(interval: Duration) -> Arc<Self>
Spawn a tokio task that refreshes the cache immediately, then every
interval. The returned Arc is shared with the refresh task, which
lives for the duration of the process.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CloudflareIpCache
impl RefUnwindSafe for CloudflareIpCache
impl Send for CloudflareIpCache
impl Sync for CloudflareIpCache
impl Unpin for CloudflareIpCache
impl UnsafeUnpin for CloudflareIpCache
impl UnwindSafe for CloudflareIpCache
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more