mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Support unix socket for parent and tcppm; abstract (fileless) unix sockets for linux support
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
Use unix:/path/to/socket, e.g. tcppm 1234 unix:/path/to/socket 1234 Under linux abstract sockets are supported with '@' prefix, e.g. parent 1000 http unix:@virtual.3proxy.socket 1111 Destination port numbers are not used in tcppm/parent, but you must specify any positive value to match the syntaxis.
This commit is contained in:
1 parent
3f92dc7355
commit
878a432481
6 files changed
+77
-27
No files matched your search
+35
-6
@@ -62,17 +62,34 @@ int mutex_unlock(int *val)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_UN
|
||||
void make_un(const unsigned char *path, struct sockaddr_un * sun){
|
||||
memset(sun, 0, sizeof(*sun));
|
||||
sun->sun_family = AF_UNIX;
|
||||
strncpy(sun->sun_path, (char *)path, sizeof(sun->sun_path) - 1);
|
||||
if(*path == '@')*sun->sun_path = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int myinet_ntop(int af, void *src, char *dst, socklen_t size){
|
||||
#ifdef WITH_UN
|
||||
if(af == AF_UNIX){
|
||||
struct sockaddr_un *sun = (struct sockaddr_un *)src;
|
||||
int ephemeral = 0;
|
||||
char *path = sun->sun_path;
|
||||
char *basename = strrchr(path, '/');
|
||||
char *basename;
|
||||
if(!path[0] && path[1]){
|
||||
ephemeral = 1;
|
||||
*dst++ = '@';
|
||||
path++;
|
||||
}
|
||||
basename = strrchr(path, '/');
|
||||
if(basename) basename++;
|
||||
else basename = path;
|
||||
if(size > 0){
|
||||
strncpy(dst, basename, (size > 40) ? 40 : size - 1);
|
||||
dst[((size > 40) ? 40 : size - 1)] = 0;
|
||||
strncpy(dst, basename, (size > 40) ? 40 : size - (ephemeral + 1));
|
||||
dst[((size > 40) ? 40 : size - (ephemeral + 1))] = 0;
|
||||
}
|
||||
return (int)strlen(dst);
|
||||
}
|
||||
@@ -538,14 +555,14 @@ int connectwithpoll(struct clientparam *param, SOCKET sock, struct sockaddr *sa,
|
||||
fcntl(sock,F_SETFL, O_NONBLOCK | fcntl(sock,F_GETFL));
|
||||
#endif
|
||||
if(param?param->srv->so._connect(param->sostate, sock,sa,size) : so._connect(so.state, sock,sa,size)) {
|
||||
if(errno != EAGAIN && errno != EINPROGRESS) return (13);
|
||||
if(errno != EAGAIN && errno != EINPROGRESS) return 13;
|
||||
}
|
||||
if(!errno) return 0;
|
||||
memset(fds, 0, sizeof(fds));
|
||||
fds[0].fd = sock;
|
||||
fds[0].events = POLLOUT;
|
||||
if((param?param->srv->so._poll(param->sostate, fds, 1, to*1000):so._poll(so.state, fds, 1, to*1000)) <= 0 || !(fds[0].revents & POLLOUT) || (fds[0].revents & (POLLERR|POLLHUP))) {
|
||||
return (13);
|
||||
return 13;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -575,8 +592,17 @@ int doconnect(struct clientparam * param){
|
||||
memcpy(SAADDR(¶m->sinsr), SAADDR(¶m->req), SAADDRLEN(¶m->req));
|
||||
}
|
||||
if(!*SAPORT(¶m->sinsr))*SAPORT(¶m->sinsr) = *SAPORT(¶m->req);
|
||||
if ((param->remsock=param->srv->so._socket(param->sostate, SASOCK(¶m->sinsr), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);}
|
||||
if ((param->remsock=param->srv->so._socket(param->sostate, SASOCK(¶m->sinsr), SOCK_STREAM,
|
||||
#ifdef WITH_UN
|
||||
*SAFAMILY(¶m->sinsr) == AF_UNIX? 0 :
|
||||
#endif
|
||||
IPPROTO_TCP
|
||||
)) == INVALID_SOCKET) {return (11);}
|
||||
if(SAISNULL(¶m->sinsl)){
|
||||
#ifdef WITH_UN
|
||||
if(*SAFAMILY(¶m->sinsr) == AF_UNIX) param->sinsl = param->sinsr;
|
||||
else
|
||||
#endif
|
||||
#ifndef NOIPV6
|
||||
if(*SAFAMILY(¶m->sinsr) == AF_INET6) param->sinsl = param->srv->extsa6;
|
||||
else
|
||||
@@ -616,6 +642,9 @@ int doconnect(struct clientparam * param){
|
||||
if(*SAFAMILY(¶m->sinsl) == AF_INET6 && param->srv->so._setsockopt(param->sostate, param->remsock, IPPROTO_IPV6, IPV6_BOUND_IF, &idx, sizeof(idx))) return 12;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#ifdef WITH_UN
|
||||
if(*SAFAMILY(¶m->sinsl) != AF_UNIX)
|
||||
#endif
|
||||
if(param->srv->so._bind(param->sostate, param->remsock, (struct sockaddr*)¶m->sinsl, SASIZE(¶m->sinsl))==-1) {
|
||||
return 12;
|
||||
|
||||
Reference in new issue
Block a user