void protocol::start_connect(const code& ec, const config::authority& peer) { if (ec) { handle_connect(ec, nullptr, peer); return; } if (is_connected(peer)) { handle_connect(error::address_in_use, nullptr, peer); return; } if (is_blacklisted(peer)) { handle_connect(error::address_blocked, nullptr, peer); return; } log_debug(LOG_PROTOCOL) << "Connecting to peer [" << peer.to_string() << "]"; // OUTBOUND CONNECT (sequential) network_.connect(peer.to_hostname(), peer.port(), dispatch_.ordered_delegate(&protocol::handle_connect, this, _1, _2, peer)); }
bool protocol::is_blacklisted(const config::authority& peer) const { const auto found = [&peer](const config::authority& host) { return (host.port() == 0 || host.port() == peer.port()) && (host.ip() == peer.ip()); }; auto it = std::find_if(blacklisted_.begin(), blacklisted_.end(), found); return it != blacklisted_.end(); return true; }
void connector::connect(const config::authority& authority, connect_handler handler) { connect(authority.to_hostname(), authority.port(), handler); }