mirror of
https://github.com/rofl0r/proxychains-ng
synced 2025-01-23 01:12:59 +08:00
add uv_close hook
This commit is contained in:
parent
2eb03d3719
commit
65ab050bc2
@ -20,6 +20,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <uv.h>
|
||||
|
||||
#ifndef __CORE_HEADER
|
||||
#define __CORE_HEADER
|
||||
@ -151,6 +152,7 @@ void proxychains_write_log(char *str, ...);
|
||||
|
||||
typedef int (*close_t)(int);
|
||||
typedef int (*close_range_t)(unsigned, unsigned, int);
|
||||
typedef void (*uv_close_t)(uv_handle_t* , uv_close_cb);
|
||||
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
|
||||
typedef struct hostent* (*gethostbyname_t)(const char *);
|
||||
typedef int (*freeaddrinfo_t)(struct addrinfo *);
|
||||
@ -197,6 +199,7 @@ extern getpeername_t true_getpeername;
|
||||
extern read_t true_read;
|
||||
extern write_t true_write;
|
||||
extern close_t true_close;
|
||||
extern uv_close_t true_uv_close;
|
||||
|
||||
struct gethostbyname_data {
|
||||
struct hostent hostent_space;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <pthread.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
|
||||
@ -63,6 +64,7 @@ connect_t true___xnet_connect;
|
||||
|
||||
close_t true_close;
|
||||
close_range_t true_close_range;
|
||||
uv_close_t true_uv_close;
|
||||
connect_t true_connect;
|
||||
gethostbyname_t true_gethostbyname;
|
||||
getaddrinfo_t true_getaddrinfo;
|
||||
@ -647,6 +649,41 @@ HOOKFUNC(int, close, int fd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
HOOKFUNC(void, uv_close, uv_handle_t* handle, uv_close_cb close_cb){
|
||||
PFUNC();
|
||||
|
||||
switch (handle->type)
|
||||
{
|
||||
case UV_UDP:
|
||||
int fd = ((uv_udp_t*)handle)->io_watcher.fd;
|
||||
|
||||
/***** UDP STUFF *******/
|
||||
//PDEBUG("checking if a relay chain is opened for fd %d\n", fd);
|
||||
udp_relay_chain* relay_chain = NULL;
|
||||
|
||||
PDEBUG("waiting for mutex\n");
|
||||
MUTEX_LOCK(&relay_chains_mutex);
|
||||
PDEBUG("got mutex\n");
|
||||
relay_chain = get_relay_chain(relay_chains, fd);
|
||||
if(NULL != relay_chain){
|
||||
PDEBUG("fd %d corresponds to chain %x, closing it\n", fd, relay_chain);
|
||||
free_relay_chain_contents(relay_chain);
|
||||
del_relay_chain(&relay_chains, relay_chain);
|
||||
PDEBUG("chain %x corresponding to fd %d closed\n", relay_chain, fd);
|
||||
DUMP_RELAY_CHAINS_LIST(relay_chains);
|
||||
}
|
||||
MUTEX_UNLOCK(&relay_chains_mutex);
|
||||
/***** END UDP STUFF *******/
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
return true_uv_close(handle, close_cb);
|
||||
|
||||
}
|
||||
|
||||
static int is_v4inv6(const struct in6_addr *a) {
|
||||
return !memcmp(a->s6_addr, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
|
||||
}
|
||||
@ -2240,6 +2277,7 @@ static void setup_hooks(void) {
|
||||
#endif
|
||||
SETUP_SYM(close);
|
||||
SETUP_SYM_OPTIONAL(close_range);
|
||||
SETUP_SYM_OPTIONAL(uv_close);
|
||||
}
|
||||
|
||||
#ifdef MONTEREY_HOOKING
|
||||
|
Loading…
Reference in New Issue
Block a user