Struct tower_governor::key_extractor::PeerIpKeyExtractor
source · pub struct PeerIpKeyExtractor;
Expand description
A KeyExtractor that uses peer IP as key. This is the default key extractor and it may no do want you want.
Warning: this key extractor enforces rate limiting based on the peer IP address.
This means that if your app is deployed behind a reverse proxy, the peer IP address will always be the proxy’s IP address. In this case, rate limiting will be applied to all incoming requests as if they were from the same user.
If this is not the behavior you want, you may:
- Use the SmartIpKeyExtractor to get the IP from the
Forwarded
orX-Forwarded-For
headers that most proxies set - implement your own KeyExtractor that tries to get IP from the
Forwarded
orX-Forwarded-For
headers that most reverse proxies set - make absolutely sure that you only trust these headers when the peer IP is the IP of your reverse proxy (otherwise any user could set them to fake its IP)
Trait Implementations§
source§impl Clone for PeerIpKeyExtractor
impl Clone for PeerIpKeyExtractor
source§fn clone(&self) -> PeerIpKeyExtractor
fn clone(&self) -> PeerIpKeyExtractor
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PeerIpKeyExtractor
impl Debug for PeerIpKeyExtractor
source§impl KeyExtractor for PeerIpKeyExtractor
impl KeyExtractor for PeerIpKeyExtractor
source§impl PartialEq for PeerIpKeyExtractor
impl PartialEq for PeerIpKeyExtractor
source§fn eq(&self, other: &PeerIpKeyExtractor) -> bool
fn eq(&self, other: &PeerIpKeyExtractor) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for PeerIpKeyExtractor
impl Eq for PeerIpKeyExtractor
impl StructuralPartialEq for PeerIpKeyExtractor
Auto Trait Implementations§
impl Freeze for PeerIpKeyExtractor
impl RefUnwindSafe for PeerIpKeyExtractor
impl Send for PeerIpKeyExtractor
impl Sync for PeerIpKeyExtractor
impl Unpin for PeerIpKeyExtractor
impl UnwindSafe for PeerIpKeyExtractor
Blanket Implementations§
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