MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / record_ip

Method record_ip

nodedb/src/control/security/risk.rs:153–163  ·  view source on GitHub ↗

Record an IP as known for a user.

(&self, user_id: &str, ip: &str)

Source from the content-addressed store, hash-verified

151
152 /// Record an IP as known for a user.
153 fn record_ip(&self, user_id: &str, ip: &str) {
154 let mut known = self.known_ips.write().unwrap_or_else(|p| p.into_inner());
155 let ips = known.entry(user_id.into()).or_default();
156 if !ips.contains(&ip.to_string()) {
157 // Keep max 50 IPs per user.
158 if ips.len() >= 50 {
159 ips.remove(0);
160 }
161 ips.push(ip.to_string());
162 }
163 }
164}
165
166impl Default for RiskScorer {

Callers 1

scoreMethod · 0.80

Calls 7

entryMethod · 0.80
to_stringMethod · 0.80
writeMethod · 0.45
containsMethod · 0.45
lenMethod · 0.45
removeMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected