1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-15 12:19:02 +00:00

Added a new NSE_STATUS_PROXYERROR status type to report proxy-related errors

back to caller.
This commit is contained in:
henri
2013-04-22 19:32:29 +00:00
parent da1559b237
commit c9d237f26b
3 changed files with 21 additions and 15 deletions

View File

@@ -322,8 +322,9 @@ enum nse_status {
nspool is being deleted -- you should free up any nspool is being deleted -- you should free up any
resources you have allocated and exit. Don't you resources you have allocated and exit. Don't you
dare make any more async nsock calls! */ dare make any more async nsock calls! */
NSE_STATUS_EOF /* We got EOF and NO DATA -- if we got data first, NSE_STATUS_EOF, /* We got EOF and NO DATA -- if we got data first,
SUCCESS is reported (see nse_eof()). */ SUCCESS is reported (see nse_eof()). */
NSE_STATUS_PROXYERROR
}; };
enum nse_status nse_status(nsock_event nse); enum nse_status nse_status(nsock_event nse);

View File

@@ -500,6 +500,7 @@ const char *nse_status2str(enum nse_status status) {
case NSE_STATUS_CANCELLED: return "CANCELLED"; case NSE_STATUS_CANCELLED: return "CANCELLED";
case NSE_STATUS_KILL: return "KILL"; case NSE_STATUS_KILL: return "KILL";
case NSE_STATUS_EOF: return "EOF"; case NSE_STATUS_EOF: return "EOF";
case NSE_STATUS_PROXYERROR: return "PROXY ERROR";
default: default:
return "UNKNOWN!"; return "UNKNOWN!";
} }

View File

@@ -428,32 +428,36 @@ void forward_event(nsock_pool nspool, nsock_event nsevent, void *udata) {
msevent *nse = (msevent *)nsevent; msevent *nse = (msevent *)nsevent;
enum nse_type cached_type; enum nse_type cached_type;
enum nse_status cached_status; enum nse_status cached_status;
cached_type = nse->type; cached_type = nse->type;
cached_status = nse->status; cached_status = nse->status;
nse->type = NSE_TYPE_CONNECT; nse->type = NSE_TYPE_CONNECT;
nse->status = NSE_STATUS_SUCCESS;
if (nse->status != NSE_STATUS_SUCCESS)
nse->status = NSE_STATUS_PROXYERROR;
if (nsp->tracelevel > 0) if (nsp->tracelevel > 0)
nsock_trace(nsp, "Forwarding event upstream: SUCCESS TCP connect (IOD #%li) EID %li", nsock_trace(nsp, "Forwarding event upstream: TCP connect %s (IOD #%li) EID %li",
nse->iod->id, nse->id); nse_status2str(nse->status), nse->iod->id, nse->id);
nse->iod->px_ctx->target_handler(nsp, nse, udata); nse->iod->px_ctx->target_handler(nsp, nse, udata);
nse->type = cached_type; nse->type = cached_type;
nse->status = cached_status; nse->status = cached_status;
} }
void nsock_proxy_ev_dispatch(nsock_pool nspool, nsock_event nsevent, void *udata) { void nsock_proxy_ev_dispatch(nsock_pool nspool, nsock_event nsevent, void *udata) {
msevent *nse = (msevent *)nsevent; msevent *nse = (msevent *)nsevent;
struct proxy_node *current;
if (nse->status != NSE_STATUS_SUCCESS) if (nse->status == NSE_STATUS_SUCCESS) {
fatal("Error, but this is debug only!"); struct proxy_node *current;
current = proxy_ctx_node_current(nse->iod->px_ctx); current = proxy_ctx_node_current(nse->iod->px_ctx);
assert(current); assert(current);
current->ops->handler(nspool, nsevent, udata); current->ops->handler(nspool, nsevent, udata);
} else {
forward_event(nspool, nsevent, udata);
}
} }