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
+14
-14
@@ -407,10 +407,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
case 'i':
|
||||
#ifdef WITH_UN
|
||||
if(!strncmp((char *)argv[i]+2, "unix:", 5)){
|
||||
struct sockaddr_un *sun = (struct sockaddr_un *)&srv.intsa;
|
||||
memset(sun, 0, sizeof(*sun));
|
||||
sun->sun_family = AF_UNIX;
|
||||
strncpy(sun->sun_path, (char *)argv[i] + 7, sizeof(sun->sun_path) - 1);
|
||||
make_un((unsigned char *)argv[i] + 7, (struct sockaddr_un *)&srv.intsa);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -658,15 +655,13 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
|
||||
if (!iscbc) {
|
||||
if(srv.srvsock == INVALID_SOCKET){
|
||||
|
||||
#ifdef WITH_UN
|
||||
if(*SAFAMILY(&srv.intsa) == AF_UNIX){
|
||||
sock=srv.so._socket(srv.so.state, PF_UNIX, SOCK_STREAM, 0);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if(!isudp){
|
||||
sock=srv.so._socket(srv.so.state, SASOCK(&srv.intsa), SOCK_STREAM, IPPROTO_TCP);
|
||||
sock=srv.so._socket(srv.so.state, SASOCK(&srv.intsa), SOCK_STREAM,
|
||||
#ifdef WITH_UN
|
||||
*SAFAMILY(&srv.intsa) == AF_UNIX? 0 :
|
||||
#endif
|
||||
IPPROTO_TCP
|
||||
);
|
||||
}
|
||||
else {
|
||||
sock=srv.so._socket(srv.so.state, SASOCK(&srv.intsa), SOCK_DGRAM, IPPROTO_UDP);
|
||||
@@ -718,7 +713,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
#ifdef WITH_UN
|
||||
if(*SAFAMILY(&srv.intsa) == AF_UNIX){
|
||||
struct sockaddr_un *sun = (struct sockaddr_un *)&srv.intsa;
|
||||
unlink(sun->sun_path);
|
||||
if(*sun->sun_path)unlink(sun->sun_path);
|
||||
}
|
||||
#endif
|
||||
size = sizeof(srv.intsa);
|
||||
@@ -1064,7 +1059,12 @@ void srvinit2(struct srvparam * srv, struct clientparam *param){
|
||||
}
|
||||
|
||||
void srvfree(struct srvparam * srv){
|
||||
if(srv->srvsock != INVALID_SOCKET) so._closesocket(srv->so.state, srv->srvsock);
|
||||
if(srv->srvsock != INVALID_SOCKET) {
|
||||
so._closesocket(srv->so.state, srv->srvsock);
|
||||
#ifdef WITH_UN
|
||||
if(*SAFAMILY(&srv->intsa) == AF_UNIX && *SAADDR(&srv->intsa))unlink((char *)SAADDR(&srv->intsa));
|
||||
#endif
|
||||
}
|
||||
srv->srvsock = INVALID_SOCKET;
|
||||
if(srv->cbsock != INVALID_SOCKET) so._closesocket(srv->so.state, srv->cbsock);
|
||||
srv->cbsock = INVALID_SOCKET;
|
||||
|
||||
Reference in new issue
Block a user