cuprate_p2p_core/network_zones/
clear.rs
1use std::net::{IpAddr, SocketAddr};
2
3use crate::{NetZoneAddress, NetworkZone};
4
5impl NetZoneAddress for SocketAddr {
6 type BanID = IpAddr;
7
8 fn set_port(&mut self, port: u16) {
9 Self::set_port(self, port);
10 }
11
12 fn ban_id(&self) -> Self::BanID {
13 self.ip()
14 }
15
16 fn make_canonical(&mut self) {
17 let ip = self.ip().to_canonical();
18 self.set_ip(ip);
19 }
20
21 fn should_add_to_peer_list(&self) -> bool {
22 true
24 }
25}
26
27#[derive(Clone, Copy)]
28pub enum ClearNet {}
29
30#[async_trait::async_trait]
31impl NetworkZone for ClearNet {
32 const NAME: &'static str = "ClearNet";
33
34 const CHECK_NODE_ID: bool = true;
35
36 const BROADCAST_OWN_ADDR: bool = false;
37
38 type Addr = SocketAddr;
39}