diff --git a/include/Host.h b/include/Host.h index b7299ec41d..63ec1acd96 100644 --- a/include/Host.h +++ b/include/Host.h @@ -45,6 +45,7 @@ class Host : public GenericHost { IpAddress ip; Mutex *m; Mac *mac; + u_int8_t num_resolve_attempts; time_t nextResolveAttempt, nextSitesUpdate; #ifdef NTOPNG_PRO CountMinSketch *sent_to_sketch, *rcvd_from_sketch; diff --git a/src/Host.cpp b/src/Host.cpp index a3aed9c64f..dd027845b9 100644 --- a/src/Host.cpp +++ b/src/Host.cpp @@ -132,7 +132,7 @@ void Host::initialize(u_int8_t _mac[6], u_int16_t _vlanId, bool init_all) { mac->incUses(); drop_all_host_traffic = false, dump_host_traffic = false, dhcpUpdated = false, - deviceIP = 0, deviceIfIdx = 0; + deviceIP = 0, deviceIfIdx = 0, num_resolve_attempts = 0; max_new_flows_sec_threshold = CONST_MAX_NEW_FLOWS_SECOND; max_num_syn_sec_threshold = CONST_MAX_NUM_SYN_PER_SECOND; max_num_active_flows = CONST_MAX_NUM_HOST_ACTIVE_FLOWS, good_low_flow_detected = false; @@ -642,11 +642,13 @@ char* Host::get_name(char *buf, u_int buf_len, bool force_resolution_if_not_foun int rc; time_t now = time(NULL); - if(nextResolveAttempt && ((nextResolveAttempt > now) || (nextResolveAttempt == (time_t)-1))) { + if(nextResolveAttempt + && ((num_resolve_attempts > 1) || (nextResolveAttempt > now) || (nextResolveAttempt == (time_t)-1))) { return(symbolic_name); } else nextResolveAttempt = ntop->getPrefs()->is_dns_resolution_enabled() ? now + MIN_HOST_RESOLUTION_FREQUENCY : (time_t)-1; + num_resolve_attempts++; addr = ip.print(buf, buf_len); if((symbolic_name != NULL) && strcmp(symbolic_name, addr))