fair-rate-limiter

crates.io version license: Apache 2.0 unsafe forbidden pipeline status

Use RateLimiter struct to detect overload and fairly shed load from diverse IP addresses, users, or systems. Mitigate denial-of-service (DoS) attacks.

Use Cases

Features

Limitations

Alternatives

Related Crates

Example

rust let mut limiter = new_fair_ip_address_rate_limiter(10.0).unwrap(); let mut now = Instant::now(); let key = IpAddrKey::from(Ipv4Addr::new(10,0,0,1)); assert!(limiter.check(key, 4, now)); assert!(limiter.check(key, 4, now)); now += Duration::from_secs(1); assert!(limiter.check(key, 4, now)); assert!(limiter.check(key, 4, now)); now += Duration::from_secs(1); assert!(limiter.check(key, 4, now)); assert!(limiter.check(key, 4, now)); now += Duration::from_secs(1); assert!(limiter.check(key, 4, now)); assert!(limiter.check(key, 4, now)); assert!(!limiter.check(key, 4, now));

Cargo Geiger Safety Report

```

Metric output format: x/y x = unsafe code used by the build y = total unsafe code found in the crate

Symbols: 🔒 = No unsafe usage found, declares #![forbid(unsafecode)] ❓ = No unsafe usage found, missing #![forbid(unsafecode)] ☢️ = unsafe usage found

Functions Expressions Impls Traits Methods Dependency

0/0 0/0 0/0 0/0 0/0 🔒 fair-rate-limiter 0.1.0 0/0 0/0 0/0 0/0 0/0 🔒 └── oorandom 11.1.3

0/0 0/0 0/0 0/0 0/0

```

Changelog

TO DO

License: Apache-2.0