Trait cuprate_p2p_core::NetZoneAddress

source ·
pub trait NetZoneAddress:
    TryFrom<NetworkAddress, Error = NetworkAddressIncorrectZone>
    + Into<NetworkAddress>
    + Display
    + Hash
    + Eq
    + Copy
    + Send
    + Sync
    + Unpin
    + 'static {
    type BanID: Debug + Hash + Eq + Clone + Copy + Send + 'static;

    // Required methods
    fn set_port(&mut self, port: u16);
    fn make_canonical(&mut self);
    fn ban_id(&self) -> Self::BanID;
    fn should_add_to_peer_list(&self) -> bool;
}
Expand description

An address on a specific NetworkZone.

Required Associated Types§

source

type BanID: Debug + Hash + Eq + Clone + Copy + Send + 'static

Cuprate needs to be able to ban peers by IP addresses and not just by SocketAddr as that include the port, to be able to facilitate this network addresses must have a ban ID which for hidden services could just be the address it self but for clear net addresses will be the IP address.

  • TODO: IP zone banning?
  • TODO: rename this to Host.

Required Methods§

source

fn set_port(&mut self, port: u16)

Changes the port of this address to port.

source

fn make_canonical(&mut self)

Turns this address into its canonical form.

source

fn ban_id(&self) -> Self::BanID

Returns the Self::BanID for this address.

source

fn should_add_to_peer_list(&self) -> bool

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl NetZoneAddress for SocketAddr

source§

type BanID = IpAddr

source§

fn set_port(&mut self, port: u16)

source§

fn ban_id(&self) -> Self::BanID

source§

fn make_canonical(&mut self)

source§

fn should_add_to_peer_list(&self) -> bool

Implementors§