Sfoglia il codice sorgente

parentretries command added

z3APA3A 5 anni fa
parent
commit
0a7987c6fb
4 ha cambiato i file con 25 aggiunte e 7 eliminazioni
  1. 12 4
      src/auth.c
  2. 1 1
      src/common.c
  3. 11 1
      src/conf.c
  4. 1 1
      src/structures.h

+ 12 - 4
src/auth.c

@@ -605,7 +605,6 @@ void trafcountfunc(struct clientparam *param){
 	pthread_mutex_lock(&tc_mutex);
 	for(tc = conf.trafcounter; tc; tc = tc->next) {
 		if(ACLmatches(tc->ace, param)){
-			time_t t;
 
 			if(tc->ace->action == NOCOUNTIN) {
 				countout = 1;
@@ -622,7 +621,6 @@ void trafcountfunc(struct clientparam *param){
 	}
 	if(countout) for(tc = conf.trafcounter; tc; tc = tc->next) {
 		if(ACLmatches(tc->ace, param)){
-			time_t t;
 			if(tc->ace->action == NOCOUNTOUT || tc->ace->action == NOCOUNTALL) break;
 			if(tc->ace->action != COUNTOUT && tc->ace->action != COUNTALL ) {
 				continue;
@@ -701,6 +699,7 @@ int checkACL2(struct clientparam * param, int pre){
 				param->weight = acentry->weight;
 				if(acentry->action == 2) {
 					struct ace dup;
+					int res=60,i=0;
 
 					if(param->operation < 256 && !(param->operation & CONNECT)){
 						continue;
@@ -708,8 +707,17 @@ int checkACL2(struct clientparam * param, int pre){
 					if(param->redirected && acentry->chains && SAISNULL(&acentry->chains->addr) && !*SAPORT(&acentry->chains->addr)) {
 						continue;
 					}
-					dup = *acentry;
-					return handleredirect(param, &dup);
+					if(param->remsock != INVALID_SOCKET) {
+						return 0;
+					}
+					for(; i < conf.parentretries; i++){
+						dup = *acentry;
+						res = handleredirect(param, &dup);
+						if(!res) break;
+						if(param->remsock != INVALID_SOCKET) closesocket(param->remsock);
+						param->remsock = INVALID_SOCKET;
+					}
+					return res;
 				}
 			}
 			return acentry->action;

+ 1 - 1
src/common.c

@@ -102,7 +102,7 @@ struct extparam conf = {
 	NULL, /* struct srvparam *services; */
 	0, /* int stacksize, */ 
 	0, -1, 0, 0, 0, 0, /* threadinit, counterd, haveerror, rotate, paused, archiverc, */
-	0, 250, 0, 0, 0, 0, 0, /* demon, maxchild, needreload, timetoexit, version, noforce, bandlimver; */
+	0, 250, 0, 0, 0, 0, 0, 2, /* demon, maxchild, needreload, timetoexit, version, noforce, bandlimver, parenretries; */
 	6, 600, /* int authcachetype, authcachetime; */
 	1048576, /* int filtermaxsize; */
 	NULL, /* **archiver; */

+ 11 - 1
src/conf.c

@@ -528,6 +528,15 @@ static int h_nscache(int argc, char **argv){
 	}
 	return 0;
 }
+
+static int h_parentretries(int argc, char **argv){
+  int res;
+
+	res = atoi((char *)argv[1]);
+	if(res > 0) conf.parentretries = res;
+	return 0;
+}
+
 static int h_nscache6(int argc, char **argv){
   int res;
 
@@ -1472,8 +1481,9 @@ struct commands commandhandlers[]={
 	{commandhandlers+59, "stacksize", h_stacksize, 2, 2},
 	{commandhandlers+60, "force", h_force, 1, 1},
 	{commandhandlers+61, "noforce", h_noforce, 1, 1},
+	{commandhandlers+62, "parentretries", h_parentretries, 2, 2},
 #ifndef NORADIUS
-	{commandhandlers+62, "radius", h_radius, 3, 0},
+	{commandhandlers+63, "radius", h_radius, 3, 0},
 #endif
 	{specificcommands, 	 "", h_noop, 1, 0}
 };

+ 1 - 1
src/structures.h

@@ -611,7 +611,7 @@ struct extparam {
 	struct srvparam *services;
 	int stacksize,
 		threadinit, counterd, haveerror, rotate, paused, archiverc,
-		demon, maxchild, needreload, timetoexit, version, noforce, bandlimver;
+		demon, maxchild, needreload, timetoexit, version, noforce, bandlimver, parentretries;
 	int authcachetype, authcachetime;
 	int filtermaxsize;
 	char **archiver;