mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Support namespaces for UDP in socks
This commit is contained in:
1 parent
ff15a8d480
commit
7871279fae
3 files changed
+46
-5
No files matched your search
+15
@@ -7,6 +7,9 @@
|
||||
*/
|
||||
|
||||
#include "proxy.h"
|
||||
#ifdef __linux__
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
#define RETURN(xxx) { param->res = xxx; goto CLEANRET; }
|
||||
|
||||
@@ -188,6 +191,12 @@ void * sockschild(struct clientparam* param) {
|
||||
param->sinsl = *SAFAMILY(¶m->req)==AF_INET6? param->srv->extsa6 : param->srv->extsa;
|
||||
#else
|
||||
param->sinsl = param->srv->extsa;
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
if(command == 3 && param->srv->o_nsfd >= 0) {
|
||||
if(param->srv->saved_nsfd >= 0 && setns(param->srv->saved_nsfd, CLONE_NEWNET)) {RETURN(11);}
|
||||
if(setns(param->srv->o_nsfd, CLONE_NEWNET)) {RETURN(11);}
|
||||
}
|
||||
#endif
|
||||
if ((param->remsock=param->srv->so._socket(param->sostate, SASOCK(¶m->req), command == 2? SOCK_STREAM:SOCK_DGRAM, command == 2?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) {RETURN (11);}
|
||||
param->operation = command == 2?BIND:UDPASSOC;
|
||||
@@ -242,6 +251,12 @@ fflush(stderr);
|
||||
param->srv->so._getsockname(param->sostate, param->remsock, (struct sockaddr *)¶m->sinsl, &sasize);
|
||||
if(command == 3) {
|
||||
param->ctrlsock = param->clisock;
|
||||
#ifdef __linux__
|
||||
if(param->srv->i_nsfd >= 0) {
|
||||
if(param->srv->saved_nsfd >= 0 && setns(param->srv->saved_nsfd, CLONE_NEWNET)) {RETURN(11);}
|
||||
if(setns(param->srv->i_nsfd, CLONE_NEWNET)) {RETURN(11);}
|
||||
}
|
||||
#endif
|
||||
param->clisock = param->srv->so._socket(param->sostate, SASOCK(¶m->sincr), SOCK_DGRAM, IPPROTO_UDP);
|
||||
if(param->clisock == INVALID_SOCKET) {RETURN(11);}
|
||||
sin = param->sincl;
|
||||
|
||||
Reference in new issue
Block a user