mirror of
				https://github.com/3proxy/3proxy.git
				synced 2025-11-04 15:52:39 +08:00 
			
		
		
		
	better dat filters handling
This commit is contained in:
		
							parent
							
								
									1ff0fabf15
								
							
						
					
					
						commit
						d2dcf4bb69
					
				
							
								
								
									
										23
									
								
								src/proxy.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								src/proxy.c
									
									
									
									
									
								
							@ -537,17 +537,28 @@ for(;;){
 | 
				
			|||||||
	RETURN(0);
 | 
						RETURN(0);
 | 
				
			||||||
 }
 | 
					 }
 | 
				
			||||||
 if(action != PASS) RETURN(517);
 | 
					 if(action != PASS) RETURN(517);
 | 
				
			||||||
 if(param->ndatfilterscli > 0 && contentlength64 > 0){
 | 
					 param->nolongdatfilter = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 if (conf.filtermaxsize && contentlength64 > (uint64_t)conf.filtermaxsize) {
 | 
				
			||||||
 | 
						param->nolongdatfilter = 1;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 else if(param->ndatfilterscli > 0 && contentlength64 > 0){
 | 
				
			||||||
  uint64_t newlen64;
 | 
					  uint64_t newlen64;
 | 
				
			||||||
  newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
 | 
					  newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
 | 
				
			||||||
  if(newlen64 == contentlength64) {
 | 
					  if(newlen64 == contentlength64) {
 | 
				
			||||||
 | 
						action = handlepredatflt(param);
 | 
				
			||||||
 | 
						if(action == HANDLED){
 | 
				
			||||||
 | 
							RETURN(0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if(action != PASS) RETURN(19);
 | 
				
			||||||
	action = handledatfltcli(param,  ¶m->clibuf, (int *)¶m->clibufsize, 0, (int *)¶m->cliinbuf);
 | 
						action = handledatfltcli(param,  ¶m->clibuf, (int *)¶m->clibufsize, 0, (int *)¶m->cliinbuf);
 | 
				
			||||||
	if(action == HANDLED){
 | 
						if(action == HANDLED){
 | 
				
			||||||
		RETURN(0);
 | 
							RETURN(0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if(action != PASS) RETURN(517);
 | 
						if(action != PASS) RETURN(517);
 | 
				
			||||||
	contentlength64 = param->cliinbuf;
 | 
						contentlength64 = param->cliinbuf;
 | 
				
			||||||
	param->ndatfilterscli = 0;
 | 
						param->nolongdatfilter = 1;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
 | 
					  sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64);
 | 
				
			||||||
 }
 | 
					 }
 | 
				
			||||||
@ -882,7 +893,6 @@ for(;;){
 | 
				
			|||||||
	sleeptime = param->bandlimfunc(param, 0, (int)strlen((char *)buf));
 | 
						sleeptime = param->bandlimfunc(param, 0, (int)strlen((char *)buf));
 | 
				
			||||||
 }
 | 
					 }
 | 
				
			||||||
 if(contentlength64 > 0){
 | 
					 if(contentlength64 > 0){
 | 
				
			||||||
	 param->nolongdatfilter = 0;
 | 
					 | 
				
			||||||
	 param->waitclient64 = contentlength64;
 | 
						 param->waitclient64 = contentlength64;
 | 
				
			||||||
	 res = mapsocket(param, conf.timeouts[CONNECTION_S]);
 | 
						 res = mapsocket(param, conf.timeouts[CONNECTION_S]);
 | 
				
			||||||
	 param->waitclient64 = 0;
 | 
						 param->waitclient64 = 0;
 | 
				
			||||||
@ -985,10 +995,15 @@ for(;;){
 | 
				
			|||||||
 if (conf.filtermaxsize && contentlength64 > (uint64_t)conf.filtermaxsize) {
 | 
					 if (conf.filtermaxsize && contentlength64 > (uint64_t)conf.filtermaxsize) {
 | 
				
			||||||
	param->nolongdatfilter = 1;
 | 
						param->nolongdatfilter = 1;
 | 
				
			||||||
 }
 | 
					 }
 | 
				
			||||||
 else if(param->unsafefilter && param->ndatfilterssrv > 0 && contentlength64 > 0 && param->operation != HTTP_HEAD && res != 204 && res != 304){
 | 
					 else if(param->ndatfilterssrv > 0 && contentlength64 > 0 && param->operation != HTTP_HEAD && res != 204 && res != 304){
 | 
				
			||||||
  uint64_t newlen;
 | 
					  uint64_t newlen;
 | 
				
			||||||
  newlen = (uint64_t)sockfillbuffsrv(param, (unsigned long) contentlength64, CONNECTION_S);
 | 
					  newlen = (uint64_t)sockfillbuffsrv(param, (unsigned long) contentlength64, CONNECTION_S);
 | 
				
			||||||
  if(newlen == contentlength64) {
 | 
					  if(newlen == contentlength64) {
 | 
				
			||||||
 | 
						action = handlepredatflt(param);
 | 
				
			||||||
 | 
						if(action == HANDLED){
 | 
				
			||||||
 | 
							RETURN(0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if(action != PASS) RETURN(19);
 | 
				
			||||||
	action = handledatfltsrv(param,  ¶m->srvbuf, (int *)¶m->srvbufsize, 0, (int *)¶m->srvinbuf);
 | 
						action = handledatfltsrv(param,  ¶m->srvbuf, (int *)¶m->srvbufsize, 0, (int *)¶m->srvinbuf);
 | 
				
			||||||
	param->nolongdatfilter = 1;
 | 
						param->nolongdatfilter = 1;
 | 
				
			||||||
	if(action == HANDLED){
 | 
						if(action == HANDLED){
 | 
				
			||||||
 | 
				
			|||||||
@ -67,7 +67,7 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
 | 
				
			|||||||
 int pipesrv[2] = {-1,-1};
 | 
					 int pipesrv[2] = {-1,-1};
 | 
				
			||||||
 int pipecli[2] = {-1,-1};
 | 
					 int pipecli[2] = {-1,-1};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 if(param->operation == UDPASSOC) usesplice = 0;
 | 
					 if(param->operation == UDPASSOC || (!param->nolongdatfilter && (param->ndatfilterscli > 0 || param->ndatfilterssrv))) usesplice = 0;
 | 
				
			||||||
 if(usesplice){
 | 
					 if(usesplice){
 | 
				
			||||||
	TOCLIENTPIPE = FROMCLIENTPIPE = TOSERVERPIPE = FROMSERVERPIPE = 1;
 | 
						TOCLIENTPIPE = FROMCLIENTPIPE = TOSERVERPIPE = FROMSERVERPIPE = 1;
 | 
				
			||||||
	TOCLIENTBUF = TOSERVERBUF = 0;
 | 
						TOCLIENTBUF = TOSERVERBUF = 0;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user