[Fix] Use machine cahce for nmap results.
This commit is contained in:
parent
7b58ecc4d5
commit
cb7c5d8a95
@ -98,11 +98,20 @@ std::string ssh(Session& context, const std::string& ip) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string nmap(Session& context, const std::string& ip) {
|
std::string nmap(Session& context, const std::string& ip) {
|
||||||
long long machine_id = context.get_machine_manager()->get_machine_id_by_ip(ip);
|
INetworkBridge* bridge = context.get_network_bridge();
|
||||||
if(machine_id == 0) {
|
Machine* target_machine = bridge->get_machine_by_ip(ip);
|
||||||
|
|
||||||
|
if(!target_machine) {
|
||||||
return "nmap: Could not resolve host: " + ip;
|
return "nmap: Could not resolve host: " + ip;
|
||||||
}
|
}
|
||||||
auto services = context.get_db_manager()->services().get_for_machine(machine_id);
|
|
||||||
|
/* Read services from the cached machine object, not the DB. */
|
||||||
|
auto services = target_machine->services;
|
||||||
|
|
||||||
|
/* Release the machine from the cache if it's a remote machine. */
|
||||||
|
if(target_machine != context.get_session_machine()) {
|
||||||
|
bridge->release_machine(target_machine->id);
|
||||||
|
}
|
||||||
|
|
||||||
if(services.empty()) {
|
if(services.empty()) {
|
||||||
return "No open ports for " + ip;
|
return "No open ports for " + ip;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user