diff --git a/FPEngine.cc b/FPEngine.cc index 22c50d1f8..f8d628089 100644 --- a/FPEngine.cc +++ b/FPEngine.cc @@ -441,7 +441,7 @@ void FPNetworkControl::probe_transmission_handler(nsock_pool nsp, nsock_event ns } else if (status == NSE_STATUS_EOF) { if (o.debugging) log_write(LOG_PLAIN, "probe_transmission_handler(): EOF\n"); - } else if (status == NSE_STATUS_ERROR) { + } else if (status == NSE_STATUS_ERROR || status == NSE_STATUS_PROXYERROR) { if (o.debugging) log_write(LOG_PLAIN, "probe_transmission_handler(): %s failed: %s\n", nse_type2str(type), strerror(socket_errno())); } else if (status == NSE_STATUS_TIMEOUT) { @@ -566,7 +566,7 @@ void FPNetworkControl::response_reception_handler(nsock_pool nsp, nsock_event ns } else if (status == NSE_STATUS_EOF) { if (o.debugging) log_write(LOG_PLAIN, "response_reception_handler(): EOF\n"); - } else if (status == NSE_STATUS_ERROR) { + } else if (status == NSE_STATUS_ERROR || NSE_STATUS_PROXYERROR) { if (o.debugging) log_write(LOG_PLAIN, "response_reception_handler(): %s failed: %s\n", nse_type2str(type), strerror(socket_errno())); } else if (status == NSE_STATUS_TIMEOUT) { diff --git a/nse_nsock.cc b/nse_nsock.cc index 662192163..c05a33a4b 100644 --- a/nse_nsock.cc +++ b/nse_nsock.cc @@ -331,6 +331,7 @@ static void status (lua_State *L, enum nse_status status) case NSE_STATUS_EOF: case NSE_STATUS_ERROR: case NSE_STATUS_TIMEOUT: + case NSE_STATUS_PROXYERROR: lua_pushnil(L); lua_pushstring(L, nse_status2str(status)); nse_restore(L, 2); diff --git a/service_scan.cc b/service_scan.cc index 1c7400299..52ea1bd3d 100644 --- a/service_scan.cc +++ b/service_scan.cc @@ -2253,23 +2253,31 @@ static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *m send_probe_text(nsp, nsi, svc, probe); // Now let us read any results nsock_read(nsp, nsi, servicescan_read_handler, svc->probe_timemsleft(probe, nsock_gettimeofday()), svc); - } else if (status == NSE_STATUS_TIMEOUT || status == NSE_STATUS_ERROR) { - // This is not good. The connect() really shouldn't generally - // be timing out like that. We'll mark this svc as incomplete - // and move it to the finished bin. - if (o.debugging) - error("Got nsock CONNECT response with status %s - aborting this service", nse_status2str(status)); - end_svcprobe(nsp, PROBESTATE_INCOMPLETE, SG, svc, nsi); - } else if (status == NSE_STATUS_KILL) { - /* User probablby specified host_timeout and so the service scan is - shutting down */ - end_svcprobe(nsp, PROBESTATE_INCOMPLETE, SG, svc, nsi); - return; - } else fatal("Unexpected nsock status (%d) returned for connection attempt", (int) status); + } else { + switch(status) { + case NSE_STATUS_TIMEOUT: + case NSE_STATUS_ERROR: + case NSE_STATUS_PROXYERROR: + // This is not good. The connect() really shouldn't generally + // be timing out like that. We'll mark this svc as incomplete + // and move it to the finished bin. + if (o.debugging) + error("Got nsock CONNECT response with status %s - aborting this service", nse_status2str(status)); + end_svcprobe(nsp, PROBESTATE_INCOMPLETE, SG, svc, nsi); + break; + + case NSE_STATUS_KILL: + /* User probablby specified host_timeout and so the service scan is + * shutting down */ + end_svcprobe(nsp, PROBESTATE_INCOMPLETE, SG, svc, nsi); + return; + default: + fatal("Unexpected nsock status (%d) returned for connection attempt", (int)status); + } + } // We may have room for more pr0bes! launchSomeServiceProbes(nsp, SG); - return; } @@ -2306,7 +2314,7 @@ static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *myd return; } - if (status == NSE_STATUS_ERROR) { + if (status == NSE_STATUS_ERROR || status == NSE_STATUS_PROXYERROR) { err = nse_errorcode(nse); error("Got nsock WRITE error #%d (%s)", err, strerror(err)); }