mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 02:25:40 +08:00
Fixed: counters incorectly shown in webadmin, contall/nocountall are not applied
This commit is contained in:
parent
29f8867a9e
commit
129d26475e
26
src/auth.c
26
src/auth.c
@ -606,17 +606,18 @@ void trafcountfunc(struct clientparam *param){
|
||||
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||
if(ACLmatches(tc->ace, param)){
|
||||
time_t t;
|
||||
if(tc->ace->action == NOCOUNTIN || tc->ace->action == NOCOUNTALL) {
|
||||
|
||||
if(tc->ace->action == NOCOUNTIN) {
|
||||
countout = 1;
|
||||
break;
|
||||
}
|
||||
if(tc->ace->action != COUNTIN) {
|
||||
if(tc->ace->action == NOCOUNTALL) break;
|
||||
if(tc->ace->action != COUNTIN && tc->ace->action != COUNTALL) {
|
||||
countout = 1;
|
||||
if(tc->ace->action != COUNTALL)continue;
|
||||
continue;
|
||||
}
|
||||
tc->traf64 += param->statssrv64;
|
||||
time(&t);
|
||||
tc->updated = t;
|
||||
tc->updated = conf.time;
|
||||
}
|
||||
}
|
||||
if(countout) for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||
@ -627,8 +628,7 @@ void trafcountfunc(struct clientparam *param){
|
||||
continue;
|
||||
}
|
||||
tc->traf64 += param->statscli64;
|
||||
time(&t);
|
||||
tc->updated = t;
|
||||
tc->updated = conf.time;
|
||||
}
|
||||
}
|
||||
|
||||
@ -655,10 +655,14 @@ int alwaysauth(struct clientparam * param){
|
||||
for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||
if(tc->disabled) continue;
|
||||
if(ACLmatches(tc->ace, param)){
|
||||
if(tc->ace->action == NOCOUNTIN) break;
|
||||
if(tc->ace->action == NOCOUNTIN) {
|
||||
countout = 1;
|
||||
break;
|
||||
}
|
||||
if(tc->ace->action == NOCOUNTALL) break;
|
||||
if(tc->ace->action != COUNTIN) {
|
||||
countout = 1;
|
||||
continue;
|
||||
if(tc->ace->action != COUNTALL) continue;
|
||||
}
|
||||
if(tc->traflim64 <= tc->traf64) return 10;
|
||||
param->trafcountfunc = conf.trafcountfunc;
|
||||
@ -668,8 +672,8 @@ int alwaysauth(struct clientparam * param){
|
||||
if(countout)for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||
if(tc->disabled) continue;
|
||||
if(ACLmatches(tc->ace, param)){
|
||||
if(tc->ace->action == NOCOUNTOUT) break;
|
||||
if(tc->ace->action != COUNTOUT) {
|
||||
if(tc->ace->action == NOCOUNTOUT || tc->ace->action == NOCOUNTALL) break;
|
||||
if(tc->ace->action != COUNTOUT && tc->ace->action != COUNTALL) {
|
||||
continue;
|
||||
}
|
||||
if(tc->traflim64 <= tc->traf64) return 10;
|
||||
|
@ -404,7 +404,6 @@ static int h_archiver(int argc, unsigned char **argv){
|
||||
static int h_counter(int argc, unsigned char **argv){
|
||||
struct counter_header ch1;
|
||||
if(conf.counterd >=0)close(conf.counterd);
|
||||
if(!conf.trafcountfunc) conf.trafcountfunc = trafcountfunc;
|
||||
conf.counterd = open((char *)argv[1], O_BINARY|O_RDWR|O_CREAT, 0660);
|
||||
if(conf.counterd<0){
|
||||
fprintf(stderr, "Unable to open counter file %s, line %d\n", argv[1], linenum);
|
||||
@ -1239,6 +1238,7 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
case NOCOUNTOUT:
|
||||
case COUNTALL:
|
||||
case NOCOUNTALL:
|
||||
if(!conf.trafcountfunc) conf.trafcountfunc = trafcountfunc;
|
||||
tl = myalloc(sizeof(struct trafcount));
|
||||
if(!tl) {
|
||||
return(21);
|
||||
|
@ -365,32 +365,11 @@ static void * ef_ace_next(struct node * node){
|
||||
return ((struct ace *)node->value) -> next;
|
||||
}
|
||||
|
||||
|
||||
char * aceaction (int action);
|
||||
|
||||
static void * ef_ace_type(struct node * node){
|
||||
switch (((struct ace *)node->value) -> action) {
|
||||
case ALLOW:
|
||||
case REDIRECT:
|
||||
return "allow";
|
||||
case DENY:
|
||||
return "deny";
|
||||
case BANDLIM:
|
||||
return "bandlim";
|
||||
case NOBANDLIM:
|
||||
return "nobandlim";
|
||||
case COUNTIN:
|
||||
return "countin";
|
||||
case NOCOUNTIN:
|
||||
return "nocountin";
|
||||
case COUNTOUT:
|
||||
return "countout";
|
||||
case NOCOUNTOUT:
|
||||
return "nocountout";
|
||||
case COUNTALL:
|
||||
return "countall";
|
||||
case NOCOUNTALL:
|
||||
return "nocountall";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
return aceaction(((struct ace *)node->value) -> action);
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,12 +16,43 @@ extern FILE *writable;
|
||||
FILE * confopen();
|
||||
extern void decodeurl(unsigned char *s, int filter);
|
||||
|
||||
|
||||
|
||||
struct printparam {
|
||||
char buf[1024];
|
||||
int inbuf;
|
||||
struct clientparam *cp;
|
||||
};
|
||||
|
||||
char * aceaction (int action){
|
||||
switch (action) {
|
||||
case ALLOW:
|
||||
case REDIRECT:
|
||||
return "allow";
|
||||
case DENY:
|
||||
return "deny";
|
||||
case BANDLIM:
|
||||
return "bandlim";
|
||||
case NOBANDLIM:
|
||||
return "nobandlim";
|
||||
case COUNTIN:
|
||||
return "countin";
|
||||
case NOCOUNTIN:
|
||||
return "nocountin";
|
||||
case COUNTOUT:
|
||||
return "countout";
|
||||
case NOCOUNTOUT:
|
||||
return "nocountout";
|
||||
case COUNTALL:
|
||||
return "countall";
|
||||
case NOCOUNTALL:
|
||||
return "nocountall";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void stdpr(struct printparam* pp, char *buf, int inbuf){
|
||||
if((pp->inbuf + inbuf > 1024) || !buf) {
|
||||
socksend(pp->cp->clisock, (unsigned char *)pp->buf, pp->inbuf, conf.timeouts[STRING_S]);
|
||||
@ -260,11 +291,11 @@ char * admin_stringtable[]={
|
||||
|
||||
"<h3>Counters</h3>\r\n"
|
||||
"<table border = \'1\'>\r\n"
|
||||
"<tr align=\'center\'><td>Description</td><td>Active</td>"
|
||||
"<tr align=\'center\'><td>Action</td><td>#/Desc</td><td>Active</td>"
|
||||
"<td>Users</td><td>Source Address</td><td>Destination Address</td>"
|
||||
"<td>Port</td>"
|
||||
"<td>Limit</td><td>Units</td><td>Value</td>"
|
||||
"<td>Reset</td><td>Updated</td><td>Num</td></tr>\r\n",
|
||||
"<td>Reset</td><td>Updated</td><td>Position</td></tr>\r\n",
|
||||
|
||||
"</table>\r\n",
|
||||
|
||||
@ -433,9 +464,14 @@ void * adminchild(struct clientparam* param) {
|
||||
}
|
||||
if(req[1] == 'S' && atoi(req+2) == num) cp->disabled=0;
|
||||
if(req[1] == 'D' && atoi(req+2) == num) cp->disabled=1;
|
||||
inbuf += sprintf(buf, "<tr>"
|
||||
"<td>%s</td><td><A HREF=\'/C%c%d\'>%s</A></td><td>",
|
||||
(cp->comment)?cp->comment:" ",
|
||||
inbuf += sprintf(buf, "<tr><td>%s</td><td>", cp->ace?aceaction(cp->ace->action):"-");
|
||||
if(cp->number || cp->comment)
|
||||
inbuf += sprintf(buf+inbuf, "%d/%s</td>" , cp->number,
|
||||
(cp->comment)?cp->comment:" ");
|
||||
else
|
||||
inbuf += sprintf(buf+inbuf, " - </td>");
|
||||
|
||||
inbuf += sprintf(buf+inbuf, "<td><A HREF=\'/C%c%d\'>%s</A></td><td>",
|
||||
(cp->disabled)?'S':'D',
|
||||
num,
|
||||
(cp->disabled)?"NO":"YES"
|
||||
@ -467,7 +503,7 @@ void * adminchild(struct clientparam* param) {
|
||||
else {
|
||||
inbuf += printportlist(buf+inbuf, LINESIZE-128, cp->ace->ports, ",<br />\r\n");
|
||||
}
|
||||
if(cp->type == NONE) {
|
||||
if(cp->ace && (cp->ace->action == NOCOUNTIN || cp->ace->action == NOCOUNTOUT || cp->ace->action == NOCOUNTALL)) {
|
||||
inbuf += sprintf(buf+inbuf,
|
||||
"</td><td colspan=\'6\' align=\'center\'>exclude from limitation</td></tr>\r\n"
|
||||
);
|
||||
@ -543,7 +579,7 @@ void * adminchild(struct clientparam* param) {
|
||||
error = 1;
|
||||
}
|
||||
while(l < contentlen && (i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, (contentlen - l) > LINESIZE - 1?LINESIZE - 1:contentlen - l, '+', conf.timeouts[STRING_S])) > 0){
|
||||
if(i > (contentlen - l)) i = (contentlen - l);
|
||||
if((unsigned)i > (contentlen - l)) i = (contentlen - l);
|
||||
if(!l){
|
||||
if(i<9 || strncasecmp(buf, "conffile=", 9)) error = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user