mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 02:25:40 +08:00
add monitorsock support
This commit is contained in:
parent
fae9c227bb
commit
fa74b9a6e3
@ -2,5 +2,4 @@
|
||||
|
||||
*Initial deb devel release
|
||||
|
||||
-- z3APA3A <3apa3a@3proxy.org> Thu, 12 Nov 2020 12:12:12 +0300
|
||||
|
||||
-- z3APA3A <3apa3a@3proxy.org> Thu, 03 Dec 2020 21:07:14 +0300
|
||||
|
@ -153,9 +153,9 @@ extern int timetoexit;
|
||||
extern struct extparam conf;
|
||||
|
||||
int sockmap(struct clientparam * param, int timeo, int usesplice);
|
||||
int socksend(SOCKET sock, char * buf, int bufsize, int to);
|
||||
int socksendto(SOCKET sock, struct sockaddr * sin, char * buf, int bufsize, int to);
|
||||
int sockrecvfrom(SOCKET sock, struct sockaddr * sin, char * buf, int bufsize, int to);
|
||||
int socksend(SOCKET sock, char * buf, int bufsize, int tosec);
|
||||
int socksendto(SOCKET sock, struct sockaddr * sin, char * buf, int bufsize, int tomsec);
|
||||
int sockrecvfrom(SOCKET sock, struct sockaddr * sin, char * buf, int bufsize, int tomsec);
|
||||
|
||||
|
||||
int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec);
|
||||
@ -304,7 +304,7 @@ extern struct datatype datatypes[64];
|
||||
extern struct commands commandhandlers[];
|
||||
|
||||
#ifdef WITHSPLICE
|
||||
#define mapsocket(a,b) ((a->srv->usesplice && !a->ndatfilterssrv && !a->ndatfilterscli)?sockmap(a,b,1):sockmap(a,b,0))
|
||||
#define mapsocket(a,b) ((a->srv->usesplice)?sockmap(a,b,1):sockmap(a,b,0))
|
||||
#else
|
||||
#define mapsocket(a,b) sockmap(a,b, 0)
|
||||
#endif
|
||||
|
@ -53,7 +53,7 @@ void * threadfunc (void *p) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if(socksendto(param->remsock, (struct sockaddr*)¶m->sinsr, "C", 1, CONNBACK_TO*1000) != 1){
|
||||
if(socksend(param->remsock, "C", 1, CONNBACK_TO) != 1){
|
||||
dolog(param, (char *)"Connect back sending command failed");
|
||||
so._closesocket(param->remsock);
|
||||
param->remsock = INVALID_SOCKET;
|
||||
@ -891,7 +891,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
|
||||
param->srv = srv;
|
||||
param->version = srv->version;
|
||||
param->paused = srv->paused;
|
||||
param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = INVALID_SOCKET;
|
||||
param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = param->monitorsock = INVALID_SOCKET;
|
||||
*SAFAMILY(¶m->req) = *SAFAMILY(¶m->sinsl) = *SAFAMILY(¶m->sinsr) = *SAFAMILY(¶m->sincr) = *SAFAMILY(¶m->sincl) = AF_INET;
|
||||
pthread_mutex_init(&srv->counter_mutex, NULL);
|
||||
srv->intsa = conf.intsa;
|
||||
|
@ -82,7 +82,7 @@ int readdata (struct clientparam* param) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
socksendto(param->remsock, (struct sockaddr *)¶m->sinsr, buf, i, conf.timeouts[STRING_S]);
|
||||
socksend(param->remsock, buf, i, conf.timeouts[STRING_S]);
|
||||
}
|
||||
if(i < 1) {
|
||||
myfree(buf);
|
||||
|
@ -52,7 +52,7 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
|
||||
int HASERROR=0;
|
||||
int CLIENTTERM = 0, SERVERTERM = 0;
|
||||
int after = 0;
|
||||
struct pollfd fds[6];
|
||||
struct pollfd fds[7];
|
||||
struct pollfd *fdsp = fds;
|
||||
int fdsc = 0;
|
||||
int sleeptime = 0;
|
||||
@ -167,7 +167,11 @@ log(logbuf);
|
||||
memset(fds, 0, sizeof(fds));
|
||||
fds[0].fd = param->clisock;
|
||||
fds[1].fd = param->remsock;
|
||||
so._poll(fds, 2, sleeptime);
|
||||
fds[2].fd = param->monitorsock;
|
||||
fds[2].events = POLLIN;
|
||||
if(param->monitorsock != INVALID_SOCKET)
|
||||
so._poll(fds, param->monitorsock != INVALID_SOCKET? 3:2, sleeptime);
|
||||
if(fds[2].revents)RETURN (93);
|
||||
sleeptime = 0;
|
||||
}
|
||||
if((param->srv->logdumpsrv && (param->statssrv64 > param->srv->logdumpsrv)) ||
|
||||
@ -431,11 +435,19 @@ log("done read from server to buf");
|
||||
}
|
||||
}
|
||||
}
|
||||
for(after = 0; after < 2; after ++){
|
||||
for(after = 0; after <= 1; after ++){
|
||||
fdsc = 0;
|
||||
if(!after){
|
||||
memset(fds, 0, sizeof(fds));
|
||||
}
|
||||
if(param->monitorsock != INVALID_SOCKET){
|
||||
if(!after){
|
||||
fds[fdsc].fd = param->monitorsock;
|
||||
fds[fdsc].events = POLLIN;
|
||||
fdsc++;
|
||||
}
|
||||
else if(fds[fdsc].revents) RETURN(90);
|
||||
}
|
||||
if(!CLIENTTERM){
|
||||
if(!after){
|
||||
fds[fdsc].fd = param->clisock;
|
||||
|
@ -520,19 +520,20 @@ struct clientparam {
|
||||
**hdrfilterscli, **hdrfilterssrv,
|
||||
**predatfilters, **datfilterscli, **datfilterssrv;
|
||||
|
||||
PROXYSERVICE service;
|
||||
|
||||
SOCKET clisock,
|
||||
remsock,
|
||||
ctrlsock,
|
||||
ctrlsocksrv;
|
||||
|
||||
REDIRTYPE redirtype;
|
||||
|
||||
uint64_t waitclient64,
|
||||
waitserver64,
|
||||
cycles;
|
||||
|
||||
SOCKET clisock,
|
||||
remsock,
|
||||
ctrlsock,
|
||||
ctrlsocksrv, monitorsock;
|
||||
|
||||
PROXYSERVICE service;
|
||||
REDIRTYPE redirtype;
|
||||
|
||||
|
||||
int redirected,
|
||||
operation,
|
||||
nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv,
|
||||
|
Loading…
Reference in New Issue
Block a user