Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: Don't limit LAN addresses
cloudhead committed 2 years ago
commit 091f7b7e986d05381718e2aeed2497c55dd0179a
parent 9c96b46c592aafc0858c4d4babafdba1ed59b88c
1 file changed +7 -1
modified radicle-node/src/service/limitter.rs
@@ -1,7 +1,7 @@
use std::collections::HashMap;

use localtime::LocalTime;
-
use radicle::node::{config, HostName};
+
use radicle::node::{address, config, HostName};

/// Peer rate limitter.
///
@@ -21,6 +21,12 @@ impl RateLimiter {
    /// Supplying a different amount of tokens per address is useful if for eg. a peer
    /// is outbound vs. inbound.
    pub fn limit<T: AsTokens>(&mut self, addr: HostName, tokens: &T, now: LocalTime) -> bool {
+
        if let HostName::Ip(ip) = addr {
+
            // Don't limit LAN addresses.
+
            if !address::is_routable(&ip) {
+
                return false;
+
            }
+
        }
        !self
            .buckets
            .entry(addr)