You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! Thanks for your awesome codes!
Here I have some questions about the accept function in src/desock.c. After writte the accept function ,I think all the accept will return a fake addr and port (0.0.0.0:9000) and addrlen which will have an influence on the normal request ?
intaccept(intsockfd, structsockaddr*addr, socklen_t*addrlen)
{
if (preeny_desock_did_accept)
exit(0);
preeny_desock_did_accept=1;
//initialize a sockaddr_in for the peerstructsockaddr_inpeer_addr;
memset(&peer_addr, '0', sizeof(structsockaddr_in));
//Set the contents in the peer's sock_addr. //Make sure the contents will simulate a real client that connects with the intercepted server, as the server may depend on the contents to make further decisions. //The followings set-up should be fine with Nginx.peer_addr.sin_family=AF_INET;
peer_addr.sin_addr.s_addr=htonl(INADDR_ANY);
peer_addr.sin_port=htons(9000);
//copy the initialized peer_addr back to the original sockaddr. Note the space for the original sockaddr, namely addr, has already been allocatedif (addr) memcpy(addr, &peer_addr, sizeof(structsockaddr_in));
if (preeny_socket_threads_to_front[sockfd]) returndup(sockfd);
elsereturnoriginal_accept(sockfd, addr, addrlen);
}
So I think we should change the if (preeny_socket_threads_to_front[sockfd]) like the following? If it is correct, I am glad to pull a request to update it.
intaccept(intsockfd, structsockaddr*addr, socklen_t*addrlen)
{
if (preeny_socket_threads_to_front[sockfd])
{
if (preeny_desock_did_accept)
exit(0);
preeny_desock_did_accept=1;
//initialize a sockaddr_in for the peerstructsockaddr_inpeer_addr;
memset(&peer_addr, '0', sizeof(structsockaddr_in));
//Set the contents in the peer's sock_addr. //Make sure the contents will simulate a real client that connects with the intercepted server, as the server may depend on the contents to make further decisions. //The followings set-up should be fine with Nginx.peer_addr.sin_family=AF_INET;
peer_addr.sin_addr.s_addr=htonl(INADDR_ANY);
peer_addr.sin_port=htons(9000);
//copy the initialized peer_addr back to the original sockaddr. Note the space for the original sockaddr, namely addr, has already been allocatedif (addr) memcpy(addr, &peer_addr, sizeof(structsockaddr_in));
returndup(sockfd);
}
elsereturnoriginal_accept(sockfd, addr, addrlen);
}
The text was updated successfully, but these errors were encountered:
Hello! Thanks for your awesome codes!
Here I have some questions about the accept function in src/desock.c. After writte the accept function ,I think all the accept will return a fake addr and port (0.0.0.0:9000) and addrlen which will have an influence on the normal request ?
So I think we should change the
if (preeny_socket_threads_to_front[sockfd])
like the following? If it is correct, I am glad to pull a request to update it.The text was updated successfully, but these errors were encountered: