Skip to main content

is_loopback

Function is_loopback 

Source
pub fn is_loopback(endpoint: &str) -> bool
Expand description

Does an endpoint or a seed (http://host:port, or host:port) reach only this machine? A loopback address carries the card and the envelope nowhere a person on another host can read them, which is how two worktrees of one machine find each other without a hub, so a working tree may name one without the trunk’s say-so.

use majordomus_cli::mesh::root::is_loopback;
assert!(is_loopback("http://127.0.0.1:8791"));
assert!(is_loopback("http://localhost:7"));
assert!(is_loopback("[::1]:8791"));
assert!(!is_loopback("http://192.168.100.30:8791"));
assert!(!is_loopback("http://127.0.0.1.attacker.example:8791"));