1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

added get_dns_servers() to nmap_dns.cc/.h

This commit is contained in:
pgpickering
2008-08-21 09:24:35 +00:00
parent 3c9833b57c
commit a5b421e67c
2 changed files with 19 additions and 0 deletions

View File

@@ -1326,3 +1326,21 @@ void nmap_mass_rdns(Target **targets, int num_targets) {
firstrun=0; firstrun=0;
} }
// Returns a list of known DNS servers
std::list<std::string> get_dns_servers() {
// if, for example, run with -n, list is not initialized,
// run empty nmap_mass_rdns to do so
if(servs.size() == 0 && firstrun) {
nmap_mass_rdns(NULL, 0);
}
std::list<dns_server *>::iterator servI;
std::list<std::string> serverList;
dns_server *tpserv;
for(servI = servs.begin(); servI != servs.end(); servI++) {
tpserv = *servI;
serverList.push_back(inet_ntoa(tpserv->addr.sin_addr));
}
return serverList;
}

View File

@@ -103,3 +103,4 @@ const char *lookup_cached_host(u32 ip);
void free_dns_servers(); void free_dns_servers();
void free_etchosts(); void free_etchosts();
std::list<std::string> get_dns_servers();