mirror of
https://github.com/3proxy/3proxy.git
synced 2026-08-13 12:19:17 +08:00
Compare commits
6 Commits
f5ff81d0bc
...
c31fe8367f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c31fe8367f | ||
|
|
f480c9dfe8 | ||
|
|
8de2be3b3b | ||
|
|
aea9ff8c94 | ||
|
|
e7bc76da73 | ||
|
|
207ddb7f02 |
@ -201,11 +201,14 @@ for most traffic. Rebuild with -DWITHSPLICE to make -s available, -s0 disables i
|
|||||||
explicitly.
|
explicitly.
|
||||||
.br
|
.br
|
||||||
.B -C
|
.B -C
|
||||||
(for TCP services) keep the session until both sides close the connection
|
(for TCP services) a connection closed by any of the sides terminates the
|
||||||
(TCP half-close). By default a connection closed by any of the sides terminates
|
session, buffered data is delivered before the sockets are closed. By default
|
||||||
the session, buffered data is delivered before the sockets are closed. Half-close
|
the session is kept until both sides close the connection (TCP half-close).
|
||||||
is required for the protocols where one of the sides closes its sending side and
|
Half-close is required for the protocols where one of the sides closes its
|
||||||
expects the answer, it may cause the sockets to be kept in CLOSE_WAIT state.
|
sending side and expects the answer, but it keeps the socket of the side which
|
||||||
|
has already closed the connection in CLOSE_WAIT state. Use -C to close both
|
||||||
|
sockets as soon as any of the sides closes the connection, -C1 to request
|
||||||
|
the default behaviour explicitly.
|
||||||
.br
|
.br
|
||||||
(for dnspr) simple, do not use resolver and 3proxy cache, always use external DNS server.
|
(for dnspr) simple, do not use resolver and 3proxy cache, always use external DNS server.
|
||||||
.br
|
.br
|
||||||
|
|||||||
@ -298,7 +298,7 @@ void cyclestep(void){
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dologname (tmpbuf, conf.logname, (conf.archiver)?conf.archiver[1]:NULL, conf.logtype, (conf.logtime - t * conf.rotate));
|
dologname (tmpbuf, conf.logname, (conf.archiver)?conf.archiver[1]:NULL, conf.logtype, (conf.logtime - (time_t)t * conf.rotate));
|
||||||
remove ((char *) tmpbuf);
|
remove ((char *) tmpbuf);
|
||||||
if(conf.archiver) {
|
if(conf.archiver) {
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@ -159,6 +159,10 @@ int checkACL(struct clientparam * param){
|
|||||||
if(!res) break;
|
if(!res) break;
|
||||||
if(param->remsock != INVALID_SOCKET) param->srv->so._closesocket(param->sostate, param->remsock);
|
if(param->remsock != INVALID_SOCKET) param->srv->so._closesocket(param->sostate, param->remsock);
|
||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
|
if(param->ctrlsocksrv != INVALID_SOCKET) {
|
||||||
|
param->srv->so._closesocket(param->sostate, param->ctrlsocksrv);
|
||||||
|
param->ctrlsocksrv = INVALID_SOCKET;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/hash.c
12
src/hash.c
@ -70,9 +70,9 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
|
|||||||
_3proxy_mutex_init(&ht->hash_mutex);
|
_3proxy_mutex_init(&ht->hash_mutex);
|
||||||
_3proxy_mutex_lock(&ht->hash_mutex);
|
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||||
}
|
}
|
||||||
if(!(ht->ihashtable = malloc(tablesize * sizeof(uint32_t)))
|
if(!(ht->ihashtable = malloc((size_t)tablesize * sizeof(uint32_t)))
|
||||||
|| !(ht->hashvalues = malloc(poolsize * (sizeof(struct hashentry) + ht->recsize - 4)))
|
|| !(ht->hashvalues = malloc((size_t)poolsize * (sizeof(struct hashentry) + ht->recsize - 4)))
|
||||||
|| !(ht->hashhashvalues = malloc(poolsize * ht->hash_size))
|
|| !(ht->hashhashvalues = malloc((size_t)poolsize * ht->hash_size))
|
||||||
){
|
){
|
||||||
free(ht->ihashtable);
|
free(ht->ihashtable);
|
||||||
ht->ihashtable = NULL;
|
ht->ihashtable = NULL;
|
||||||
@ -126,13 +126,13 @@ static void hashgrow(struct hashtable *ht){
|
|||||||
if(ht->ihashempty) return;
|
if(ht->ihashempty) return;
|
||||||
if(ht->poolsize >= ht->growlimit) return;
|
if(ht->poolsize >= ht->growlimit) return;
|
||||||
if(newsize > ht->growlimit) newsize = ht->growlimit;
|
if(newsize > ht->growlimit) newsize = ht->growlimit;
|
||||||
newvalues = realloc(ht->hashvalues, newsize * (sizeof(struct hashentry) + ht->recsize - 4));
|
newvalues = realloc(ht->hashvalues, (size_t)newsize * (sizeof(struct hashentry) + ht->recsize - 4));
|
||||||
if(!newvalues) return;
|
if(!newvalues) return;
|
||||||
ht->hashvalues = newvalues;
|
ht->hashvalues = newvalues;
|
||||||
newvalues = realloc(ht->hashhashvalues, newsize * ht->hash_size);
|
newvalues = realloc(ht->hashhashvalues, (size_t)newsize * ht->hash_size);
|
||||||
if(!newvalues) return;
|
if(!newvalues) return;
|
||||||
ht->hashhashvalues = newvalues;
|
ht->hashhashvalues = newvalues;
|
||||||
memset(ht->hashvalues + (ht->poolsize * (sizeof(struct hashentry) + ht->recsize - 4)), 0, (newsize - ht->poolsize) * (sizeof(struct hashentry) + ht->recsize - 4));
|
memset(ht->hashvalues + ((size_t)ht->poolsize * (sizeof(struct hashentry) + ht->recsize - 4)), 0, (size_t)(newsize - ht->poolsize) * (sizeof(struct hashentry) + ht->recsize - 4));
|
||||||
for(i = ht->poolsize + 1; i < newsize; i++) {
|
for(i = ht->poolsize + 1; i < newsize; i++) {
|
||||||
hvalue(ht,i)->inext = i+1;
|
hvalue(ht,i)->inext = i+1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,15 +109,17 @@ struct sockfuncs sso;
|
|||||||
|
|
||||||
static void genpaths(struct fp_stream *fps){
|
static void genpaths(struct fp_stream *fps){
|
||||||
|
|
||||||
|
size_t len = strlen(path) + 32;
|
||||||
|
|
||||||
if(fps->what & (FP_CLIDATA|FP_CLIHEADER)){
|
if(fps->what & (FP_CLIDATA|FP_CLIHEADER)){
|
||||||
if(fps->fpd.path_cli) free(fps->fpd.path_cli);
|
if(fps->fpd.path_cli) free(fps->fpd.path_cli);
|
||||||
fps->fpd.path_cli = malloc(strlen(path) + 10);
|
fps->fpd.path_cli = malloc(len);
|
||||||
sprintf(fps->fpd.path_cli, path, counter++);
|
if(fps->fpd.path_cli) sprintf(fps->fpd.path_cli, "%s%07d.tmp", path, counter++);
|
||||||
}
|
}
|
||||||
if(fps->what & (FP_SRVDATA|FP_SRVHEADER)){
|
if(fps->what & (FP_SRVDATA|FP_SRVHEADER)){
|
||||||
if(fps->fpd.path_srv) free(fps->fpd.path_srv);
|
if(fps->fpd.path_srv) free(fps->fpd.path_srv);
|
||||||
fps->fpd.path_srv = malloc(strlen(path) + 10);
|
fps->fpd.path_srv = malloc(len);
|
||||||
sprintf(fps->fpd.path_srv, path, counter++);
|
if(fps->fpd.path_srv) sprintf(fps->fpd.path_srv, "%s%07d.tmp", path, counter++);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -139,6 +141,7 @@ static
|
|||||||
return fps->fpd.h_cli;
|
return fps->fpd.h_cli;
|
||||||
#else
|
#else
|
||||||
if(fps->fpd.fd_cli != -1) close(fps->fpd.fd_cli);
|
if(fps->fpd.fd_cli != -1) close(fps->fpd.fd_cli);
|
||||||
|
if(!fps->fpd.path_cli) return (fps->fpd.fd_cli = -1);
|
||||||
fps->fpd.fd_cli = open(fps->fpd.path_cli, O_BINARY|O_RDWR|O_CREAT|O_TRUNC, 0600);
|
fps->fpd.fd_cli = open(fps->fpd.path_cli, O_BINARY|O_RDWR|O_CREAT|O_TRUNC, 0600);
|
||||||
return fps->fpd.fd_cli;
|
return fps->fpd.fd_cli;
|
||||||
#endif
|
#endif
|
||||||
@ -160,6 +163,7 @@ static
|
|||||||
return fps->fpd.h_srv;
|
return fps->fpd.h_srv;
|
||||||
#else
|
#else
|
||||||
if(fps->fpd.fd_srv != -1) close(fps->fpd.fd_srv);
|
if(fps->fpd.fd_srv != -1) close(fps->fpd.fd_srv);
|
||||||
|
if(!fps->fpd.path_srv) return (fps->fpd.fd_srv = -1);
|
||||||
fps->fpd.fd_srv = open(fps->fpd.path_srv, O_BINARY|O_RDWR|O_CREAT|O_TRUNC, 0600);
|
fps->fpd.fd_srv = open(fps->fpd.path_srv, O_BINARY|O_RDWR|O_CREAT|O_TRUNC, 0600);
|
||||||
return fps->fpd.fd_srv;
|
return fps->fpd.fd_srv;
|
||||||
#endif
|
#endif
|
||||||
@ -871,17 +875,17 @@ static int h_cachedir(int argc, unsigned char **argv){
|
|||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
dirp = (argc > 1)? (char *)argv[1] : getenv("TEMP");
|
dirp = (argc > 1)? (char *)argv[1] : getenv("TEMP");
|
||||||
len = strlen(dirp);
|
len = dirp? strlen(dirp) : 0;
|
||||||
if(!dirp || !len || len > 200 || strchr(dirp, '%')) {
|
if(!dirp || !len || len > 200 || strchr(dirp, '%')) {
|
||||||
fprintf(stderr, "FilePlugin: invalid directory path: %s\n", dirp);
|
fprintf(stderr, "FilePlugin: invalid directory path: %s\n", dirp);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if(dirp[len-1] == '\\') dirp[len-1] = 0;
|
if(dirp[len-1] == '\\') dirp[len-1] = 0;
|
||||||
sprintf(path, "%.256s\\%%07d.tmp", dirp);
|
sprintf(path, "%.256s\\", dirp);
|
||||||
#else
|
#else
|
||||||
if(dirp[len-1] == '/') dirp[len-1] = 0;
|
if(dirp[len-1] == '/') dirp[len-1] = 0;
|
||||||
sprintf(path, "%.256s/%%07d.tmp", dirp);
|
sprintf(path, "%.256s/", dirp);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/proxy.c
10
src/proxy.c
@ -831,12 +831,20 @@ for(;;){
|
|||||||
send_st(param, 9);
|
send_st(param, 9);
|
||||||
}
|
}
|
||||||
if((unsigned)socksend(param, param->clisock, buf, inbuf, conf.timeouts[STRING_S]) != inbuf){
|
if((unsigned)socksend(param, param->clisock, buf, inbuf, conf.timeouts[STRING_S]) != inbuf){
|
||||||
|
param->srv->so._closesocket(param->sostate, ftps);
|
||||||
|
ftps = INVALID_SOCKET;
|
||||||
|
param->remsock = s;
|
||||||
RETURN(781);
|
RETURN(781);
|
||||||
}
|
}
|
||||||
inbuf = 0;
|
inbuf = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!(newbuf = realloc(buf, bufsize + BUFSIZE))){RETURN (21);}
|
if(!(newbuf = realloc(buf, bufsize + BUFSIZE))){
|
||||||
|
param->srv->so._closesocket(param->sostate, ftps);
|
||||||
|
ftps = INVALID_SOCKET;
|
||||||
|
param->remsock = s;
|
||||||
|
RETURN (21);
|
||||||
|
}
|
||||||
buf = newbuf;
|
buf = newbuf;
|
||||||
bufsize += BUFSIZE;
|
bufsize += BUFSIZE;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -329,8 +329,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#endif
|
#endif
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
" -s Use splice() - no filtering for data, off by default\n"
|
" -s Use splice() - no filtering for data, off by default\n"
|
||||||
" -C keep the session until both sides close the connection (TCP half-close),\n"
|
" -C connection closed by any of the sides terminates the session, by default\n"
|
||||||
" by default connection closed by any of the sides terminates the session\n"
|
" the session is kept until both sides close it (TCP half-close)\n"
|
||||||
#endif
|
#endif
|
||||||
"-g(GRACE_TRAFF,GRACE_NUM,GRACE_DELAY) - delay GRACE_DELAY milliseconds before polling if average polling size below GRACE_TRAFF bytes and GRACE_NUM read operations in single directions are detected within 1 second to minimize polling\n"
|
"-g(GRACE_TRAFF,GRACE_NUM,GRACE_DELAY) - delay GRACE_DELAY milliseconds before polling if average polling size below GRACE_TRAFF bytes and GRACE_NUM read operations in single directions are detected within 1 second to minimize polling\n"
|
||||||
" -fFORMAT logging format (see documentation)\n"
|
" -fFORMAT logging format (see documentation)\n"
|
||||||
@ -599,7 +599,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
sscanf(argv[i]+2, "%d,%d,%d", &srv.gracetraf, &srv.gracenum, &srv.gracedelay);
|
sscanf(argv[i]+2, "%d,%d,%d", &srv.gracetraf, &srv.gracenum, &srv.gracedelay);
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
srv.halfclose = *(argv[i]+2)? atoi(argv[i]+2) : 1;
|
srv.halfclose = *(argv[i]+2)? atoi(argv[i]+2) : 0;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
@ -1252,7 +1252,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
|
|||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
srv->usesplice = 0;
|
srv->usesplice = 0;
|
||||||
#endif
|
#endif
|
||||||
srv->halfclose = 0;
|
srv->halfclose = 1;
|
||||||
memset(param, 0, sizeof(struct clientparam));
|
memset(param, 0, sizeof(struct clientparam));
|
||||||
param->srv = srv;
|
param->srv = srv;
|
||||||
param->version = srv->version;
|
param->version = srv->version;
|
||||||
|
|||||||
@ -352,6 +352,7 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
|||||||
}
|
}
|
||||||
if(param->operation == UDPASSOC){
|
if(param->operation == UDPASSOC){
|
||||||
SOCKET s;
|
SOCKET s;
|
||||||
|
if(cur->type != R_SOCKS5 && cur->type != R_SOCKS5P) return 70;
|
||||||
s = param->remsock;
|
s = param->remsock;
|
||||||
param->remsock = INVALID_SOCKET;
|
param->remsock = INVALID_SOCKET;
|
||||||
param->ctrlsocksrv = s;
|
param->ctrlsocksrv = s;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user