pub(crate) fn block_addr(&mut self, addr: SocketAddr, now: Instant) -> Option<DialRequest<H>> {
        let span = make_span(addr, self.outgoing.get(&addr));

        span.clone()
            .in_scope(move || match self.outgoing.entry(addr) {
                Entry::Vacant(_vacant) => {
                    info!("unknown address blocked");
                    self.change_outgoing_state(addr, OutgoingState::Blocked { since: now });
                    None
                }
                // TODO: Check what happens on close on our end, i.e. can we distinguish in logs
                // between a closed connection on our end vs one that failed?
                Entry::Occupied(occupied) => match occupied.get().state {
                    OutgoingState::Blocked { .. } => {
                        debug!("address already blocked");
                        None
                    }
                    OutgoingState::Loopback => {
                        warn!("loopback address block ignored");
                        None
                    }
                    OutgoingState::Connected { ref handle, .. } => {
                        info!("connected address blocked, disconnecting");
                        let handle = handle.clone();
                        self.change_outgoing_state(addr, OutgoingState::Blocked { since: now });
                        Some(DialRequest::Disconnect { span, handle })
                    }
                    OutgoingState::Waiting { .. } | OutgoingState::Connecting { .. } => {
                        info!("address blocked");
                        self.change_outgoing_state(addr, OutgoingState::Blocked { since: now });
                        None
                    }
                },
            })
    }
/// Blocks an address.
///
/// Causes any current connection to the address to be terminated and future ones prohibited.
Blocks an address.
Causes any current connection to the address to be terminated and future ones prohibited.
Blocks an address . Causes any current connection to the address to be terminated and future ones prohibited .
pub(crate) fn block_addr(&mut self, addr: SocketAddr, now: Instant) -> Option<DialRequest<H>> {
        let span = make_span(addr, self.outgoing.get(&addr));
        span.clone()
            .in_scope(move || match self.outgoing.entry(addr) {
                Entry::Vacant(_vacant) => {
                    info!("unknown address blocked");
                    self.change_outgoing_state(addr, OutgoingState::Blocked { since: now });
                    None
                }
                // TODO: Check what happens on close on our end, i.e. can we distinguish in logs
                // between a closed connection on our end vs one that failed?
                Entry::Occupied(occupied) => match occupied.get().state {
                    OutgoingState::Blocked { .. } => {
                        debug!("address already blocked");
                        None
                    }
                    OutgoingState::Loopback => {
                        warn!("loopback address block ignored");
                        None
                    }
                    OutgoingState::Connected { ref handle, .. } => {
                        info!("connected address blocked, disconnecting");
                        let handle = handle.clone();
                        self.change_outgoing_state(addr, OutgoingState::Blocked { since: now });
                        Some(DialRequest::Disconnect { span, handle })
                    }
                    OutgoingState::Waiting { .. } | OutgoingState::Connecting { .. } => {
                        info!("address blocked");
                        self.change_outgoing_state(addr, OutgoingState::Blocked { since: now });
                        None
                    }
                },
            })
    }
pub ( crate ) fn block_addr ( & mut self , addr : SocketAddr , now : Instant ) -> Option < DialRequest < H > > { let span = make_span ( addr , self . outgoing . get ( & addr ) ) ; span . clone ( ) . in_scope ( move | | match self . outgoing . entry ( addr ) { Entry :: Vacant ( _vacant ) => { info ! ( " " ) ; self . change_outgoing_state ( addr , OutgoingState :: Blocked { since : now } ) ; None } // TODO: Check what happens on close on our end, i.e. can we distinguish in logs // between a closed connection on our end vs one that failed? Entry :: Occupied ( occupied ) => match occupied . get ( ) . state { OutgoingState :: Blocked { .. } => { debug ! ( " " ) ; None } OutgoingState :: Loopback => { warn ! ( " " ) ; None } OutgoingState :: Connected { ref handle , .. } => { info ! ( " " ) ; let handle = handle . clone ( ) ; self . change_outgoing_state ( addr , OutgoingState :: Blocked { since : now } ) ; Some ( DialRequest :: Disconnect { span , handle } ) } OutgoingState :: Waiting { .. } | OutgoingState :: Connecting { .. } => { info ! ( " " ) ; self . change_outgoing_state ( addr , OutgoingState :: Blocked { since : now } ) ; None } } , } ) }
Blocks an address.
Blocks an address .
&mut self
addr
SocketAddr
now
Instant
&mut self
addr
SocketAddr
now
Instant