4545#define SOCKFAMILY (x ) (satosin(x)->sin_family)
4646#define MAX_CHAIN 512
4747
48+
49+
50+
51+
52+
53+
54+
55+ #include <stdio.h>
56+ #include <stdlib.h>
57+ #include <unistd.h>
58+ #include <dlfcn.h>
59+ #include <sys/types.h>
60+ #include <sys/socket.h>
61+ #include <string.h>
62+ #include <strings.h>
63+ #include <sys/types.h>
64+ #include <netinet/in.h>
65+ #include <arpa/inet.h>
66+ #include <sys/poll.h>
67+ #include <sys/time.h>
68+ #include <pwd.h>
69+ #include <errno.h>
70+ #include <fcntl.h>
71+ #include <stdarg.h>
72+ #include <resolv.h>
73+
74+
75+
4876connect_t true_connect ;
4977gethostbyname_t true_gethostbyname ;
5078getaddrinfo_t true_getaddrinfo ;
@@ -383,6 +411,18 @@ int connect(int sock, const struct sockaddr *addr, socklen_t len) {
383411 }
384412 }
385413 }
414+
415+ //Rejecting non local udp
416+ if (socktype == SOCK_DGRAM ){
417+ if (proxybound_allow_leak ) {
418+ PDEBUG ("allowing unproxified udp connect()\n" );
419+ return true_connect (sock , addr , len );
420+ } else {
421+ PDEBUG ("blocking unproxified udp connect()\n" );
422+ //exit(0);
423+ return -1 ;
424+ }
425+ }
386426
387427 flags = fcntl (sock , F_GETFL , 0 );
388428 if (flags & O_NONBLOCK )
@@ -401,6 +441,19 @@ int connect(int sock, const struct sockaddr *addr, socklen_t len) {
401441 return ret ;
402442}
403443
444+ //TODO: DNS LEAK: OTHER RESOLVER FUNCTION
445+ //realresinit = dlsym(lib, "res_init");
446+ //realresquery = dlsym(lib, "res_query");
447+ //realressend = dlsym(lib, "res_send");
448+ //realresquerydomain = dlsym(lib, "res_querydomain");
449+ //realressearch = dlsym(lib, "res_search");
450+ //realgethostbyaddr = dlsym(lib, "gethostbyaddr"); //Needs rewrite
451+ //realgetipnodebyname = dlsym(lib, "getipnodebyname");
452+
453+ //UDP & DNS LEAK
454+ //realsendto = dlsym(lib, "sendto");
455+ //realsendmsg = dlsym(lib, "sendmsg");
456+
404457static struct gethostbyname_data ghbndata ;
405458
406459struct hostent * gethostbyname (const char * name ) {
0 commit comments