mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Abstract nsock logging function to avoid nsock.h inclusion in output.h
This commit is contained in:
@@ -206,7 +206,7 @@ void FPNetworkControl::init(const char *ifname, devtype iftype) {
|
|||||||
if ((this->nsp = nsock_pool_new(NULL)) == NULL)
|
if ((this->nsp = nsock_pool_new(NULL)) == NULL)
|
||||||
fatal("Unable to obtain an Nsock pool");
|
fatal("Unable to obtain an Nsock pool");
|
||||||
|
|
||||||
nsock_set_log_function(nmap_nsock_stderr_logger);
|
nmap_set_nsock_logger();
|
||||||
nmap_adjust_loglevel(o.packetTrace());
|
nmap_adjust_loglevel(o.packetTrace());
|
||||||
|
|
||||||
nsock_pool_set_device(nsp, o.device);
|
nsock_pool_set_device(nsp, o.device);
|
||||||
|
|||||||
@@ -1190,7 +1190,7 @@ static void nmap_mass_rdns_core(Target **targets, int num_targets) {
|
|||||||
if ((dnspool = nsock_pool_new(NULL)) == NULL)
|
if ((dnspool = nsock_pool_new(NULL)) == NULL)
|
||||||
fatal("Unable to create nsock pool in %s()", __func__);
|
fatal("Unable to create nsock pool in %s()", __func__);
|
||||||
|
|
||||||
nsock_set_log_function(nmap_nsock_stderr_logger);
|
nmap_set_nsock_logger();
|
||||||
nmap_adjust_loglevel(o.packetTrace());
|
nmap_adjust_loglevel(o.packetTrace());
|
||||||
|
|
||||||
nsock_pool_set_device(dnspool, o.device);
|
nsock_pool_set_device(dnspool, o.device);
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ static nsock_pool new_pool (lua_State *L)
|
|||||||
nsock_pool *nspp;
|
nsock_pool *nspp;
|
||||||
|
|
||||||
/* configure logging */
|
/* configure logging */
|
||||||
nsock_set_log_function(nmap_nsock_stderr_logger);
|
nmap_set_nsock_logger();
|
||||||
nmap_adjust_loglevel(o.scriptTrace());
|
nmap_adjust_loglevel(o.scriptTrace());
|
||||||
|
|
||||||
nsock_pool_set_device(nsp, o.device);
|
nsock_pool_set_device(nsp, o.device);
|
||||||
|
|||||||
@@ -151,6 +151,7 @@
|
|||||||
#include "xml.h"
|
#include "xml.h"
|
||||||
#include "nbase.h"
|
#include "nbase.h"
|
||||||
#include "libnetutil/netutil.h"
|
#include "libnetutil/netutil.h"
|
||||||
|
#include <nsock.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -2782,7 +2783,7 @@ void nmap_adjust_loglevel(bool trace) {
|
|||||||
nsock_set_loglevel(nsock_loglevel);
|
nsock_set_loglevel(nsock_loglevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nmap_nsock_stderr_logger(const struct nsock_log_rec *rec) {
|
static void nmap_nsock_stderr_logger(const struct nsock_log_rec *rec) {
|
||||||
int elapsed_time;
|
int elapsed_time;
|
||||||
|
|
||||||
elapsed_time = TIMEVAL_MSEC_SUBTRACT(rec->time, *(o.getStartTime()));
|
elapsed_time = TIMEVAL_MSEC_SUBTRACT(rec->time, *(o.getStartTime()));
|
||||||
@@ -2790,3 +2791,7 @@ void nmap_nsock_stderr_logger(const struct nsock_log_rec *rec) {
|
|||||||
log_write(LOG_STDERR, "NSOCK %s [%.4fs] %s(): %s\n", nslog2str(rec->level),
|
log_write(LOG_STDERR, "NSOCK %s [%.4fs] %s(): %s\n", nslog2str(rec->level),
|
||||||
elapsed_time/1000.0, rec->func, rec->msg);
|
elapsed_time/1000.0, rec->func, rec->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nmap_set_nsock_logger() {
|
||||||
|
nsock_set_log_function(nmap_nsock_stderr_logger);
|
||||||
|
}
|
||||||
|
|||||||
3
output.h
3
output.h
@@ -173,7 +173,6 @@
|
|||||||
#ifndef NOLUA
|
#ifndef NOLUA
|
||||||
#include "nse_main.h"
|
#include "nse_main.h"
|
||||||
#endif
|
#endif
|
||||||
#include <nsock.h>
|
|
||||||
class PortList;
|
class PortList;
|
||||||
class Target;
|
class Target;
|
||||||
|
|
||||||
@@ -311,7 +310,7 @@ void printdatafilepaths();
|
|||||||
|
|
||||||
/* nsock logging interface */
|
/* nsock logging interface */
|
||||||
void nmap_adjust_loglevel(bool trace);
|
void nmap_adjust_loglevel(bool trace);
|
||||||
void nmap_nsock_stderr_logger(const struct nsock_log_rec *rec);
|
void nmap_set_nsock_logger();
|
||||||
|
|
||||||
#endif /* OUTPUT_H */
|
#endif /* OUTPUT_H */
|
||||||
|
|
||||||
|
|||||||
@@ -2851,7 +2851,7 @@ int service_scan(std::vector<Target *> &Targets) {
|
|||||||
if ((nsp = nsock_pool_new(SG)) == NULL) {
|
if ((nsp = nsock_pool_new(SG)) == NULL) {
|
||||||
fatal("%s() failed to create new nsock pool.", __func__);
|
fatal("%s() failed to create new nsock pool.", __func__);
|
||||||
}
|
}
|
||||||
nsock_set_log_function(nmap_nsock_stderr_logger);
|
nmap_set_nsock_logger();
|
||||||
nmap_adjust_loglevel(o.versionTrace());
|
nmap_adjust_loglevel(o.versionTrace());
|
||||||
|
|
||||||
nsock_pool_set_device(nsp, o.device);
|
nsock_pool_set_device(nsp, o.device);
|
||||||
|
|||||||
Reference in New Issue
Block a user