mirror of
https://github.com/nmap/nmap.git
synced 2025-12-20 14:39:02 +00:00
Design improvements.
Externally: The calling application can build a proxychain object and assign it to one (or more) NSP. Once a NSP get assigned a proxychain it's not possible to remove it so that consistency is (should be...) ensured. Internally: An IOD comes with a proxychain context structure storing the whole tunnel state. Also each proxy type now has a table of associated functions to use as hooks for TCP connects(), read() and write() requests. As a result, adding support of new proxy type should be easier. Code also gains readability in comparison to large switch/cases that redirect the execution flow according to the given proxy type.
This commit is contained in:
@@ -66,6 +66,9 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
extern struct proxy_actions *ProxyActions;
|
||||
|
||||
|
||||
/* Create the actual socket (nse->iod->sd) underlying the iod. This unblocks the
|
||||
* socket, binds to the localaddr address, sets IP options, and sets the
|
||||
* broadcast flag. Trying to change these functions after making this call will
|
||||
@@ -266,15 +269,7 @@ nsock_event_id nsock_connect_tcp(nsock_pool nsp, nsock_iod ms_iod, nsock_ev_hand
|
||||
msiod *nsi = (msiod *)ms_iod;
|
||||
|
||||
if (nsi->px_ctx) {
|
||||
memcpy(&nsi->px_ctx->target_ss, saddr, sslen);
|
||||
nsi->px_ctx->target_sslen = sslen;
|
||||
nsi->px_ctx->target_port = port;
|
||||
nsi->px_ctx->target_handler = handler;
|
||||
|
||||
saddr = (struct sockaddr *)&nsi->px_ctx->px_current->ss;
|
||||
sslen = nsi->px_ctx->px_current->sslen;
|
||||
port = nsi->px_ctx->px_current->port;
|
||||
handler = nsock_proxy_ev_handler;
|
||||
return IOD_PX_TCP_CONNECT(nsi)(nsp, ms_iod, handler, timeout_msecs, userdata, saddr, sslen, port);
|
||||
}
|
||||
|
||||
return nsock_connect_tcp_direct(nsp, ms_iod, handler, timeout_msecs, userdata, saddr, sslen, port);
|
||||
|
||||
Reference in New Issue
Block a user