mirror of
https://github.com/rofl0r/proxychains-ng
synced 2025-01-25 02:45:05 +08:00
put INIT() call consistently at beginning of hooked funcs
This commit is contained in:
parent
afe6171cad
commit
d900b090fe
@ -308,7 +308,9 @@ int close(int fd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int connect(int sock, const struct sockaddr *addr, unsigned int len) {
|
int connect(int sock, const struct sockaddr *addr, unsigned int len) {
|
||||||
|
INIT();
|
||||||
PFUNC();
|
PFUNC();
|
||||||
|
|
||||||
int socktype = 0, flags = 0, ret = 0;
|
int socktype = 0, flags = 0, ret = 0;
|
||||||
socklen_t optlen = 0;
|
socklen_t optlen = 0;
|
||||||
ip_type dest_ip;
|
ip_type dest_ip;
|
||||||
@ -318,7 +320,6 @@ int connect(int sock, const struct sockaddr *addr, unsigned int len) {
|
|||||||
unsigned short port;
|
unsigned short port;
|
||||||
size_t i;
|
size_t i;
|
||||||
int remote_dns_connect = 0;
|
int remote_dns_connect = 0;
|
||||||
INIT();
|
|
||||||
optlen = sizeof(socktype);
|
optlen = sizeof(socktype);
|
||||||
getsockopt(sock, SOL_SOCKET, SO_TYPE, &socktype, &optlen);
|
getsockopt(sock, SOL_SOCKET, SO_TYPE, &socktype, &optlen);
|
||||||
if(!(SOCKFAMILY(*addr) == AF_INET && socktype == SOCK_STREAM))
|
if(!(SOCKFAMILY(*addr) == AF_INET && socktype == SOCK_STREAM))
|
||||||
@ -365,7 +366,6 @@ int connect(int sock, const struct sockaddr *addr, unsigned int len) {
|
|||||||
static struct gethostbyname_data ghbndata;
|
static struct gethostbyname_data ghbndata;
|
||||||
struct hostent *gethostbyname(const char *name) {
|
struct hostent *gethostbyname(const char *name) {
|
||||||
INIT();
|
INIT();
|
||||||
|
|
||||||
PDEBUG("gethostbyname: %s\n", name);
|
PDEBUG("gethostbyname: %s\n", name);
|
||||||
|
|
||||||
if(proxychains_resolver)
|
if(proxychains_resolver)
|
||||||
@ -377,45 +377,36 @@ struct hostent *gethostbyname(const char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
|
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
INIT();
|
INIT();
|
||||||
|
|
||||||
PDEBUG("getaddrinfo: %s %s\n", node ? node : "null", service ? service : "null");
|
PDEBUG("getaddrinfo: %s %s\n", node ? node : "null", service ? service : "null");
|
||||||
|
|
||||||
if(proxychains_resolver)
|
if(proxychains_resolver)
|
||||||
ret = proxy_getaddrinfo(node, service, hints, res);
|
return proxy_getaddrinfo(node, service, hints, res);
|
||||||
else
|
else
|
||||||
ret = true_getaddrinfo(node, service, hints, res);
|
return true_getaddrinfo(node, service, hints, res);
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeaddrinfo(struct addrinfo *res) {
|
void freeaddrinfo(struct addrinfo *res) {
|
||||||
INIT();
|
INIT();
|
||||||
|
|
||||||
PDEBUG("freeaddrinfo %p \n", res);
|
PDEBUG("freeaddrinfo %p \n", res);
|
||||||
|
|
||||||
if(!proxychains_resolver)
|
if(!proxychains_resolver)
|
||||||
true_freeaddrinfo(res);
|
true_freeaddrinfo(res);
|
||||||
else
|
else
|
||||||
proxy_freeaddrinfo(res);
|
proxy_freeaddrinfo(res);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int pc_getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
int pc_getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
||||||
char *host, socklen_t hostlen, char *serv,
|
char *host, socklen_t hostlen, char *serv,
|
||||||
socklen_t servlen, int flags)
|
socklen_t servlen, int flags)
|
||||||
{
|
{
|
||||||
char ip_buf[16];
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
INIT();
|
INIT();
|
||||||
|
|
||||||
PFUNC();
|
PFUNC();
|
||||||
|
|
||||||
|
char ip_buf[16];
|
||||||
|
|
||||||
if(!proxychains_resolver) {
|
if(!proxychains_resolver) {
|
||||||
ret = true_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
|
return true_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
|
||||||
} else {
|
} else {
|
||||||
if(salen < sizeof(struct sockaddr_in) || SOCKFAMILY(*sa) != AF_INET)
|
if(salen < sizeof(struct sockaddr_in) || SOCKFAMILY(*sa) != AF_INET)
|
||||||
return EAI_FAMILY;
|
return EAI_FAMILY;
|
||||||
@ -429,20 +420,19 @@ int pc_getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
|||||||
return EAI_OVERFLOW;
|
return EAI_OVERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
|
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
|
||||||
|
INIT();
|
||||||
|
PDEBUG("TODO: proper gethostbyaddr hook\n");
|
||||||
|
|
||||||
static char buf[16];
|
static char buf[16];
|
||||||
static char ipv4[4];
|
static char ipv4[4];
|
||||||
static char *list[2];
|
static char *list[2];
|
||||||
static char *aliases[1];
|
static char *aliases[1];
|
||||||
static struct hostent he;
|
static struct hostent he;
|
||||||
|
|
||||||
INIT();
|
|
||||||
|
|
||||||
PDEBUG("TODO: proper gethostbyaddr hook\n");
|
|
||||||
|
|
||||||
if(!proxychains_resolver)
|
if(!proxychains_resolver)
|
||||||
return true_gethostbyaddr(addr, len, type);
|
return true_gethostbyaddr(addr, len, type);
|
||||||
else {
|
else {
|
||||||
@ -471,6 +461,8 @@ struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
|
|||||||
|
|
||||||
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
||||||
const struct sockaddr *dest_addr, socklen_t addrlen) {
|
const struct sockaddr *dest_addr, socklen_t addrlen) {
|
||||||
|
INIT();
|
||||||
|
PFUNC();
|
||||||
if (flags & MSG_FASTOPEN) {
|
if (flags & MSG_FASTOPEN) {
|
||||||
if (!connect(sockfd, dest_addr, addrlen) && errno != EINPROGRESS) {
|
if (!connect(sockfd, dest_addr, addrlen) && errno != EINPROGRESS) {
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user