Parcourir la source

Some useful warnings added

Checks for most common misconfigurations
z3APA3A il y a 11 ans
Parent
commit
f452009079
1 fichiers modifiés avec 21 ajouts et 0 suppressions
  1. 21 0
      src/3proxy.c

+ 21 - 0
src/3proxy.c

@@ -647,6 +647,9 @@ static int h_proxy(int argc, unsigned char ** argv){
 		childdef.isudp = 0;
 		childdef.service = S_PROXY;
 		childdef.helpmessage = " -n - no NTLM support\n";
+		if(!resolvfunc || (resolvfunc == myresolver && !dns_table->hashsize)){
+			fprintf(stderr, "[line %d] Warning: no nserver/nscache configured, proxy may run very slow\n", linenum);
+		}
 	}
 	else if(!strcmp((char *)argv[0], "pop3p")) {
 		childdef.pf = pop3pchild;
@@ -675,6 +678,9 @@ static int h_proxy(int argc, unsigned char ** argv){
 		childdef.isudp = 0;
 		childdef.service = S_SOCKS;
 		childdef.helpmessage = " -n - no NTLM support\n";
+		if(!resolvfunc || (resolvfunc == myresolver && !dns_table->hashsize)){
+			fprintf(stderr, "[line %d] Warning: no nserver/nscache configured, socks may run very slow\n", linenum);
+		}
 	}
 	else if(!strcmp((char *)argv[0], "tcppm")) {
 		childdef.pf = tcppmchild;
@@ -715,6 +721,9 @@ static int h_proxy(int argc, unsigned char ** argv){
 		childdef.port = 53;
 		childdef.isudp = 1;
 		childdef.service = S_DNSPR;
+		if(!resolvfunc || (resolvfunc == myresolver && !dns_table->hashsize) || resolvfunc == fake_resolver){
+			fprintf(stderr, "[line %d] Warning: no nserver/nscache configured, dnspr will not work as expected\n", linenum);
+		}
 	}
 	return start_proxy_thread(&ch);
 }
@@ -954,6 +963,18 @@ static int h_maxconn(int argc, unsigned char **argv){
 	if(!conf.maxchild) {
 		return(1);
 	}
+#ifndef _WIN32
+	{
+		struct rlimit rl;
+		if(!getrlimit(RLIMIT_NOFILE, &rl)){
+			if((conf.maxchild<<1) > rl.rlim_cur)
+				fprintf(stderr, "[line %d] Warning: current open file ulimits are too low (cur: %d/max: %d),"
+						" maxconn requires at least %d for every running service."
+						" Configure ulimits according to system documentation\n",
+						  linenum, (int)rl.rlim_cur, (int)rl.rlim_max, (conf.maxchild<<1));
+		}
+	}
+#endif
 	return 0;
 }