Ejemplo n.º 1
0
std::size_t do_parse_successor(const_buffer buf, ip::tcp::endpoint& ep)
{
	const successor_frame<Addr>* frame = buffer_cast<const successor_frame<Addr>*>(buf);

	typename Addr::bytes_type ip_bytes;
	std::memcpy(ip_bytes.data(), frame->sucessor_ip, ip_bytes.size());
	ep.address(Addr(ip_bytes));
	ep.port(u16(frame->sucessor_port));

	return sizeof(successor_frame<Addr>);
}
Ejemplo n.º 2
0
bool UpdateManager::isAddressInList(ip::tcp::endpoint &endpoint, std::list<boost::asio::ip::address> addresses) {
  ip::address address                  = endpoint.address();
  std::list<ip::address>::iterator i   = addresses.begin();
  std::list<ip::address>::iterator end = addresses.end();
  
  for ( ; i != end ; i++) {
    if ((*i) == address) return true;
  }
  
  return false;  
}
Ejemplo n.º 3
0
connection::ptr_t connection::connect(boost::shared_ptr<local_node> node, ip::tcp::endpoint peer, routing_type rtype)
{
	DLOG(INFO) << "Connecting: " << node->public_endpoint().port() << ", " << peer.address() << ':' << peer.port();
	ptr_t con(new connection(node, rtype));
	con->starting_connection();
	con->incoming_port_ = peer.port();
	con->link_.socket.lowest_layer().async_connect(peer, boost::bind(&connection::ssl_handshake,
	                                                                 con,
	                                                                 boost::asio::ssl::stream_base::client,
	                                                                 placeholders::error));
	return con;
}
Ejemplo n.º 4
0
void user_asyn_tcp_client::did_disconnect(const ip::tcp::endpoint &ep) {
    log_warn("end-point: %s:%d", ep.address().to_string().c_str(), ep.port());
}
Ejemplo n.º 5
0
void user_asyn_tcp_client::did_connect_to_host(const ip::tcp::endpoint &ep) {
    log_debug("end-point: %s:%d", ep.address().to_string().c_str(), ep.port());
    // 登录
//    do_login();
}