mirror of
https://github.com/rofl0r/proxychains-ng.git
synced 2025-09-02 13:56:59 +00:00
add sendto hook to handle MSG_FASTOPEN flag
This commit is contained in:
@ -95,6 +95,10 @@ typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *
|
||||
typedef int (*getnameinfo_t) (const struct sockaddr *, socklen_t, char *,
|
||||
socklen_t, char *, socklen_t, int);
|
||||
|
||||
typedef ssize_t (*sendto_t) (int sockfd, const void *buf, size_t len, int flags,
|
||||
const struct sockaddr *dest_addr, socklen_t addrlen);
|
||||
|
||||
|
||||
|
||||
extern connect_t true_connect;
|
||||
extern gethostbyname_t true_gethostbyname;
|
||||
|
@ -52,6 +52,7 @@ getaddrinfo_t true_getaddrinfo;
|
||||
freeaddrinfo_t true_freeaddrinfo;
|
||||
getnameinfo_t true_getnameinfo;
|
||||
gethostbyaddr_t true_gethostbyaddr;
|
||||
sendto_t true_sendto;
|
||||
|
||||
int tcp_read_time_out;
|
||||
int tcp_connect_time_out;
|
||||
@ -113,6 +114,7 @@ static void do_init(void) {
|
||||
proxychains_write_log(LOG_PREFIX "DLL init: proxychains-ng %s\n", proxychains_get_version());
|
||||
|
||||
SETUP_SYM(connect);
|
||||
SETUP_SYM(sendto);
|
||||
SETUP_SYM(gethostbyname);
|
||||
SETUP_SYM(getaddrinfo);
|
||||
SETUP_SYM(freeaddrinfo);
|
||||
@ -479,3 +481,18 @@ struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
||||
const struct sockaddr *dest_addr, socklen_t addrlen) {
|
||||
#ifdef MSG_FASTOPEN
|
||||
if (flags & MSG_FASTOPEN) {
|
||||
if (!connect(sockfd, dest_addr, addrlen) && errno != EINPROGRESS) {
|
||||
return -1;
|
||||
}
|
||||
dest_addr = NULL;
|
||||
addrlen = 0;
|
||||
flags &= ~MSG_FASTOPEN;
|
||||
}
|
||||
#endif
|
||||
return true_sendto(sockfd, buf, len, flags, dest_addr, addrlen);
|
||||
}
|
||||
|
Reference in New Issue
Block a user