diff options
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r-- | src/p2p/net_node.inl | 163 |
1 files changed, 80 insertions, 83 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index f32e7a435..34a3f9363 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -48,7 +48,6 @@ #include "net/local_ip.h" #include "crypto/crypto.h" #include "storages/levin_abstract_invoke2.h" -#include "data_logger.hpp" // We have to look for miniupnpc headers in different places, dependent on if its compiled or external #ifdef UPNP_STATIC @@ -61,6 +60,9 @@ #include "upnperrors.h" #endif +#undef MONERO_DEFAULT_LOG_CATEGORY +#define MONERO_DEFAULT_LOG_CATEGORY "net.p2p" + #define NET_MAKE_IP(b1,b2,b3,b4) ((LPARAM)(((DWORD)(b1)<<24)+((DWORD)(b2)<<16)+((DWORD)(b3)<<8)+((DWORD)(b4)))) @@ -203,7 +205,7 @@ namespace nodetool if(time(nullptr) >= it->second) { m_blocked_ips.erase(it); - LOG_PRINT_CYAN("IP " << epee::string_tools::get_ip_string_from_int32(addr) << " unblocked.", LOG_LEVEL_0); + MLOG_CYAN(el::Level::Info, "IP " << epee::string_tools::get_ip_string_from_int32(addr) << " unblocked."); return true; } return false; @@ -235,7 +237,7 @@ namespace nodetool for (const auto &c: conns) m_net_server.get_config_object().close(c); - LOG_PRINT_CYAN("IP " << epee::string_tools::get_ip_string_from_int32(addr) << " blocked.", LOG_LEVEL_0); + MLOG_CYAN(el::Level::Info, "IP " << epee::string_tools::get_ip_string_from_int32(addr) << " blocked."); return true; } //----------------------------------------------------------------------------------- @@ -247,7 +249,7 @@ namespace nodetool if (i == m_blocked_ips.end()) return false; m_blocked_ips.erase(i); - LOG_PRINT_CYAN("IP " << epee::string_tools::get_ip_string_from_int32(addr) << " unblocked.", LOG_LEVEL_0); + MLOG_CYAN(el::Level::Info, "IP " << epee::string_tools::get_ip_string_from_int32(addr) << " unblocked."); return true; } //----------------------------------------------------------------------------------- @@ -256,7 +258,7 @@ namespace nodetool { CRITICAL_REGION_LOCAL(m_ip_fails_score_lock); uint64_t fails = ++m_ip_fails_score[address]; - LOG_PRINT_CYAN("IP " << epee::string_tools::get_ip_string_from_int32(address) << " fail score=" << fails, LOG_LEVEL_1); + MDEBUG("IP " << epee::string_tools::get_ip_string_from_int32(address) << " fail score=" << fails); if(fails > P2P_IP_FAILS_BEFORE_BLOCK) { auto it = m_ip_fails_score.find(address); @@ -376,11 +378,11 @@ namespace nodetool na.ip = boost::asio::detail::socket_ops::host_to_network_long(endpoint.address().to_v4().to_ulong()); na.port = endpoint.port(); seed_nodes.push_back(na); - LOG_PRINT_L4("Added seed node: " << endpoint.address().to_v4().to_string(ec) << ':' << na.port); + MINFO("Added seed node: " << endpoint.address().to_v4().to_string(ec) << ':' << na.port); } else { - LOG_PRINT_L2("IPv6 doesn't supported, skip '" << host << "' -> " << endpoint.address().to_v6().to_string(ec)); + MDEBUG("IPv6 doesn't supported, skip '" << host << "' -> " << endpoint.address().to_v6().to_string(ec)); } } } @@ -416,7 +418,7 @@ namespace nodetool { boost::thread* th = new boost::thread([=, &dns_results, &addr_str] { - LOG_PRINT_L4("dns_threads[" << result_index << "] created for: " << addr_str); + MDEBUG("dns_threads[" << result_index << "] created for: " << addr_str); // TODO: care about dnssec avail/valid bool avail, valid; std::vector<std::string> addr_list; @@ -424,7 +426,7 @@ namespace nodetool try { addr_list = tools::DNSResolver::instance().get_ipv4(addr_str, avail, valid); - LOG_PRINT_L4("dns_threads[" << result_index << "] DNS resolve done"); + MDEBUG("dns_threads[" << result_index << "] DNS resolve done"); boost::this_thread::interruption_point(); } catch(const boost::thread_interrupted&) @@ -432,11 +434,11 @@ namespace nodetool // thread interruption request // even if we now have results, finish thread without setting // result variables, which are now out of scope in main thread - LOG_PRINT_L4("dns_threads[" << result_index << "] interrupted"); + MWARNING("dns_threads[" << result_index << "] interrupted"); return; } - LOG_PRINT_L4("dns_threads[" << result_index << "] addr_str: " << addr_str << " number of results: " << addr_list.size()); + MINFO("dns_threads[" << result_index << "] addr_str: " << addr_str << " number of results: " << addr_list.size()); dns_results[result_index] = addr_list; }); @@ -444,14 +446,14 @@ namespace nodetool ++result_index; } - LOG_PRINT_L4("dns_threads created, now waiting for completion or timeout of " << CRYPTONOTE_DNS_TIMEOUT_MS << "ms"); + MDEBUG("dns_threads created, now waiting for completion or timeout of " << CRYPTONOTE_DNS_TIMEOUT_MS << "ms"); boost::chrono::system_clock::time_point deadline = boost::chrono::system_clock::now() + boost::chrono::milliseconds(CRYPTONOTE_DNS_TIMEOUT_MS); uint64_t i = 0; for (boost::thread* th : dns_threads) { if (! th->try_join_until(deadline)) { - LOG_PRINT_L4("dns_threads[" << i << "] timed out, sending interrupt"); + MWARNING("dns_threads[" << i << "] timed out, sending interrupt"); th->interrupt(); } ++i; @@ -460,7 +462,7 @@ namespace nodetool i = 0; for (const auto& result : dns_results) { - LOG_PRINT_L4("DNS lookup for " << m_seed_nodes_list[i] << ": " << result.size() << " results"); + MDEBUG("DNS lookup for " << m_seed_nodes_list[i] << ": " << result.size() << " results"); // if no results for node, thread's lookup likely timed out if (result.size()) { @@ -472,7 +474,7 @@ namespace nodetool if (!full_addrs.size()) { - LOG_PRINT_L0("DNS seed node lookup either timed out or failed, falling back to defaults"); + MINFO("DNS seed node lookup either timed out or failed, falling back to defaults"); full_addrs.insert("198.74.231.92:18080"); full_addrs.insert("161.67.132.39:18080"); full_addrs.insert("163.172.182.165:18080"); @@ -483,10 +485,10 @@ namespace nodetool for (const auto& full_addr : full_addrs) { - LOG_PRINT_L2("Seed node: " << full_addr); + MDEBUG("Seed node: " << full_addr); append_net_address(m_seed_nodes, full_addr); } - LOG_PRINT_L1("Number of seed nodes: " << m_seed_nodes.size()); + MDEBUG("Number of seed nodes: " << m_seed_nodes.size()); bool res = handle_command_line(vm, testnet); CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line"); @@ -520,18 +522,18 @@ namespace nodetool return res; //try to bind - LOG_PRINT_L0("Binding on " << m_bind_ip << ":" << m_port); + MINFO("Binding on " << m_bind_ip << ":" << m_port); res = m_net_server.init_server(m_port, m_bind_ip); CHECK_AND_ASSERT_MES(res, false, "Failed to bind server"); m_listenning_port = m_net_server.get_binded_port(); - LOG_PRINT_GREEN("Net service bound to " << m_bind_ip << ":" << m_listenning_port, LOG_LEVEL_0); + MLOG_GREEN(el::Level::Info, "Net service bound to " << m_bind_ip << ":" << m_listenning_port); if(m_external_port) - LOG_PRINT_L0("External port defined as " << m_external_port); + MDEBUG("External port defined as " << m_external_port); // Add UPnP port mapping if(m_no_igd == false) { - LOG_PRINT_L0("Attempting to add IGD port mapping."); + MDEBUG("Attempting to add IGD port mapping."); int result; #if MINIUPNPC_API_VERSION > 13 // default according to miniupnpc.h @@ -558,19 +560,19 @@ namespace nodetool if (portMappingResult != 0) { LOG_ERROR("UPNP_AddPortMapping failed, error: " << strupnperror(portMappingResult)); } else { - LOG_PRINT_GREEN("Added IGD port mapping.", LOG_LEVEL_0); + MLOG_GREEN(el::Level::Info, "Added IGD port mapping."); } } else if (result == 2) { - LOG_PRINT_L0("IGD was found but reported as not connected."); + MWARNING("IGD was found but reported as not connected."); } else if (result == 3) { - LOG_PRINT_L0("UPnP device was found but not recognized as IGD."); + MWARNING("UPnP device was found but not recognized as IGD."); } else { - LOG_ERROR("UPNP_GetValidIGD returned an unknown result code."); + MWARNING("UPNP_GetValidIGD returned an unknown result code."); } FreeUPNPUrls(&urls); } else { - LOG_PRINT_L0("No IGD was found."); + MINFO("No IGD was found."); } } return res; @@ -600,9 +602,6 @@ namespace nodetool }); // lambda m_current_number_of_out_peers = number_of_peers; - if (epee::net_utils::data_logger::is_dying()) - break; - epee::net_utils::data_logger::get_instance().add_data("peers", number_of_peers); boost::this_thread::sleep_for(boost::chrono::seconds(1)); } // main loop of thread @@ -619,13 +618,13 @@ namespace nodetool attrs.set_stack_size(THREAD_STACK_SIZE); //go to loop - LOG_PRINT("Run net_service loop( " << thrds_count << " threads)...", LOG_LEVEL_0); + MINFO("Run net_service loop( " << thrds_count << " threads)..."); if(!m_net_server.run_server(thrds_count, true, attrs)) { LOG_ERROR("Failed to run net tcp server!"); } - LOG_PRINT("net_service loop stopped.", LOG_LEVEL_0); + MINFO("net_service loop stopped."); return true; } @@ -652,7 +651,7 @@ namespace nodetool TRY_ENTRY(); if (!tools::create_directories_if_necessary(m_config_folder)) { - LOG_PRINT_L0("Failed to create data directory: " << m_config_folder); + MWARNING("Failed to create data directory: " << m_config_folder); return false; } @@ -661,7 +660,7 @@ namespace nodetool p2p_data.open( state_file_path , std::ios_base::binary | std::ios_base::out| std::ios::trunc); if(p2p_data.fail()) { - LOG_PRINT_L0("Failed to save config to file " << state_file_path); + MWARNING("Failed to save config to file " << state_file_path); return false; }; @@ -678,7 +677,7 @@ namespace nodetool { m_payload_handler.stop(); m_net_server.send_stop_signal(); - LOG_PRINT_L0("[node] Stop signal sent"); + MDEBUG("[node] Stop signal sent"); return true; } //----------------------------------------------------------------------------------- @@ -702,19 +701,19 @@ namespace nodetool if(code < 0) { - LOG_PRINT_CC_RED(context, "COMMAND_HANDSHAKE invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")", LOG_LEVEL_1); + LOG_ERROR_CC(context, "COMMAND_HANDSHAKE invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")"); return; } if(rsp.node_data.network_id != m_network_id) { - LOG_ERROR_CCONTEXT("COMMAND_HANDSHAKE Failed, wrong network! (" << epee::string_tools::get_str_from_guid_a(rsp.node_data.network_id) << "), closing connection."); + LOG_ERROR_CC(context, "COMMAND_HANDSHAKE Failed, wrong network! (" << epee::string_tools::get_str_from_guid_a(rsp.node_data.network_id) << "), closing connection."); return; } if(!handle_remote_peerlist(rsp.local_peerlist, rsp.node_data.local_time, context)) { - LOG_ERROR_CCONTEXT("COMMAND_HANDSHAKE: failed to handle_remote_peerlist(...), closing connection."); + LOG_ERROR_CC(context, "COMMAND_HANDSHAKE: failed to handle_remote_peerlist(...), closing connection."); add_ip_fail(context.m_remote_ip); return; } @@ -723,7 +722,7 @@ namespace nodetool { if(!m_payload_handler.process_payload_sync_data(rsp.payload_data, context, true)) { - LOG_ERROR_CCONTEXT("COMMAND_HANDSHAKE invoked, but process_payload_sync_data returned false, dropping connection."); + LOG_ERROR_CC(context, "COMMAND_HANDSHAKE invoked, but process_payload_sync_data returned false, dropping connection."); hsh_result = false; return; } @@ -733,14 +732,14 @@ namespace nodetool if(rsp.node_data.peer_id == m_config.m_peer_id) { - LOG_PRINT_CCONTEXT_L2("Connection to self detected, dropping connection"); + LOG_DEBUG_CC(context, "Connection to self detected, dropping connection"); hsh_result = false; return; } - LOG_PRINT_CCONTEXT_L1(" COMMAND_HANDSHAKE INVOKED OK"); + LOG_DEBUG_CC(context, " COMMAND_HANDSHAKE INVOKED OK"); }else { - LOG_PRINT_CCONTEXT_L1(" COMMAND_HANDSHAKE(AND CLOSE) INVOKED OK"); + LOG_DEBUG_CC(context, " COMMAND_HANDSHAKE(AND CLOSE) INVOKED OK"); } }, P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT); @@ -751,7 +750,7 @@ namespace nodetool if(!hsh_result) { - LOG_PRINT_CC_L1(context_, "COMMAND_HANDSHAKE Failed"); + LOG_ERROR_CC(context_, "COMMAND_HANDSHAKE Failed"); m_net_server.get_config_object().close(context_.m_connection_id); } else @@ -776,13 +775,13 @@ namespace nodetool { if(code < 0) { - LOG_PRINT_CC_RED(context, "COMMAND_TIMED_SYNC invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")", LOG_LEVEL_1); + LOG_ERROR_CC(context, "COMMAND_TIMED_SYNC invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")"); return; } if(!handle_remote_peerlist(rsp.local_peerlist, rsp.local_time, context)) { - LOG_ERROR_CCONTEXT("COMMAND_TIMED_SYNC: failed to handle_remote_peerlist(...), closing connection."); + LOG_WARNING_CC(context, "COMMAND_TIMED_SYNC: failed to handle_remote_peerlist(...), closing connection."); m_net_server.get_config_object().close(context.m_connection_id ); add_ip_fail(context.m_remote_ip); } @@ -793,7 +792,7 @@ namespace nodetool if(!r) { - LOG_PRINT_CC_L2(context_, "COMMAND_TIMED_SYNC Failed"); + LOG_ERROR_CC(context_, "COMMAND_TIMED_SYNC Failed"); return false; } return true; @@ -808,7 +807,7 @@ namespace nodetool size_t x = crypto::rand<size_t>()%(max_index+1); size_t res = (x*x*x)/(max_index*max_index); //parabola \/ - LOG_PRINT_L3("Random connection index=" << res << "(x="<< x << ", max_index=" << max_index << ")"); + MDEBUG("Random connection index=" << res << "(x="<< x << ", max_index=" << max_index << ")"); return res; } //----------------------------------------------------------------------------------- @@ -853,9 +852,9 @@ namespace nodetool #define LOG_PRINT_CC_PRIORITY_NODE(priority, con, msg) \ do { \ if (priority) {\ - LOG_PRINT_CC_L1(con, msg); \ + LOG_INFO_CC(con, "[priority]" << msg); \ } else {\ - LOG_PRINT_CC_L1(con, msg); \ + LOG_INFO_CC(con, msg); \ } \ } while(0) @@ -872,7 +871,7 @@ namespace nodetool m_current_number_of_out_peers --; // atomic variable, update time = 1s return false; } - LOG_PRINT_L1("Connecting to " << epee::string_tools::get_ip_string_from_int32(na.ip) << ":" + MDEBUG("Connecting to " << epee::string_tools::get_ip_string_from_int32(na.ip) << ":" << epee::string_tools::num_to_string_fast(na.port) << "(white=" << white << ", last_seen: " << (last_seen_stamp ? epee::misc_utils::get_time_interval_string(time(NULL) - last_seen_stamp):"never") << ")..."); @@ -910,7 +909,7 @@ namespace nodetool if(just_take_peerlist) { m_net_server.get_config_object().close(con.m_connection_id); - LOG_PRINT_CC_GREEN(con, "CONNECTION HANDSHAKED OK AND CLOSED.", LOG_LEVEL_2); + LOG_DEBUG_CC(con, "CONNECTION HANDSHAKED OK AND CLOSED."); return true; } @@ -923,7 +922,7 @@ namespace nodetool m_peerlist.append_with_peer_white(pe_local); //update last seen and push it to peerlist manager - LOG_PRINT_CC_GREEN(con, "CONNECTION HANDSHAKED OK.", LOG_LEVEL_2); + LOG_DEBUG_CC(con, "CONNECTION HANDSHAKED OK."); return true; } @@ -986,7 +985,7 @@ namespace nodetool if(is_addr_recently_failed(pe.adr)) continue; - LOG_PRINT_L2("Selected peer: " << pe.id << " " << epee::string_tools::get_ip_string_from_int32(pe.adr.ip) + MDEBUG("Selected peer: " << pe.id << " " << epee::string_tools::get_ip_string_from_int32(pe.adr.ip) << ":" << boost::lexical_cast<std::string>(pe.adr.port) << "[white=" << use_white_list << "] last_seen: " << (pe.last_seen ? epee::misc_utils::get_time_interval_string(time(NULL) - pe.last_seen) : "never")); @@ -1021,7 +1020,7 @@ namespace nodetool break; if(++try_count > m_seed_nodes.size()) { - LOG_PRINT_RED_L0("Failed to connect to any of seed peers, continuing without seeds"); + MWARNING("Failed to connect to any of seed peers, continuing without seeds"); break; } if(++current_index >= m_seed_nodes.size()) @@ -1105,7 +1104,7 @@ namespace nodetool template<class t_payload_net_handler> bool node_server<t_payload_net_handler>::peer_sync_idle_maker() { - LOG_PRINT_L2("STARTED PEERLIST IDLE HANDSHAKE"); + MDEBUG("STARTED PEERLIST IDLE HANDSHAKE"); typedef std::list<std::pair<epee::net_utils::connection_context_base, peerid_type> > local_connects_type; local_connects_type cncts; m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt) @@ -1117,7 +1116,7 @@ namespace nodetool std::for_each(cncts.begin(), cncts.end(), [&](const typename local_connects_type::value_type& vl){do_peer_timed_sync(vl.first, vl.second);}); - LOG_PRINT_L2("FINISHED PEERLIST IDLE HANDSHAKE"); + MDEBUG("FINISHED PEERLIST IDLE HANDSHAKE"); return true; } //----------------------------------------------------------------------------------- @@ -1133,7 +1132,7 @@ namespace nodetool { if(be.last_seen > local_time) { - LOG_PRINT_RED_L1("FOUND FUTURE peerlist for entry " << epee::string_tools::get_ip_string_from_int32(be.adr.ip) << ":" << be.adr.port << " last_seen: " << be.last_seen << ", local_time(on remote node):" << local_time); + MWARNING("FOUND FUTURE peerlist for entry " << epee::string_tools::get_ip_string_from_int32(be.adr.ip) << ":" << be.adr.port << " last_seen: " << be.last_seen << ", local_time(on remote node):" << local_time); return false; } be.last_seen += delta; @@ -1148,8 +1147,8 @@ namespace nodetool std::list<peerlist_entry> peerlist_ = peerlist; if(!fix_time_delta(peerlist_, local_time, delta)) return false; - LOG_PRINT_CCONTEXT_L2("REMOTE PEERLIST: TIME_DELTA: " << delta << ", remote peerlist size=" << peerlist_.size()); - LOG_PRINT_CCONTEXT_L3("REMOTE PEERLIST: " << print_peerlist_to_string(peerlist_)); + LOG_DEBUG_CC(context, "REMOTE PEERLIST: TIME_DELTA: " << delta << ", remote peerlist size=" << peerlist_.size()); + LOG_DEBUG_CC(context, "REMOTE PEERLIST: " << print_peerlist_to_string(peerlist_)); return m_peerlist.merge_peerlist(peerlist_); } //----------------------------------------------------------------------------------- @@ -1332,7 +1331,7 @@ namespace nodetool { if(ec) { - LOG_PRINT_CC_L2(ping_context, "back ping connect failed to " << ip << ":" << port); + LOG_WARNING_CC(ping_context, "back ping connect failed to " << ip << ":" << port); return false; } COMMAND_PING::request req; @@ -1351,13 +1350,13 @@ namespace nodetool { if(code <= 0) { - LOG_PRINT_CC_L2(ping_context, "Failed to invoke COMMAND_PING to " << ip << ":" << port << "(" << code << ", " << epee::levin::get_err_descr(code) << ")"); + LOG_ERROR_CC(ping_context, "Failed to invoke COMMAND_PING to " << ip << ":" << port << "(" << code << ", " << epee::levin::get_err_descr(code) << ")"); return; } if(rsp.status != PING_OK_RESPONSE_STATUS_TEXT || pr != rsp.peer_id) { - LOG_PRINT_CC_L2(ping_context, "back ping invoke wrong response \"" << rsp.status << "\" from" << ip << ":" << port << ", hsh_peer_id=" << pr_ << ", rsp.peer_id=" << rsp.peer_id); + LOG_ERROR_CC(ping_context, "back ping invoke wrong response \"" << rsp.status << "\" from" << ip << ":" << port << ", hsh_peer_id=" << pr_ << ", rsp.peer_id=" << rsp.peer_id); m_net_server.get_config_object().close(ping_context.m_connection_id); return; } @@ -1367,7 +1366,7 @@ namespace nodetool if(!inv_call_res) { - LOG_PRINT_CC_L2(ping_context, "back ping invoke failed to " << ip << ":" << port); + LOG_ERROR_CC(ping_context, "back ping invoke failed to " << ip << ":" << port); m_net_server.get_config_object().close(ping_context.m_connection_id); return false; } @@ -1375,7 +1374,7 @@ namespace nodetool }); if(!r) { - LOG_ERROR("Failed to call connect_async, network error."); + LOG_ERROR_CC(context, "Failed to call connect_async, network error."); } return r; } @@ -1394,7 +1393,7 @@ namespace nodetool { if(code < 0) { - LOG_PRINT_CC_RED(context_, "COMMAND_REQUEST_SUPPORT_FLAGS invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")", LOG_LEVEL_1); + LOG_ERROR_CC(context_, "COMMAND_REQUEST_SUPPORT_FLAGS invoke failed. (" << code << ", " << epee::levin::get_err_descr(code) << ")"); return; } @@ -1411,7 +1410,7 @@ namespace nodetool { if(!m_payload_handler.process_payload_sync_data(arg.payload_data, context, false)) { - LOG_ERROR_CCONTEXT("Failed to process_payload_sync_data(), dropping connection"); + LOG_ERROR_CC(context, "Failed to process_payload_sync_data(), dropping connection"); drop_connection(context); return 1; } @@ -1420,7 +1419,7 @@ namespace nodetool rsp.local_time = time(NULL); m_peerlist.get_peerlist_head(rsp.local_peerlist); m_payload_handler.get_payload_sync_data(rsp.payload_data); - LOG_PRINT_CCONTEXT_L2("COMMAND_TIMED_SYNC"); + LOG_DEBUG_CC(context, "COMMAND_TIMED_SYNC"); return 1; } //----------------------------------------------------------------------------------- @@ -1430,7 +1429,7 @@ namespace nodetool if(arg.node_data.network_id != m_network_id) { - LOG_PRINT_CCONTEXT_L1("WRONG NETWORK AGENT CONNECTED! id=" << epee::string_tools::get_str_from_guid_a(arg.node_data.network_id)); + LOG_INFO_CC(context, "WRONG NETWORK AGENT CONNECTED! id=" << epee::string_tools::get_str_from_guid_a(arg.node_data.network_id)); drop_connection(context); add_ip_fail(context.m_remote_ip); return 1; @@ -1438,7 +1437,7 @@ namespace nodetool if(!context.m_is_income) { - LOG_ERROR_CCONTEXT("COMMAND_HANDSHAKE came not from incoming connection"); + LOG_ERROR_CC(context, "COMMAND_HANDSHAKE came not from incoming connection"); drop_connection(context); add_ip_fail(context.m_remote_ip); return 1; @@ -1446,14 +1445,14 @@ namespace nodetool if(context.peer_id) { - LOG_ERROR_CCONTEXT("COMMAND_HANDSHAKE came, but seems that connection already have associated peer_id (double COMMAND_HANDSHAKE?)"); + LOG_ERROR_CC(context, "COMMAND_HANDSHAKE came, but seems that connection already have associated peer_id (double COMMAND_HANDSHAKE?)"); drop_connection(context); return 1; } if(!m_payload_handler.process_payload_sync_data(arg.payload_data, context, true)) { - LOG_ERROR_CCONTEXT("COMMAND_HANDSHAKE came, but process_payload_sync_data returned false, dropping connection."); + LOG_ERROR_CC(context, "COMMAND_HANDSHAKE came, but process_payload_sync_data returned false, dropping connection."); drop_connection(context); return 1; } @@ -1476,7 +1475,7 @@ namespace nodetool pe.last_seen = static_cast<int64_t>(last_seen); pe.id = peer_id_l; this->m_peerlist.append_with_peer_white(pe); - LOG_PRINT_CCONTEXT_L2("PING SUCCESS " << epee::string_tools::get_ip_string_from_int32(context.m_remote_ip) << ":" << port_l); + LOG_DEBUG_CC(context, "PING SUCCESS " << epee::string_tools::get_ip_string_from_int32(context.m_remote_ip) << ":" << port_l); }); } @@ -1489,14 +1488,14 @@ namespace nodetool m_peerlist.get_peerlist_head(rsp.local_peerlist); get_local_node_data(rsp.node_data); m_payload_handler.get_payload_sync_data(rsp.payload_data); - LOG_PRINT_CCONTEXT_GREEN("COMMAND_HANDSHAKE", LOG_LEVEL_1); + LOG_DEBUG_CC(context, "COMMAND_HANDSHAKE"); return 1; } //----------------------------------------------------------------------------------- template<class t_payload_net_handler> int node_server<t_payload_net_handler>::handle_ping(int command, COMMAND_PING::request& arg, COMMAND_PING::response& rsp, p2p_connection_context& context) { - LOG_PRINT_CCONTEXT_L2("COMMAND_PING"); + LOG_DEBUG_CC(context, "COMMAND_PING"); rsp.status = PING_OK_RESPONSE_STATUS_TEXT; rsp.peer_id = m_config.m_peer_id; return 1; @@ -1508,14 +1507,14 @@ namespace nodetool std::list<peerlist_entry> pl_white; std::list<peerlist_entry> pl_gray; m_peerlist.get_peerlist_full(pl_gray, pl_white); - LOG_PRINT_L0(ENDL << "Peerlist white:" << ENDL << print_peerlist_to_string(pl_white) << ENDL << "Peerlist gray:" << ENDL << print_peerlist_to_string(pl_gray) ); + MINFO(ENDL << "Peerlist white:" << ENDL << print_peerlist_to_string(pl_white) << ENDL << "Peerlist gray:" << ENDL << print_peerlist_to_string(pl_gray) ); return true; } //----------------------------------------------------------------------------------- template<class t_payload_net_handler> bool node_server<t_payload_net_handler>::log_connections() { - LOG_PRINT_L0("Connections: \r\n" << print_connections_container() ); + MINFO("Connections: \r\n" << print_connections_container() ); return true; } //----------------------------------------------------------------------------------- @@ -1539,13 +1538,13 @@ namespace nodetool template<class t_payload_net_handler> void node_server<t_payload_net_handler>::on_connection_new(p2p_connection_context& context) { - LOG_PRINT_L2("["<< epee::net_utils::print_connection_context(context) << "] NEW CONNECTION"); + MINFO("["<< epee::net_utils::print_connection_context(context) << "] NEW CONNECTION"); } //----------------------------------------------------------------------------------- template<class t_payload_net_handler> void node_server<t_payload_net_handler>::on_connection_close(p2p_connection_context& context) { - LOG_PRINT_L2("["<< epee::net_utils::print_connection_context(context) << "] CLOSE CONNECTION"); + MINFO("["<< epee::net_utils::print_connection_context(context) << "] CLOSE CONNECTION"); } template<class t_payload_net_handler> @@ -1595,10 +1594,8 @@ namespace nodetool { if(max == -1) { m_config.m_net_config.connections_count = P2P_DEFAULT_CONNECTIONS_COUNT; - epee::net_utils::data_logger::get_instance().add_data("peers_limit", m_config.m_net_config.connections_count); return true; } - epee::net_utils::data_logger::get_instance().add_data("peers_limit", max); m_config.m_net_config.connections_count = max; return true; } @@ -1632,7 +1629,7 @@ namespace nodetool limit *= 1024; epee::net_utils::connection<epee::levin::async_protocol_handler<p2p_connection_context> >::set_rate_up_limit( limit ); - LOG_PRINT_L0("Set limit-up to " << limit/1024 << " kB/s"); + MINFO("Set limit-up to " << limit/1024 << " kB/s"); return true; } @@ -1646,7 +1643,7 @@ namespace nodetool } limit *= 1024; epee::net_utils::connection<epee::levin::async_protocol_handler<p2p_connection_context> >::set_rate_down_limit( limit ); - LOG_PRINT_L0("Set limit-down to " << limit/1024 << " kB/s"); + MINFO("Set limit-down to " << limit/1024 << " kB/s"); return true; } @@ -1668,11 +1665,11 @@ namespace nodetool } if(!this->islimitup) { epee::net_utils::connection<epee::levin::async_protocol_handler<p2p_connection_context> >::set_rate_up_limit(limit_up); - LOG_PRINT_L0("Set limit-up to " << limit_up/1024 << " kB/s"); + MINFO("Set limit-up to " << limit_up/1024 << " kB/s"); } if(!this->islimitdown) { epee::net_utils::connection<epee::levin::async_protocol_handler<p2p_connection_context> >::set_rate_down_limit(limit_down); - LOG_PRINT_L0("Set limit-down to " << limit_down/1024 << " kB/s"); + MINFO("Set limit-down to " << limit_down/1024 << " kB/s"); } return true; |