mirror of
				https://github.com/3proxy/3proxy.git
				synced 2025-11-04 07:42:39 +08:00 
			
		
		
		
	intermediate commit
This commit is contained in:
		
							parent
							
								
									eb829b062b
								
							
						
					
					
						commit
						a4f95462b3
					
				
							
								
								
									
										48
									
								
								src/3proxy.c
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								src/3proxy.c
									
									
									
									
									
								
							@ -271,51 +271,6 @@ void cyclestep(void){
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	if(conf.logname) {
 | 
						if(conf.logname) {
 | 
				
			||||||
		if(timechanged(conf.logtime, conf.time, conf.logtype)) {
 | 
							if(timechanged(conf.logtime, conf.time, conf.logtype)) {
 | 
				
			||||||
			if(conf.stdlog) conf.stdlog = freopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.time), "a", conf.stdlog);
 | 
					 | 
				
			||||||
			else conf.stdlog = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.time), "a");
 | 
					 | 
				
			||||||
			conf.logtime = conf.time;
 | 
					 | 
				
			||||||
			if(conf.logtype != NONE && conf.rotate) {
 | 
					 | 
				
			||||||
				int t;
 | 
					 | 
				
			||||||
				t = 1;
 | 
					 | 
				
			||||||
				switch(conf.logtype){
 | 
					 | 
				
			||||||
					case ANNUALLY:
 | 
					 | 
				
			||||||
						t = t * 12;
 | 
					 | 
				
			||||||
					case MONTHLY:
 | 
					 | 
				
			||||||
						t = t * 4;
 | 
					 | 
				
			||||||
					case WEEKLY:
 | 
					 | 
				
			||||||
						t = t * 7;
 | 
					 | 
				
			||||||
					case DAILY:
 | 
					 | 
				
			||||||
						t = t * 24;
 | 
					 | 
				
			||||||
					case HOURLY:
 | 
					 | 
				
			||||||
						t = t * 60;
 | 
					 | 
				
			||||||
					case MINUTELY:
 | 
					 | 
				
			||||||
						t = t * 60;
 | 
					 | 
				
			||||||
					default:
 | 
					 | 
				
			||||||
						break;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				dologname (tmpbuf, conf.logname, (conf.archiver)?conf.archiver[1]:NULL, conf.logtype, (conf.logtime - t * conf.rotate));
 | 
					 | 
				
			||||||
				remove ((char *) tmpbuf);
 | 
					 | 
				
			||||||
				if(conf.archiver) {
 | 
					 | 
				
			||||||
					int i;
 | 
					 | 
				
			||||||
					*tmpbuf = 0;
 | 
					 | 
				
			||||||
					for(i = 2; i < conf.archiverc && strlen((char *)tmpbuf) < 512; i++){
 | 
					 | 
				
			||||||
						strcat((char *)tmpbuf, " ");
 | 
					 | 
				
			||||||
						if(!strcmp((char *)conf.archiver[i], "%A")){
 | 
					 | 
				
			||||||
							strcat((char *)tmpbuf, "\"");
 | 
					 | 
				
			||||||
							dologname (tmpbuf + strlen((char *)tmpbuf), conf.logname, conf.archiver[1], conf.logtype, (conf.logtime - t));
 | 
					 | 
				
			||||||
							strcat((char *)tmpbuf, "\"");
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						else if(!strcmp((char *)conf.archiver[i], "%F")){
 | 
					 | 
				
			||||||
							strcat((char *)tmpbuf, "\"");
 | 
					 | 
				
			||||||
							dologname (tmpbuf+strlen((char *)tmpbuf), conf.logname, NULL, conf.logtype, (conf.logtime-t));
 | 
					 | 
				
			||||||
							strcat((char *)tmpbuf, "\"");
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						else
 | 
					 | 
				
			||||||
							strcat((char *)tmpbuf, (char *)conf.archiver[i]);
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					system((char *)tmpbuf+1);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if(conf.counterd >= 0 && conf.trafcounter) {
 | 
						if(conf.counterd >= 0 && conf.trafcounter) {
 | 
				
			||||||
@ -512,11 +467,10 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
 | 
				
			|||||||
  pthread_mutex_init(&hash_mutex, NULL);
 | 
					  pthread_mutex_init(&hash_mutex, NULL);
 | 
				
			||||||
  pthread_mutex_init(&tc_mutex, NULL);
 | 
					  pthread_mutex_init(&tc_mutex, NULL);
 | 
				
			||||||
  pthread_mutex_init(&pwl_mutex, NULL);
 | 
					  pthread_mutex_init(&pwl_mutex, NULL);
 | 
				
			||||||
  pthread_mutex_init(&log_mutex, NULL);
 | 
					 | 
				
			||||||
#ifndef NORADIUS
 | 
					#ifndef NORADIUS
 | 
				
			||||||
  pthread_mutex_init(&rad_mutex, NULL);
 | 
					  pthread_mutex_init(&rad_mutex, NULL);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					  initlog();
 | 
				
			||||||
  freeconf(&conf);
 | 
					  freeconf(&conf);
 | 
				
			||||||
  res = readconfig(fp);
 | 
					  res = readconfig(fp);
 | 
				
			||||||
  conf.version++;
 | 
					  conf.version++;
 | 
				
			||||||
 | 
				
			|||||||
@ -26,50 +26,52 @@ ftp$(OBJSUFFICS): ftp.c proxy.h structures.h
 | 
				
			|||||||
sockgetchar$(OBJSUFFICS): sockgetchar.c proxy.h structures.h
 | 
					sockgetchar$(OBJSUFFICS): sockgetchar.c proxy.h structures.h
 | 
				
			||||||
	$(CC) $(CFLAGS) sockgetchar.c
 | 
						$(CC) $(CFLAGS) sockgetchar.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
proxy$(OBJSUFFICS): proxy.c proxy.h structures.h proxymain.c
 | 
					proxy$(OBJSUFFICS): proxy.c proxy.h structures.h proxymain.c log.c
 | 
				
			||||||
	$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP $(DEFINEOPTION)ANONYMOUS proxy.c
 | 
						$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP $(DEFINEOPTION)ANONYMOUS proxy.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pop3p$(OBJSUFFICS): pop3p.c proxy.h structures.h proxymain.c
 | 
					pop3p$(OBJSUFFICS): pop3p.c proxy.h structures.h proxymain.c log.c
 | 
				
			||||||
	$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP pop3p.c
 | 
						$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP pop3p.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
smtpp$(OBJSUFFICS): smtpp.c proxy.h structures.h proxymain.c
 | 
					smtpp$(OBJSUFFICS): smtpp.c proxy.h structures.h proxymain.c log.c
 | 
				
			||||||
	$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP smtpp.c
 | 
						$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP smtpp.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ftppr$(OBJSUFFICS): ftppr.c proxy.h structures.h proxymain.c
 | 
					ftppr$(OBJSUFFICS): ftppr.c proxy.h structures.h proxymain.c log.c
 | 
				
			||||||
	$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP ftppr.c
 | 
						$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP ftppr.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
tcppm$(OBJSUFFICS): tcppm.c proxy.h structures.h proxymain.c
 | 
					tcppm$(OBJSUFFICS): tcppm.c proxy.h structures.h proxymain.c log.c
 | 
				
			||||||
	$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP tcppm.c
 | 
						$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP tcppm.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
socks$(OBJSUFFICS): socks.c proxy.h structures.h proxymain.c
 | 
					socks$(OBJSUFFICS): socks.c proxy.h structures.h proxymain.c log.c
 | 
				
			||||||
	$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP socks.c
 | 
						$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)NOPORTMAP socks.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
udppm$(OBJSUFFICS): udppm.c proxy.h structures.h proxymain.c
 | 
					udppm$(OBJSUFFICS): udppm.c proxy.h structures.h proxymain.c log.c
 | 
				
			||||||
	$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP udppm.c
 | 
						$(CC) $(CFLAGS) $(DEFINEOPTION)WITHMAIN $(DEFINEOPTION)PORTMAP udppm.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
3proxy$(OBJSUFFICS): 3proxy.c proxy.h structures.h
 | 
					3proxy$(OBJSUFFICS): 3proxy.c proxy.h structures.h
 | 
				
			||||||
	$(CC) $(CFLAGS) 3proxy.c
 | 
						$(CC) $(CFLAGS) 3proxy.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(BUILDDIR)proxy$(EXESUFFICS): sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS)
 | 
					$(BUILDDIR)proxy$(EXESUFFICS): sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS)
 | 
				
			||||||
	$(LN) $(LNOUT)$(BUILDDIR)proxy$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
 | 
						$(LN) $(LNOUT)$(BUILDDIR)proxy$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) proxy$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(BUILDDIR)pop3p$(EXESUFFICS): sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) $(COMPATLIBS)
 | 
					$(BUILDDIR)pop3p$(EXESUFFICS): sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
 | 
				
			||||||
	$(LN) $(LNOUT)$(BUILDDIR)pop3p$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
 | 
						$(LN) $(LNOUT)$(BUILDDIR)pop3p$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) pop3p$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(BUILDDIR)smtpp$(EXESUFFICS): sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) base64$(OBJSUFFICS) $(COMPATLIBS)
 | 
					$(BUILDDIR)smtpp$(EXESUFFICS): sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) base64$(OBJSUFFICS) $(COMPATLIBS)
 | 
				
			||||||
	$(LN) $(LNOUT)$(BUILDDIR)smtpp$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) base64$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
 | 
						$(LN) $(LNOUT)$(BUILDDIR)smtpp$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) smtpp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) base64$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(BUILDDIR)ftppr$(EXESUFFICS): sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) ftp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) $(COMPATLIBS)
 | 
					$(BUILDDIR)ftppr$(EXESUFFICS): sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) ftp$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) $(COMPATLIBS)
 | 
				
			||||||
	$(LN) $(LNOUT)$(BUILDDIR)ftppr$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
 | 
						$(LN) $(LNOUT)$(BUILDDIR)ftppr$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) ftppr$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) ftp$(OBJSUFFICS) $(COMPATLIBS) $(LIBS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(BUILDDIR)socks$(EXESUFFICS): sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
 | 
					$(BUILDDIR)socks$(EXESUFFICS): sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS)
 | 
				
			||||||
	$(LN) $(LNOUT)$(BUILDDIR)socks$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
 | 
						$(LN) $(LNOUT)$(BUILDDIR)socks$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) socks$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(BUILDDIR)tcppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
 | 
					$(BUILDDIR)tcppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) common$(OBJSUFFICS)
 | 
				
			||||||
	$(LN) $(LNOUT)$(BUILDDIR)tcppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
 | 
						$(LN) $(LNOUT)$(BUILDDIR)tcppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) tcppm$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(BUILDDIR)udppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS)
 | 
					$(BUILDDIR)udppm$(EXESUFFICS): sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) common$(OBJSUFFICS)
 | 
				
			||||||
	$(LN) $(LNOUT)$(BUILDDIR)udppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) log$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
 | 
						$(LN) $(LNOUT)$(BUILDDIR)udppm$(EXESUFFICS) $(LDFLAGS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) udppm$(OBJSUFFICS) common$(OBJSUFFICS) $(LIBS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mainfunc$(OBJSUFFICS): proxy.h structures.h proxymain.c
 | 
					mainfunc$(OBJSUFFICS): proxy.h structures.h proxymain.c
 | 
				
			||||||
	$(CC) $(COUT)mainfunc$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)MODULEMAINFUNC=mainfunc proxymain.c
 | 
						$(CC) $(COUT)mainfunc$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)MODULEMAINFUNC=mainfunc proxymain.c
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										152
									
								
								src/auth.c
									
									
									
									
									
								
							
							
						
						
									
										152
									
								
								src/auth.c
									
									
									
									
									
								
							@ -1341,155 +1341,3 @@ unsigned long fakeresolver (int af, unsigned char *name, unsigned char * value){
 | 
				
			|||||||
 }
 | 
					 }
 | 
				
			||||||
 return 1;
 | 
					 return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NOODBC
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
SQLHENV  henv = NULL;
 | 
					 | 
				
			||||||
SQLHSTMT hstmt = NULL;
 | 
					 | 
				
			||||||
SQLHDBC hdbc = NULL;
 | 
					 | 
				
			||||||
char * sqlstring = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void close_sql(){
 | 
					 | 
				
			||||||
	if(hstmt) {
 | 
					 | 
				
			||||||
		SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
 | 
					 | 
				
			||||||
		hstmt = NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(hdbc){
 | 
					 | 
				
			||||||
		SQLDisconnect(hdbc);
 | 
					 | 
				
			||||||
		SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
 | 
					 | 
				
			||||||
		hdbc = NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(henv) {
 | 
					 | 
				
			||||||
		SQLFreeHandle(SQL_HANDLE_ENV, henv);
 | 
					 | 
				
			||||||
		henv = NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int attempt = 0;
 | 
					 | 
				
			||||||
time_t attempt_time = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int init_sql(char * s){
 | 
					 | 
				
			||||||
	SQLRETURN  retcode;
 | 
					 | 
				
			||||||
	char * datasource;
 | 
					 | 
				
			||||||
	char * username;
 | 
					 | 
				
			||||||
	char * password;
 | 
					 | 
				
			||||||
	char * string;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!s) return 0;
 | 
					 | 
				
			||||||
	if(!sqlstring || strcmp(sqlstring, s)){
 | 
					 | 
				
			||||||
		string = sqlstring;
 | 
					 | 
				
			||||||
		sqlstring=mystrdup(s);
 | 
					 | 
				
			||||||
		if(string)myfree(string);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(hstmt || hdbc || henv) close_sql();
 | 
					 | 
				
			||||||
	attempt++;
 | 
					 | 
				
			||||||
	attempt_time = time(0);
 | 
					 | 
				
			||||||
	if(!henv){
 | 
					 | 
				
			||||||
		retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
 | 
					 | 
				
			||||||
		if (!henv || (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)){
 | 
					 | 
				
			||||||
			henv = NULL;
 | 
					 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) {
 | 
					 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(!hdbc){
 | 
					 | 
				
			||||||
		retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc); 
 | 
					 | 
				
			||||||
		if (!hdbc || (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)) {
 | 
					 | 
				
			||||||
			hdbc = NULL;
 | 
					 | 
				
			||||||
			SQLFreeHandle(SQL_HANDLE_ENV, henv);
 | 
					 | 
				
			||||||
			henv = NULL;
 | 
					 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	       	SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (void*)15, 0);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	string = mystrdup(sqlstring);
 | 
					 | 
				
			||||||
	if(!string) return 0;
 | 
					 | 
				
			||||||
	datasource = strtok(string, ",");
 | 
					 | 
				
			||||||
	username = strtok(NULL, ",");
 | 
					 | 
				
			||||||
	password = strtok(NULL, ",");
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
         /* Connect to data source */
 | 
					 | 
				
			||||||
        retcode = SQLConnect(hdbc, (SQLCHAR*) datasource, (SQLSMALLINT)strlen(datasource),
 | 
					 | 
				
			||||||
                (SQLCHAR*) username, (SQLSMALLINT)((username)?strlen(username):0),
 | 
					 | 
				
			||||||
                (SQLCHAR*) password, (SQLSMALLINT)((password)?strlen(password):0));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	myfree(string);
 | 
					 | 
				
			||||||
	if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO){
 | 
					 | 
				
			||||||
		SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
 | 
					 | 
				
			||||||
		hdbc = NULL;
 | 
					 | 
				
			||||||
		SQLFreeHandle(SQL_HANDLE_ENV, henv);
 | 
					 | 
				
			||||||
		henv = NULL;
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
        retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt); 
 | 
					 | 
				
			||||||
        if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO){
 | 
					 | 
				
			||||||
		close_sql();
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void sqlerr (char *buf){
 | 
					 | 
				
			||||||
	if(conf.stdlog){
 | 
					 | 
				
			||||||
		fprintf(conf.stdlog, "%s\n", buf);
 | 
					 | 
				
			||||||
		fflush(conf.stdlog);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	pthread_mutex_unlock(&log_mutex);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
unsigned char statbuf[8192];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void logsql(struct clientparam * param, const unsigned char *s) {
 | 
					 | 
				
			||||||
	SQLRETURN ret;
 | 
					 | 
				
			||||||
	int len;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(param->nolog) return;
 | 
					 | 
				
			||||||
	pthread_mutex_lock(&log_mutex);
 | 
					 | 
				
			||||||
	len = dobuf(param, statbuf, s, (unsigned char *)"\'");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(attempt > 5){
 | 
					 | 
				
			||||||
		time_t t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		t = time(0);
 | 
					 | 
				
			||||||
		if (t - attempt_time < 180){
 | 
					 | 
				
			||||||
			sqlerr((char *)statbuf);
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(!hstmt){
 | 
					 | 
				
			||||||
		if(!init_sql(sqlstring)) {
 | 
					 | 
				
			||||||
			sqlerr((char *)statbuf);
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(hstmt){
 | 
					 | 
				
			||||||
		ret = SQLExecDirect(hstmt, (SQLCHAR *)statbuf, (SQLINTEGER)len);
 | 
					 | 
				
			||||||
		if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
 | 
					 | 
				
			||||||
			close_sql();
 | 
					 | 
				
			||||||
			if(!init_sql(sqlstring)){
 | 
					 | 
				
			||||||
				sqlerr((char *)statbuf);
 | 
					 | 
				
			||||||
				return;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(hstmt) {
 | 
					 | 
				
			||||||
				ret = SQLExecDirect(hstmt, (SQLCHAR *)statbuf, (SQLINTEGER)len);
 | 
					 | 
				
			||||||
				if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
 | 
					 | 
				
			||||||
					sqlerr((char *)statbuf);
 | 
					 | 
				
			||||||
					return;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				attempt = 0;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		attempt = 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	pthread_mutex_unlock(&log_mutex);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -293,13 +293,14 @@ typedef struct radius_packet_t {
 | 
				
			|||||||
  uint8_t       id;
 | 
					  uint8_t       id;
 | 
				
			||||||
  uint16_t      length;
 | 
					  uint16_t      length;
 | 
				
			||||||
  uint8_t       vector[AUTH_VECTOR_LEN];
 | 
					  uint8_t       vector[AUTH_VECTOR_LEN];
 | 
				
			||||||
  uint8_t       data[4096];
 | 
					  uint8_t       data[2048];
 | 
				
			||||||
} radius_packet_t;
 | 
					} radius_packet_t;
 | 
				
			||||||
          
 | 
					          
 | 
				
			||||||
#define RETURN(xxx) { res = xxx; goto CLEANRET; }
 | 
					#define RETURN(xxx) { res = xxx; goto CLEANRET; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int radsend(struct clientparam * param, int auth, int stop){
 | 
					#define packet (*(radius_packet_t *buf))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int radbuf(struct clientparam * param, unsigned char * buf, int auth, int stop){
 | 
				
			||||||
	int loop;
 | 
						int loop;
 | 
				
			||||||
	int id;
 | 
						int id;
 | 
				
			||||||
	int res = 4;
 | 
						int res = 4;
 | 
				
			||||||
@ -308,15 +309,7 @@ int radsend(struct clientparam * param, int auth, int stop){
 | 
				
			|||||||
	int total_length;
 | 
						int total_length;
 | 
				
			||||||
	int len;
 | 
						int len;
 | 
				
			||||||
	int op;
 | 
						int op;
 | 
				
			||||||
#ifdef NOIPV6
 | 
					 | 
				
			||||||
	struct  sockaddr_in     saremote;
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
	struct  sockaddr_in6     saremote;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	struct pollfd fds[1];
 | 
					 | 
				
			||||||
	char vector[AUTH_VECTOR_LEN];
 | 
						char vector[AUTH_VECTOR_LEN];
 | 
				
			||||||
	radius_packet_t packet, rpacket;
 | 
					 | 
				
			||||||
	SASIZETYPE salen;
 | 
					 | 
				
			||||||
	int data_len;
 | 
						int data_len;
 | 
				
			||||||
	uint8_t	*vendor_len;
 | 
						uint8_t	*vendor_len;
 | 
				
			||||||
	int count=0;
 | 
						int count=0;
 | 
				
			||||||
@ -325,9 +318,8 @@ int radsend(struct clientparam * param, int auth, int stop){
 | 
				
			|||||||
	int vendorlen=0;
 | 
						int vendorlen=0;
 | 
				
			||||||
	char buf[64];
 | 
						char buf[64];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!radiussecret || !nradservers) {
 | 
						if(!radiussecret || !nradservers) {
 | 
				
			||||||
		return 4;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memset(&packet, 0, sizeof(packet));
 | 
						memset(&packet, 0, sizeof(packet));
 | 
				
			||||||
@ -526,6 +518,38 @@ int radsend(struct clientparam * param, int auth, int stop){
 | 
				
			|||||||
		md5_calc(packet.vector, (u_char *)&packet, total_length + len);
 | 
							md5_calc(packet.vector, (u_char *)&packet, total_length + len);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	memcpy(vector, packet.vector, AUTH_VECTOR_LEN);
 | 
						memcpy(vector, packet.vector, AUTH_VECTOR_LEN);
 | 
				
			||||||
 | 
						return total_length;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int radsend(const char *buf, int total_length, int auth){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int loop;
 | 
				
			||||||
 | 
						int id;
 | 
				
			||||||
 | 
						int res = 4;
 | 
				
			||||||
 | 
						SOCKET sockfd = -1;
 | 
				
			||||||
 | 
						unsigned char *ptr;
 | 
				
			||||||
 | 
						int len;
 | 
				
			||||||
 | 
						int op;
 | 
				
			||||||
 | 
					#ifdef NOIPV6
 | 
				
			||||||
 | 
						struct  sockaddr_in     saremote;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
						struct  sockaddr_in6     saremote;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
						struct pollfd fds[1];
 | 
				
			||||||
 | 
						char vector[AUTH_VECTOR_LEN];
 | 
				
			||||||
 | 
						radius_packet_t packet, rpacket;
 | 
				
			||||||
 | 
						SASIZETYPE salen;
 | 
				
			||||||
 | 
						int data_len;
 | 
				
			||||||
 | 
						uint8_t	*vendor_len;
 | 
				
			||||||
 | 
						int count=0;
 | 
				
			||||||
 | 
						uint8_t *attr;
 | 
				
			||||||
 | 
						long vendor=0;
 | 
				
			||||||
 | 
						int vendorlen=0;
 | 
				
			||||||
 | 
						char buf[64];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	for (loop = 0; loop < nradservers && loop < MAXRADIUS; loop++) {
 | 
						for (loop = 0; loop < nradservers && loop < MAXRADIUS; loop++) {
 | 
				
			||||||
		SOCKET remsock;
 | 
							SOCKET remsock;
 | 
				
			||||||
@ -656,14 +680,20 @@ CLEANRET:
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int radauth(struct clientparam * param){
 | 
					int radauth(struct clientparam * param){
 | 
				
			||||||
 | 
						radius_packet_t packet;
 | 
				
			||||||
 | 
						int len;
 | 
				
			||||||
	/*radsend(param, 0, 0);*/
 | 
						/*radsend(param, 0, 0);*/
 | 
				
			||||||
	return radsend(param, 1, 0);
 | 
						len = radbuf(param, buf, 1, 0);
 | 
				
			||||||
 | 
						return len?radsend(buf, len, 1):4;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void logradius(struct clientparam * param, const unsigned char *s) {
 | 
					
 | 
				
			||||||
	radsend(param, 0, 1);
 | 
					int raddobuf(struct clientparam * param, unsigned char * buf, const unsigned char *s){
 | 
				
			||||||
	if(param->trafcountfunc)(*param->trafcountfunc)(param);
 | 
						return radbuf(param, buf, 0, 1);
 | 
				
			||||||
	clearstat(param);
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void logradius(const unsigned char *buf, int len, LOGGER *logger){
 | 
				
			||||||
 | 
						if(len)radsend(buf, len, 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -116,7 +116,6 @@ struct extparam conf = {
 | 
				
			|||||||
	NULL,
 | 
						NULL,
 | 
				
			||||||
	NULL,
 | 
						NULL,
 | 
				
			||||||
	doconnect,
 | 
						doconnect,
 | 
				
			||||||
	lognone,
 | 
					 | 
				
			||||||
	NULL,
 | 
						NULL,
 | 
				
			||||||
	NULL,
 | 
						NULL,
 | 
				
			||||||
	NULL, NULL,
 | 
						NULL, NULL,
 | 
				
			||||||
 | 
				
			|||||||
@ -295,7 +295,7 @@ static int h_log(int argc, unsigned char ** argv){
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	if(argc > 1) {
 | 
						if(argc > 1) {
 | 
				
			||||||
		if(!strcmp((char *) argv[1], "/dev/null")) {
 | 
							if(!strcmp((char *) argv[1], "/dev/null")) {
 | 
				
			||||||
			conf.logfunc = lognone;
 | 
								conf.logfunc = NULL;
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if(!notchanged) conf.logtarget = (unsigned char *)mystrdup((char *)argv[1]);
 | 
							if(!notchanged) conf.logtarget = (unsigned char *)mystrdup((char *)argv[1]);
 | 
				
			||||||
@ -1780,7 +1780,7 @@ void freeconf(struct extparam *confp){
 | 
				
			|||||||
 logname = confp->logname;
 | 
					 logname = confp->logname;
 | 
				
			||||||
 confp->logname = NULL;
 | 
					 confp->logname = NULL;
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 confp->logfunc = lognone;
 | 
					 confp->logfunc = NULL;
 | 
				
			||||||
 logformat = confp->logformat;
 | 
					 logformat = confp->logformat;
 | 
				
			||||||
 confp->logformat = NULL;
 | 
					 confp->logformat = NULL;
 | 
				
			||||||
 confp->rotate = 0;
 | 
					 confp->rotate = 0;
 | 
				
			||||||
 | 
				
			|||||||
@ -523,7 +523,7 @@ static void * ef_server_childcount(struct node * node){
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void * ef_server_log(struct node * node){
 | 
					static void * ef_server_log(struct node * node){
 | 
				
			||||||
	if(((struct srvparam *)node->value) -> logfunc == lognone)	return "none";
 | 
						if(((struct srvparam *)node->value) -> logfunc == NULL)	return "none";
 | 
				
			||||||
#ifndef NORADIUS
 | 
					#ifndef NORADIUS
 | 
				
			||||||
	else if(((struct srvparam *)node->value) -> logfunc == logradius)	return "radius";
 | 
						else if(((struct srvparam *)node->value) -> logfunc == logradius)	return "radius";
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -333,4 +333,5 @@ struct proxydef childdef = {
 | 
				
			|||||||
	" -hdefault_host[:port] - use this host and port as default if no host specified\n"
 | 
						" -hdefault_host[:port] - use this host and port as default if no host specified\n"
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#include "proxymain.c"
 | 
					#include "proxymain.c"
 | 
				
			||||||
 | 
					#include "log.c"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										381
									
								
								src/log.c
									
									
									
									
									
								
							
							
						
						
									
										381
									
								
								src/log.c
									
									
									
									
									
								
							@ -6,9 +6,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "proxy.h"
 | 
					#include "proxy.h"
 | 
				
			||||||
pthread_mutex_t log_mutex;
 | 
					pthread_mutex_t log_mutex;
 | 
				
			||||||
int havelog = 0;
 | 
					int havelog = 0;
 | 
				
			||||||
@ -17,19 +14,95 @@ int havelog = 0;
 | 
				
			|||||||
struct clientparam logparam;
 | 
					struct clientparam logparam;
 | 
				
			||||||
struct srvparam logsrv;
 | 
					struct srvparam logsrv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct LOGGER;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void(*prelog)(struct clientparam * param) = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef WITHMAIN
 | 
				
			||||||
 | 
					#define HAVERADIUS 0
 | 
				
			||||||
 | 
					#define HAVESQL 0
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					int raddobuf(struct clientparam * param, unsigned char * buf, const unsigned char *s);
 | 
				
			||||||
 | 
					void logradius(const char * buf, int len, struct LOGGER *logger);
 | 
				
			||||||
 | 
					#define HAVERADIUS 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef NOODBC
 | 
				
			||||||
 | 
					#undef HAVESQL
 | 
				
			||||||
 | 
					#define HAVESQL 1
 | 
				
			||||||
 | 
					static int sqlinit(const char * selector, int logtype, struct LOGGER *logger);
 | 
				
			||||||
 | 
					static void sqllog(const char * buf, int len, struct LOGGER *logger);
 | 
				
			||||||
 | 
					static void sqlrotate(struct LOGGER *logger);
 | 
				
			||||||
 | 
					static void sqlclose(struct LOGGER *logger);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef _WIN32
 | 
				
			||||||
 | 
					#define HAVESYSLOG 0
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#define HAVESYSLOG 1
 | 
				
			||||||
 | 
					static int sysloginit(const char * selector, int logtype, struct LOGGER *logger);
 | 
				
			||||||
 | 
					static void logsyslog(const char * buf, int len, struct LOGGER *logger);
 | 
				
			||||||
 | 
					static void syslogrotate(struct LOGGER *logger);
 | 
				
			||||||
 | 
					static void syslogclose(struct LOGGER *logger);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int stdloginit(const char * selector, int logtype, struct LOGGER *logger);
 | 
				
			||||||
 | 
					static void stdlog(const char * buf, int len, struct LOGGER *logger);
 | 
				
			||||||
 | 
					static void stdlogrotate(struct LOGGER *logger);
 | 
				
			||||||
 | 
					static void stdlogclose(struct LOGGER *logger);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct LOGFUNC logfuncs = {
 | 
				
			||||||
 | 
					#if HAVESYSLOG > 0
 | 
				
			||||||
 | 
							{logfuncs+1+HAVESYSLOG, sysloginit, stddobuf, logsyslog, syslogrotate, syslogclose, "@"},
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#if HAVERADIUS > 0
 | 
				
			||||||
 | 
							{logfuncs+1+HAVESYSLOG+HAVERADIUS, NULL, raddobuf, logradius, NULL, NULL, "radius"},
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#if HAVESQL > 0
 | 
				
			||||||
 | 
							{logfuncs+1+HAVESYSLOG+HAVERADIUS+HAVESQL, sqlinit, sqldobuf, sqllog, sqlrotate, sqlclose, "&"},
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
							{NULL, stdloginit, stddobuf, stdlog, stdlogrotate, stdlogclose, ""}
 | 
				
			||||||
 | 
						     };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct LOGGER *loggers = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct stdlogdata{
 | 
				
			||||||
 | 
						FILE *fp;
 | 
				
			||||||
 | 
					} errld= {stderr};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct LOGGER {
 | 
				
			||||||
 | 
						char * selector;
 | 
				
			||||||
 | 
						void * data;
 | 
				
			||||||
 | 
						struct LOGFUNC *logfunc;
 | 
				
			||||||
 | 
						int rotate;
 | 
				
			||||||
 | 
						time_t rotated;
 | 
				
			||||||
 | 
						int registered;
 | 
				
			||||||
 | 
					} errlogger = {"errlogger", &errld, logfuncs+1+HAVESYSLOG+HAVERADIUS+HAVESQL, 0, 0, 1};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void initlog(void){
 | 
				
			||||||
 | 
						srvinit(&logsrv, &logparam);
 | 
				
			||||||
 | 
						pthread_mutex_init(&log_mutex, NULL);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dolog(struct clientparam * param, const unsigned char *s){
 | 
					void dolog(struct clientparam * param, const unsigned char *s){
 | 
				
			||||||
	static int init = 0;
 | 
						static int init = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(param)param->srv->logfunc(param, s);
 | 
					/* TODO: dobuf */
 | 
				
			||||||
	else {
 | 
					/* TODO: spooling */
 | 
				
			||||||
		if(!init){
 | 
						if(!param){
 | 
				
			||||||
			srvinit(&logsrv, &logparam);
 | 
							stdlog(s, strlen(s), &stdlogger);
 | 
				
			||||||
			init = 1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		logstdout(&logparam, s);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						else if(!param->nolog && param->srv->logtarget){
 | 
				
			||||||
 | 
							if(prelog)prelog(param);
 | 
				
			||||||
 | 
							param->srv->logfunc(param, s);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if(param->trafcountfunc)(*param->trafcountfunc)(param);
 | 
				
			||||||
 | 
						clearstat(param);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -318,37 +391,285 @@ int dobuf(struct clientparam * param, unsigned char * buf, const unsigned char *
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	time(&t);
 | 
						time(&t);
 | 
				
			||||||
	if(!param) return 0;
 | 
						if(!param) return 0;
 | 
				
			||||||
	if(param->trafcountfunc)(*param->trafcountfunc)(param);
 | 
					 | 
				
			||||||
	format = param->srv->logformat?(char *)param->srv->logformat : DEFLOGFORMAT;
 | 
						format = param->srv->logformat?(char *)param->srv->logformat : DEFLOGFORMAT;
 | 
				
			||||||
	tm = (*format == 'G' || *format == 'g')?
 | 
						tm = (*format == 'G' || *format == 'g')?
 | 
				
			||||||
		gmtime(&t) : localtime(&t);
 | 
							gmtime(&t) : localtime(&t);
 | 
				
			||||||
	i = dobuf2(param, buf, s, doublec, tm, format + 1);
 | 
						i = dobuf2(param, buf, s, doublec, tm, format + 1);
 | 
				
			||||||
	clearstat(param);
 | 
					 | 
				
			||||||
	return i;
 | 
						return i;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void lognone(struct clientparam * param, const unsigned char *s) {
 | 
					
 | 
				
			||||||
	if(param->trafcountfunc)(*param->trafcountfunc)(param);
 | 
					static int stdloginit(const char * selector, int logtype, struct LOGGER *logger){
 | 
				
			||||||
	clearstat(param);
 | 
						char tmpuf[1024];
 | 
				
			||||||
 | 
						struct stdlogdata *lp;
 | 
				
			||||||
 | 
						lp = myalloc(sizeof(struct stdlogdata));
 | 
				
			||||||
 | 
						if(!lp) return 1;
 | 
				
			||||||
 | 
						logger->data = lp;
 | 
				
			||||||
 | 
						if(!selector || !*selector){
 | 
				
			||||||
 | 
							logger-rotate = NONE;
 | 
				
			||||||
 | 
							lp->fp = stdout;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else {
 | 
				
			||||||
 | 
							logger->rotate = logtype;
 | 
				
			||||||
 | 
							lp->fp = fopen((char *)dologname (tmpbuf, conf.logname, NULL, logtype, time(NULL)), "a");
 | 
				
			||||||
 | 
							if(!lp->fp){
 | 
				
			||||||
 | 
								myfree(lp);
 | 
				
			||||||
 | 
								return(2);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void logstdout(struct clientparam * param, const unsigned char *s) {
 | 
					int stddobuf(struct clientparam * param, unsigned char * buf, const unsigned char *s){
 | 
				
			||||||
	FILE *log;
 | 
						return dobuf(param, buf, s, NULL);
 | 
				
			||||||
	unsigned char tmpbuf[8192];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	dobuf(param, tmpbuf, s, NULL);
 | 
					 | 
				
			||||||
	log = param->srv->stdlog?param->srv->stdlog:conf.stdlog?conf.stdlog:stdout;
 | 
					 | 
				
			||||||
	if(!param->nolog)if(fprintf(log, "%s\n", tmpbuf) < 0) {
 | 
					 | 
				
			||||||
		perror("printf()");
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
	if(log != conf.stdlog)fflush(log);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#ifndef _WIN32
 | 
					 | 
				
			||||||
void logsyslog(struct clientparam * param, const unsigned char *s) {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	unsigned char tmpbuf[8192];
 | 
					void stdlog(struct clientparam * param, const unsigned char *s, struct LOGGER *logger) {
 | 
				
			||||||
	dobuf(param, tmpbuf, s, NULL);
 | 
						FILE *log = (struct stdlogdata *)logger->data;
 | 
				
			||||||
	if(!param->nolog)syslog(LOG_INFO, "%s", tmpbuf);
 | 
					
 | 
				
			||||||
 | 
						fprintf(log, "%s\n", buf);
 | 
				
			||||||
 | 
						if(log == stdout || log == stderr)fflush(log);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void stdlogrotate(struct LOGGER *logger){
 | 
				
			||||||
 | 
					 char tmpuf[1024];
 | 
				
			||||||
 | 
					 struct stdlogdata *lp = (struct stdlogdata)logger->data;
 | 
				
			||||||
 | 
					 if(lp->fp) lp->fp = freopen((char *)dologname (tmpbuf, logger->selector, NULL, logger->rotate, conf.time), "a", lp->fp);
 | 
				
			||||||
 | 
					 else lp->fp = fopen((char *)dologname (tmpbuf, logger->selector, NULL, logger->rotate, conf.time), "a");
 | 
				
			||||||
 | 
					 conf.logtime = conf.time;
 | 
				
			||||||
 | 
					 if(logger->rotate) {
 | 
				
			||||||
 | 
						int t;
 | 
				
			||||||
 | 
						t = 1;
 | 
				
			||||||
 | 
						switch(logger->rotate){
 | 
				
			||||||
 | 
							case ANNUALLY:
 | 
				
			||||||
 | 
								t = t * 12;
 | 
				
			||||||
 | 
							case MONTHLY:
 | 
				
			||||||
 | 
								t = t * 4;
 | 
				
			||||||
 | 
							case WEEKLY:
 | 
				
			||||||
 | 
								t = t * 7;
 | 
				
			||||||
 | 
							case DAILY:
 | 
				
			||||||
 | 
								t = t * 24;
 | 
				
			||||||
 | 
							case HOURLY:
 | 
				
			||||||
 | 
								t = t * 60;
 | 
				
			||||||
 | 
							case MINUTELY:
 | 
				
			||||||
 | 
								t = t * 60;
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						dologname (tmpbuf, logger->selector, (conf.archiver)?conf.archiver[1]:NULL, logger->rotate, (conf.logtime - t * conf.rotate));
 | 
				
			||||||
 | 
						remove ((char *) tmpbuf);
 | 
				
			||||||
 | 
						if(conf.archiver) {
 | 
				
			||||||
 | 
							int i;
 | 
				
			||||||
 | 
							*tmpbuf = 0;
 | 
				
			||||||
 | 
							for(i = 2; i < conf.archiverc && strlen((char *)tmpbuf) < 512; i++){
 | 
				
			||||||
 | 
								strcat((char *)tmpbuf, " ");
 | 
				
			||||||
 | 
								if(!strcmp((char *)conf.archiver[i], "%A")){
 | 
				
			||||||
 | 
									strcat((char *)tmpbuf, "\"");
 | 
				
			||||||
 | 
									dologname (tmpbuf + strlen((char *)tmpbuf), logger->selector, conf.archiver[1], logger->rotate, (conf.logtime - t));
 | 
				
			||||||
 | 
									strcat((char *)tmpbuf, "\"");
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else if(!strcmp((char *)conf.archiver[i], "%F")){
 | 
				
			||||||
 | 
									strcat((char *)tmpbuf, "\"");
 | 
				
			||||||
 | 
									dologname (tmpbuf+strlen((char *)tmpbuf), logger->selector, NULL, logger->rotate, (conf.logtime-t));
 | 
				
			||||||
 | 
									strcat((char *)tmpbuf, "\"");
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									strcat((char *)tmpbuf, (char *)conf.archiver[i]);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							system((char *)tmpbuf+1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void stdlogclose(struct LOGGER *logger){
 | 
				
			||||||
 | 
						fclose(((struct stdlogdata *)logger->data)->fp);
 | 
				
			||||||
 | 
						myfree(((struct stdlogdata *)logger->data)->fp);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if HAVESYSLOG > 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int sysloginit(const char * selector, int logtype, struct LOGGER *logger){
 | 
				
			||||||
 | 
						openlog(selector+1, LOG_PID, LOG_DAEMON);
 | 
				
			||||||
 | 
						logger->rotate = logtype;
 | 
				
			||||||
 | 
						logger->data = NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void logsyslog(const char * buf, int len, struct LOGGER *logger) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						syslog((param->res >= 90 && param->res<=99)?LOG_NOTICE:(param->res?LOG_WARNING:LOG_INFO), "%s", buf);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void syslogrotate(struct LOGGER *logger){
 | 
				
			||||||
 | 
						closelog();
 | 
				
			||||||
 | 
						openlog(logger->selector+1, LOG_PID, LOG_DAEMON);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void syslogclose(struct LOGGER *logger){
 | 
				
			||||||
 | 
						closelog();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if HAVESQL > 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct sqldata {
 | 
				
			||||||
 | 
						SQLHENV  henv;
 | 
				
			||||||
 | 
						SQLHSTMT hstmt;
 | 
				
			||||||
 | 
						SQLHDBC hdbc;
 | 
				
			||||||
 | 
						int attempt;
 | 
				
			||||||
 | 
						time_t attempt_time;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int sqlinit(const char * selector, int logtype, struct LOGGER *logger);
 | 
				
			||||||
 | 
					static void sqllog(struct clientparam * param, const unsigned char *s, LOGGER *logger);
 | 
				
			||||||
 | 
					static void sqlrotate(struct LOGGER *logger);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int sqlinit2(struct sqldata * sd, char * source){
 | 
				
			||||||
 | 
						SQLRETURN  retcode;
 | 
				
			||||||
 | 
						char * datasource;
 | 
				
			||||||
 | 
						char * username;
 | 
				
			||||||
 | 
						char * password;
 | 
				
			||||||
 | 
						char * string;
 | 
				
			||||||
 | 
						int ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &sd->henv);
 | 
				
			||||||
 | 
						if (!henv || (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)){
 | 
				
			||||||
 | 
							return 1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						retcode = SQLSetEnvAttr(sd->henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); 
 | 
				
			||||||
 | 
						if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) {
 | 
				
			||||||
 | 
							ret = 2;
 | 
				
			||||||
 | 
							goto CLOSEENV:
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &sd->hdbc); 
 | 
				
			||||||
 | 
						if (!sd->hdbc || (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)) {
 | 
				
			||||||
 | 
							ret = 3;
 | 
				
			||||||
 | 
							goto CLOSEENV:	
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					       	SQLSetConnectAttr(sd->hdbc, SQL_LOGIN_TIMEOUT, (void*)15, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						string = mystrdup(source);
 | 
				
			||||||
 | 
						if(!string) goto CLOSEHDBC;
 | 
				
			||||||
 | 
						datasource = strtok(string, ",");
 | 
				
			||||||
 | 
						username = strtok(NULL, ",");
 | 
				
			||||||
 | 
						password = strtok(NULL, ",");
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         /* Connect to data source */
 | 
				
			||||||
 | 
					        retcode = SQLConnect(sd->hdbc, (SQLCHAR*) datasource, (SQLSMALLINT)strlen(datasource),
 | 
				
			||||||
 | 
					                (SQLCHAR*) username, (SQLSMALLINT)((username)?strlen(username):0),
 | 
				
			||||||
 | 
					                (SQLCHAR*) password, (SQLSMALLINT)((password)?strlen(password):0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						myfree(string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO){
 | 
				
			||||||
 | 
							ret = 4;
 | 
				
			||||||
 | 
							goto CLOSEHDBC;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        retcode = SQLAllocHandle(SQL_HANDLE_STMT, sd->hdbc, &sd->hstmt); 
 | 
				
			||||||
 | 
					        if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO){
 | 
				
			||||||
 | 
							sd->hstmt = 0;
 | 
				
			||||||
 | 
							ret = 5;
 | 
				
			||||||
 | 
							goto CLOSEHDBC;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CLOSEHDBC:
 | 
				
			||||||
 | 
						SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
 | 
				
			||||||
 | 
						sd->hdbc = 0;
 | 
				
			||||||
 | 
					CLOSEENV:
 | 
				
			||||||
 | 
						SQLFreeHandle(SQL_HANDLE_ENV, henv);
 | 
				
			||||||
 | 
						sd->henv = 0;
 | 
				
			||||||
 | 
						return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int sqlinit(const char * selector, int logtype, struct LOGGER *logger){
 | 
				
			||||||
 | 
						struct sqldata *sd;
 | 
				
			||||||
 | 
						int res
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						logger->rotate = logtype;
 | 
				
			||||||
 | 
						sd = (struct sqldata *)myalloc(sizeof(struct sqldata));
 | 
				
			||||||
 | 
						memset(sd, 0, sizeof(struct sqldata));
 | 
				
			||||||
 | 
						loger->data = sd;
 | 
				
			||||||
 | 
						if(!(res = sqlinit2(sd, selector+1))) {
 | 
				
			||||||
 | 
							myfree(sd);
 | 
				
			||||||
 | 
							return res;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int sqldobuf(struct clientparam * param, unsigned char * buf, const unsigned char *s){
 | 
				
			||||||
 | 
						return dobuf(param, buf, s, (unsigned char *)"\'");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void sqllog(const char * buf, int len, struct LOGGER *logger){
 | 
				
			||||||
 | 
						SQLRETURN ret;
 | 
				
			||||||
 | 
						struct sqldata *sd = (struct sqldata *)logger->data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(sd->attempt > 5){
 | 
				
			||||||
 | 
							if (conf.time - sd->attempt_time < 180){
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if(sd->attempt){
 | 
				
			||||||
 | 
							sd->attempt++;
 | 
				
			||||||
 | 
							sqlrotate(logger);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(!sd->hstmt){
 | 
				
			||||||
 | 
								sd->attempt_time=conf.time;
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						ret = SQLExecDirect(sd->hstmt, (SQLCHAR *)buf, (SQLINTEGER)len);
 | 
				
			||||||
 | 
						if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
 | 
				
			||||||
 | 
							sqlrotate(logger);
 | 
				
			||||||
 | 
							if(sd->hstmt) {
 | 
				
			||||||
 | 
								ret = SQLExecDirect(hstmt, (SQLCHAR *)buf, (SQLINTEGER)len);
 | 
				
			||||||
 | 
								if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
 | 
				
			||||||
 | 
									sd->attempt++;
 | 
				
			||||||
 | 
									sd->attempt_time=conf.time;
 | 
				
			||||||
 | 
									return;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						sd->attempt=0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void sqlrotate(struct LOGGER *logger){
 | 
				
			||||||
 | 
						struct sqldata * sd;
 | 
				
			||||||
 | 
						sqlclose(logger);
 | 
				
			||||||
 | 
						sd = (struct sqldata *)myalloc(sizeof(struct sqldata));
 | 
				
			||||||
 | 
						memset(sd, 0, sizeof(struct sqldata));
 | 
				
			||||||
 | 
						loger->data = sd;
 | 
				
			||||||
 | 
						sqlinit2(sd, logger->selector+1)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void sqlclose(struct LOGGER *logger){
 | 
				
			||||||
 | 
						struct sqldata *sd = (struct sqldata *)loger->data;
 | 
				
			||||||
 | 
						if(sd->hstmt) {
 | 
				
			||||||
 | 
							SQLFreeHandle(SQL_HANDLE_STMT, sd->hstmt);
 | 
				
			||||||
 | 
							sd->hstmt = NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if(sd->hdbc){
 | 
				
			||||||
 | 
							SQLDisconnect(sd->hdbc);
 | 
				
			||||||
 | 
							SQLFreeHandle(SQL_HANDLE_DBC, sd->hdbc);
 | 
				
			||||||
 | 
							sd->hdbc = NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if(sd->henv) {
 | 
				
			||||||
 | 
							SQLFreeHandle(SQL_HANDLE_ENV, sd->henv);
 | 
				
			||||||
 | 
							sd->henv = NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						myfree(sd);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
@ -73,7 +73,10 @@ struct symbol symbols[] = {
 | 
				
			|||||||
	{symbols+46, "decodeurl", (void *) decodeurl},
 | 
						{symbols+46, "decodeurl", (void *) decodeurl},
 | 
				
			||||||
	{symbols+47, "parsestr", (void *) parsestr},
 | 
						{symbols+47, "parsestr", (void *) parsestr},
 | 
				
			||||||
	{symbols+48, "make_ace", (void *) make_ace},
 | 
						{symbols+48, "make_ace", (void *) make_ace},
 | 
				
			||||||
	{symbols+49, "freeacl", (void *) freeacl},
 | 
						{symbols+49, "freeacl", (void *) freeacl}
 | 
				
			||||||
 | 
						{symbols+50, "dolog", (void *) dolog},
 | 
				
			||||||
 | 
						{symbols+50, "logfuncs", (void *) logfuncs},
 | 
				
			||||||
 | 
						{symbols+50, "prelog", (void *) prelog},
 | 
				
			||||||
	{NULL, "", NULL}
 | 
						{NULL, "", NULL}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -22,6 +22,9 @@ static struct commands ldap_trafgroup_handler;
 | 
				
			|||||||
static struct commands ldap_attrsgroup_handler;
 | 
					static struct commands ldap_attrsgroup_handler;
 | 
				
			||||||
static struct commands ldap_dircount_handler;
 | 
					static struct commands ldap_dircount_handler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void (*dolog)(struct clientparam * param, const unsigned char *s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static char   *attrs[] = { NULL, NULL};
 | 
					static char   *attrs[] = { NULL, NULL};
 | 
				
			||||||
static char   *ldap_group_attr;
 | 
					static char   *ldap_group_attr;
 | 
				
			||||||
static char   *ldap_access;
 | 
					static char   *ldap_access;
 | 
				
			||||||
@ -109,7 +112,7 @@ static int ldapfunc(struct clientparam *param)
 | 
				
			|||||||
  ld = ldap_init( ldap_serv, 389 );
 | 
					  ld = ldap_init( ldap_serv, 389 );
 | 
				
			||||||
  if ( ld == NULL ) 
 | 
					  if ( ld == NULL ) 
 | 
				
			||||||
   {
 | 
					   {
 | 
				
			||||||
    param->srv->logfunc(param,"Error ldap_init: No init lib ldap");
 | 
					    dolog(param,"Error ldap_init: No init lib ldap");
 | 
				
			||||||
    /*ldap_perror( ld, "Error ldap_init" ); */
 | 
					    /*ldap_perror( ld, "Error ldap_init" ); */
 | 
				
			||||||
    return 7; 
 | 
					    return 7; 
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
@ -133,7 +136,7 @@ static int ldapfunc(struct clientparam *param)
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  if ( rc != LDAP_SUCCESS ) 
 | 
					  if ( rc != LDAP_SUCCESS ) 
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
     param->srv->logfunc(param,"Error ldap_bind: No connect ldap catalog");
 | 
					     dolog(param,"Error ldap_bind: No connect ldap catalog");
 | 
				
			||||||
     ldap_unbind_s(ld);	
 | 
					     ldap_unbind_s(ld);	
 | 
				
			||||||
     return 7;
 | 
					     return 7;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -144,7 +147,7 @@ static int ldapfunc(struct clientparam *param)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if ( ld == NULL ) 
 | 
					  if ( ld == NULL ) 
 | 
				
			||||||
   {
 | 
					   {
 | 
				
			||||||
    param->srv->logfunc(param,"Error ldap_init: No init lib ldap");
 | 
					    dolog(param,"Error ldap_init: No init lib ldap");
 | 
				
			||||||
    /*ldap_perror( ld, "Error ldap_init" ); */
 | 
					    /*ldap_perror( ld, "Error ldap_init" ); */
 | 
				
			||||||
    return 7; 
 | 
					    return 7; 
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
@ -153,7 +156,7 @@ static int ldapfunc(struct clientparam *param)
 | 
				
			|||||||
 
 | 
					 
 | 
				
			||||||
   if ( rc != LDAP_SUCCESS ) 
 | 
					   if ( rc != LDAP_SUCCESS ) 
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
     param->srv->logfunc(param, "Error ldap_bind: Not authorize in ldap\
 | 
					     dolog(param, "Error ldap_bind: Not authorize in ldap\
 | 
				
			||||||
     catalog,  checked option \'ldapconnect\' ");
 | 
					     catalog,  checked option \'ldapconnect\' ");
 | 
				
			||||||
     ldap_unbind_s(ld);
 | 
					     ldap_unbind_s(ld);
 | 
				
			||||||
     return 7;
 | 
					     return 7;
 | 
				
			||||||
@ -472,6 +475,9 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink,
 | 
				
			|||||||
    return (0);
 | 
					    return (0);
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   dolog=pluginlink->findbyname("dolog");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   already_loaded = 1;
 | 
					   already_loaded = 1;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    mypluginlink=pluginlink;
 | 
					    mypluginlink=pluginlink;
 | 
				
			||||||
 | 
				
			|||||||
@ -28,6 +28,7 @@ extern "C" {
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PROXYFUNC tcppmfunc, proxyfunc, smtppfunc, ftpprfunc;
 | 
					PROXYFUNC tcppmfunc, proxyfunc, smtppfunc, ftpprfunc;
 | 
				
			||||||
 | 
					static void (*dolog)(struct clientparam * param, const unsigned char *s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct pluginlink * pl;
 | 
					static struct pluginlink * pl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -238,25 +239,25 @@ int dossl(struct clientparam* param, SSL_CONN* ServerConnp, SSL_CONN* ClientConn
 | 
				
			|||||||
 ServerConn = ssl_handshake_to_server(param->remsock, (char *)param->hostname, &ServerCert, &errSSL);
 | 
					 ServerConn = ssl_handshake_to_server(param->remsock, (char *)param->hostname, &ServerCert, &errSSL);
 | 
				
			||||||
 if ( ServerConn == NULL || ServerCert == NULL ) {
 | 
					 if ( ServerConn == NULL || ServerCert == NULL ) {
 | 
				
			||||||
	param->res = 8011;
 | 
						param->res = 8011;
 | 
				
			||||||
	param->srv->logfunc(param, (unsigned char *)"SSL handshake to server failed");
 | 
						dolog(param, (unsigned char *)"SSL handshake to server failed");
 | 
				
			||||||
	if(ServerConn == NULL) 	param->srv->logfunc(param, (unsigned char *)"ServerConn is NULL");
 | 
						if(ServerConn == NULL) 	dolog(param, (unsigned char *)"ServerConn is NULL");
 | 
				
			||||||
	if(ServerCert == NULL) 	param->srv->logfunc(param, (unsigned char *)"ServerCert is NULL");
 | 
						if(ServerCert == NULL) 	dolog(param, (unsigned char *)"ServerCert is NULL");
 | 
				
			||||||
	if(errSSL)param->srv->logfunc(param, (unsigned char *)errSSL);
 | 
						if(errSSL)dolog(param, (unsigned char *)errSSL);
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
 }
 | 
					 }
 | 
				
			||||||
 FakeCert = ssl_copy_cert(ServerCert);
 | 
					 FakeCert = ssl_copy_cert(ServerCert);
 | 
				
			||||||
 if ( FakeCert == NULL ) {
 | 
					 if ( FakeCert == NULL ) {
 | 
				
			||||||
	param->res = 8012;
 | 
						param->res = 8012;
 | 
				
			||||||
	_ssl_cert_free(ServerCert);
 | 
						_ssl_cert_free(ServerCert);
 | 
				
			||||||
	param->srv->logfunc(param, (unsigned char *)"Failed to create certificate copy");
 | 
						dolog(param, (unsigned char *)"Failed to create certificate copy");
 | 
				
			||||||
	ssl_conn_free(ServerConn);
 | 
						ssl_conn_free(ServerConn);
 | 
				
			||||||
	return 2;
 | 
						return 2;
 | 
				
			||||||
 }
 | 
					 }
 | 
				
			||||||
 ClientConn = ssl_handshake_to_client(param->clisock, FakeCert, &errSSL);
 | 
					 ClientConn = ssl_handshake_to_client(param->clisock, FakeCert, &errSSL);
 | 
				
			||||||
 if ( ClientConn == NULL ) {
 | 
					 if ( ClientConn == NULL ) {
 | 
				
			||||||
	param->res = 8012;
 | 
						param->res = 8012;
 | 
				
			||||||
	param->srv->logfunc(param, (unsigned char *)"Handshake to client failed");
 | 
						dolog(param, (unsigned char *)"Handshake to client failed");
 | 
				
			||||||
	if(errSSL)param->srv->logfunc(param, (unsigned char *)errSSL);
 | 
						if(errSSL)dolog(param, (unsigned char *)errSSL);
 | 
				
			||||||
	_ssl_cert_free(ServerCert);
 | 
						_ssl_cert_free(ServerCert);
 | 
				
			||||||
	_ssl_cert_free(FakeCert);
 | 
						_ssl_cert_free(FakeCert);
 | 
				
			||||||
	ssl_conn_free(ServerConn);
 | 
						ssl_conn_free(ServerConn);
 | 
				
			||||||
@ -382,6 +383,8 @@ PLUGINAPI int PLUGINCALL ssl_plugin (struct pluginlink * pluginlink,
 | 
				
			|||||||
					 int argc, char** argv){
 | 
										 int argc, char** argv){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pl = pluginlink;
 | 
						pl = pluginlink;
 | 
				
			||||||
 | 
					        dolog=pluginlink->findbyname("dolog");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(!ssl_loaded){
 | 
						if(!ssl_loaded){
 | 
				
			||||||
		ssl_loaded = 1;
 | 
							ssl_loaded = 1;
 | 
				
			||||||
		pthread_mutex_init(&ssl_mutex, NULL);
 | 
							pthread_mutex_init(&ssl_mutex, NULL);
 | 
				
			||||||
 | 
				
			|||||||
@ -54,7 +54,6 @@ static FILTER_ACTION transparent_filter_client(void *fo, struct clientparam * pa
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#error No SO_ORIGINAL_DST defined
 | 
					#error No SO_ORIGINAL_DST defined
 | 
				
			||||||
       	param->srv->logfunc(param, (unsigned char *)"transparent_plugin: No SO_ORIGINAL_DST defined");
 | 
					 | 
				
			||||||
	return REJECT;
 | 
						return REJECT;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
 | 
				
			|||||||
@ -69,4 +69,5 @@ struct proxydef childdef = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#include "proxymain.c"
 | 
					#include "proxymain.c"
 | 
				
			||||||
 | 
					#include "log.c"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -1141,4 +1141,5 @@ struct proxydef childdef = {
 | 
				
			|||||||
	"-a1 - anonymous proxy with random client IP spoofing\r\n"
 | 
						"-a1 - anonymous proxy with random client IP spoofing\r\n"
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#include "proxymain.c"
 | 
					#include "proxymain.c"
 | 
				
			||||||
 | 
					#include "log.c"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										14
									
								
								src/proxy.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/proxy.h
									
									
									
									
									
								
							@ -166,21 +166,10 @@ int sockgetlinebuf(struct clientparam * param, DIRECTION which, unsigned char *
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void initlog(void);
 | 
				
			||||||
void dolog(struct clientparam * param, const unsigned char *s);
 | 
					void dolog(struct clientparam * param, const unsigned char *s);
 | 
				
			||||||
int dobuf(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec);
 | 
					int dobuf(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec);
 | 
				
			||||||
int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec, struct tm* tm, char * format);
 | 
					int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec, struct tm* tm, char * format);
 | 
				
			||||||
extern FILE * stdlog;
 | 
					 | 
				
			||||||
void logstdout(struct clientparam * param, const unsigned char *s);
 | 
					 | 
				
			||||||
void logsyslog(struct clientparam * param, const unsigned char *s);
 | 
					 | 
				
			||||||
void lognone(struct clientparam * param, const unsigned char *s);
 | 
					 | 
				
			||||||
void logradius(struct clientparam * param, const unsigned char *s);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NOSQL
 | 
					 | 
				
			||||||
void logsql(struct clientparam * param, const unsigned char *s);
 | 
					 | 
				
			||||||
int init_sql(char * s);
 | 
					 | 
				
			||||||
void close_sql();
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
int doconnect(struct clientparam * param);
 | 
					int doconnect(struct clientparam * param);
 | 
				
			||||||
int alwaysauth(struct clientparam * param);
 | 
					int alwaysauth(struct clientparam * param);
 | 
				
			||||||
int ipauth(struct clientparam * param);
 | 
					int ipauth(struct clientparam * param);
 | 
				
			||||||
@ -203,7 +192,6 @@ int inithashtable(struct hashtable *hashtable, unsigned nhashsize);
 | 
				
			|||||||
void freeparam(struct clientparam * param);
 | 
					void freeparam(struct clientparam * param);
 | 
				
			||||||
void clearstat(struct clientparam * param);
 | 
					void clearstat(struct clientparam * param);
 | 
				
			||||||
void dumpcounters(struct trafcount *tl, int counterd);
 | 
					void dumpcounters(struct trafcount *tl, int counterd);
 | 
				
			||||||
 | 
					 | 
				
			||||||
int startconnlims (struct clientparam *param);
 | 
					int startconnlims (struct clientparam *param);
 | 
				
			||||||
void stopconnlims (struct clientparam *param);
 | 
					void stopconnlims (struct clientparam *param);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -288,7 +288,7 @@ int MODULEMAINFUNC (int argc, char** argv){
 | 
				
			|||||||
 }
 | 
					 }
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
 srv.needuser = 0;
 | 
					 srv.needuser = 0;
 | 
				
			||||||
 pthread_mutex_init(&log_mutex, NULL);
 | 
					 initlog();
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _WIN32
 | 
					#ifndef _WIN32
 | 
				
			||||||
@ -313,7 +313,6 @@ int MODULEMAINFUNC (int argc, char** argv){
 | 
				
			|||||||
			break;
 | 
								break;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		 case 'l':
 | 
							 case 'l':
 | 
				
			||||||
			srv.logfunc = logstdout;
 | 
					 | 
				
			||||||
			if(srv.logtarget) myfree(srv.logtarget);
 | 
								if(srv.logtarget) myfree(srv.logtarget);
 | 
				
			||||||
			srv.logtarget = (unsigned char *)mystrdup(argv[i] + 2);
 | 
								srv.logtarget = (unsigned char *)mystrdup(argv[i] + 2);
 | 
				
			||||||
			if(argv[i][2]) {
 | 
								if(argv[i][2]) {
 | 
				
			||||||
@ -867,7 +866,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
 | 
				
			|||||||
 memset(srv, 0, sizeof(struct srvparam));
 | 
					 memset(srv, 0, sizeof(struct srvparam));
 | 
				
			||||||
 srv->version = conf.version + 1;
 | 
					 srv->version = conf.version + 1;
 | 
				
			||||||
 srv->paused = conf.paused;
 | 
					 srv->paused = conf.paused;
 | 
				
			||||||
 srv->logfunc = havelog?conf.logfunc:lognone;
 | 
					 srv->logfunc = havelog?conf.logfunc:NULL;
 | 
				
			||||||
 srv->noforce = conf.noforce;
 | 
					 srv->noforce = conf.noforce;
 | 
				
			||||||
 srv->logformat = conf.logformat? (unsigned char *)mystrdup((char *)conf.logformat) : NULL;
 | 
					 srv->logformat = conf.logformat? (unsigned char *)mystrdup((char *)conf.logformat) : NULL;
 | 
				
			||||||
 srv->authfunc = conf.authfunc;
 | 
					 srv->authfunc = conf.authfunc;
 | 
				
			||||||
@ -963,6 +962,24 @@ void srvfree(struct srvparam * srv){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void freeparam(struct clientparam * param) {
 | 
					void freeparam(struct clientparam * param) {
 | 
				
			||||||
	if(param->res == 2) return;
 | 
						if(param->res == 2) return;
 | 
				
			||||||
 | 
						if(param->ctrlsocksrv != INVALID_SOCKET && param->ctrlsocksrv != param->remsock) {
 | 
				
			||||||
 | 
							so._shutdown(param->ctrlsocksrv, SHUT_RDWR);
 | 
				
			||||||
 | 
							so._closesocket(param->ctrlsocksrv);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if(param->ctrlsock != INVALID_SOCKET && param->ctrlsock != param->clisock) {
 | 
				
			||||||
 | 
							so._shutdown(param->ctrlsock, SHUT_RDWR);
 | 
				
			||||||
 | 
							so._closesocket(param->ctrlsock);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if(param->remsock != INVALID_SOCKET) {
 | 
				
			||||||
 | 
							so._shutdown(param->remsock, SHUT_RDWR);
 | 
				
			||||||
 | 
							so._closesocket(param->remsock);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if(param->clisock != INVALID_SOCKET) {
 | 
				
			||||||
 | 
							so._shutdown(param->clisock, SHUT_RDWR);
 | 
				
			||||||
 | 
							so._closesocket(param->clisock);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						myfree(param->clibuf);
 | 
				
			||||||
 | 
						myfree(param->srvbuf);
 | 
				
			||||||
	if(param->datfilterssrv) myfree(param->datfilterssrv);
 | 
						if(param->datfilterssrv) myfree(param->datfilterssrv);
 | 
				
			||||||
#ifndef STDMAIN
 | 
					#ifndef STDMAIN
 | 
				
			||||||
	if(param->reqfilters) myfree(param->reqfilters);
 | 
						if(param->reqfilters) myfree(param->reqfilters);
 | 
				
			||||||
@ -979,8 +996,6 @@ void freeparam(struct clientparam * param) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	if(conf.connlimiter && (param->res != 95 || param->remsock != INVALID_SOCKET)) stopconnlims(param);
 | 
						if(conf.connlimiter && (param->res != 95 || param->remsock != INVALID_SOCKET)) stopconnlims(param);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	if(param->clibuf) myfree(param->clibuf);
 | 
					 | 
				
			||||||
	if(param->srvbuf) myfree(param->srvbuf);
 | 
					 | 
				
			||||||
	if(param->srv){
 | 
						if(param->srv){
 | 
				
			||||||
		pthread_mutex_lock(¶m->srv->counter_mutex);
 | 
							pthread_mutex_lock(¶m->srv->counter_mutex);
 | 
				
			||||||
		if(param->prev){
 | 
							if(param->prev){
 | 
				
			||||||
@ -999,22 +1014,6 @@ void freeparam(struct clientparam * param) {
 | 
				
			|||||||
	if(param->password) myfree(param->password);
 | 
						if(param->password) myfree(param->password);
 | 
				
			||||||
	if(param->extusername) myfree(param->extusername);
 | 
						if(param->extusername) myfree(param->extusername);
 | 
				
			||||||
	if(param->extpassword) myfree(param->extpassword);
 | 
						if(param->extpassword) myfree(param->extpassword);
 | 
				
			||||||
	if(param->ctrlsocksrv != INVALID_SOCKET && param->ctrlsocksrv != param->remsock) {
 | 
					 | 
				
			||||||
		so._shutdown(param->ctrlsocksrv, SHUT_RDWR);
 | 
					 | 
				
			||||||
		so._closesocket(param->ctrlsocksrv);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(param->ctrlsock != INVALID_SOCKET && param->ctrlsock != param->clisock) {
 | 
					 | 
				
			||||||
		so._shutdown(param->ctrlsock, SHUT_RDWR);
 | 
					 | 
				
			||||||
		so._closesocket(param->ctrlsock);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(param->remsock != INVALID_SOCKET) {
 | 
					 | 
				
			||||||
		so._shutdown(param->remsock, SHUT_RDWR);
 | 
					 | 
				
			||||||
		so._closesocket(param->remsock);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(param->clisock != INVALID_SOCKET) {
 | 
					 | 
				
			||||||
		so._shutdown(param->clisock, SHUT_RDWR);
 | 
					 | 
				
			||||||
		so._closesocket(param->clisock);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	myfree(param);
 | 
						myfree(param);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -313,4 +313,5 @@ struct proxydef childdef = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#include "proxymain.c"
 | 
					#include "proxymain.c"
 | 
				
			||||||
 | 
					#include "log.c"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -464,4 +464,5 @@ struct proxydef childdef = {
 | 
				
			|||||||
	"-N(EXTERNAL_IP) External NAT address to report to client for BIND\n"
 | 
						"-N(EXTERNAL_IP) External NAT address to report to client for BIND\n"
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#include "proxymain.c"
 | 
					#include "proxymain.c"
 | 
				
			||||||
 | 
					#include "log.c"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -188,8 +188,7 @@ struct node;
 | 
				
			|||||||
struct symbol;
 | 
					struct symbol;
 | 
				
			||||||
struct pluginlink;
 | 
					struct pluginlink;
 | 
				
			||||||
struct srvparam;
 | 
					struct srvparam;
 | 
				
			||||||
 | 
					struct LOGFUNC;
 | 
				
			||||||
typedef void (*LOGFUNC)(struct clientparam * param, const unsigned char *);
 | 
					 | 
				
			||||||
typedef int (*AUTHFUNC)(struct clientparam * param);
 | 
					typedef int (*AUTHFUNC)(struct clientparam * param);
 | 
				
			||||||
typedef void * (*REDIRECTFUNC)(struct clientparam * param);
 | 
					typedef void * (*REDIRECTFUNC)(struct clientparam * param);
 | 
				
			||||||
typedef unsigned long (*RESOLVFUNC)(int af, unsigned char *name, unsigned char *value);
 | 
					typedef unsigned long (*RESOLVFUNC)(int af, unsigned char *name, unsigned char *value);
 | 
				
			||||||
@ -364,6 +363,24 @@ struct trafcount {
 | 
				
			|||||||
	time_t updated;
 | 
						time_t updated;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct LOGFUNC {
 | 
				
			||||||
 | 
						struct LOGFUNC* next;	
 | 
				
			||||||
 | 
						int (*init)(const char * selector, int logtype, struct LOGGER *logger);
 | 
				
			||||||
 | 
						int (*dobuf)(struct clientparam * param, unsigned char * buf, const unsigned char *s);
 | 
				
			||||||
 | 
						int (*log)(const char * buf, int len, struct LOGGER *logger);
 | 
				
			||||||
 | 
						int (*rotate)(struct LOGGER *logger);
 | 
				
			||||||
 | 
						int (*close)(struct LOGGER *logger);
 | 
				
			||||||
 | 
						char* prefix;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					struct LOGGER {
 | 
				
			||||||
 | 
						char * selector;
 | 
				
			||||||
 | 
						void * data;
 | 
				
			||||||
 | 
						struct LOGFUNC *logfunc;
 | 
				
			||||||
 | 
						int rotate;
 | 
				
			||||||
 | 
						time_t rotated;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					extern struct LOGFUNC logfuncs;
 | 
				
			||||||
 | 
					extern void(*prelog)(struct clientparam * param);
 | 
				
			||||||
struct nserver {
 | 
					struct nserver {
 | 
				
			||||||
#ifndef NOIPV6
 | 
					#ifndef NOIPV6
 | 
				
			||||||
	struct sockaddr_in6 addr;
 | 
						struct sockaddr_in6 addr;
 | 
				
			||||||
@ -418,7 +435,6 @@ struct srvparam {
 | 
				
			|||||||
	struct srvparam *prev;
 | 
						struct srvparam *prev;
 | 
				
			||||||
	struct clientparam *child;
 | 
						struct clientparam *child;
 | 
				
			||||||
	PROXYSERVICE service;
 | 
						PROXYSERVICE service;
 | 
				
			||||||
	LOGFUNC logfunc;
 | 
					 | 
				
			||||||
	AUTHFUNC authfunc;
 | 
						AUTHFUNC authfunc;
 | 
				
			||||||
	PROXYFUNC pf;
 | 
						PROXYFUNC pf;
 | 
				
			||||||
	SOCKET srvsock, cbsock;
 | 
						SOCKET srvsock, cbsock;
 | 
				
			||||||
@ -589,7 +605,6 @@ struct extparam {
 | 
				
			|||||||
	struct passwords *pwl;
 | 
						struct passwords *pwl;
 | 
				
			||||||
	struct auth * authenticate;
 | 
						struct auth * authenticate;
 | 
				
			||||||
	AUTHFUNC authfunc;
 | 
						AUTHFUNC authfunc;
 | 
				
			||||||
	LOGFUNC logfunc;
 | 
					 | 
				
			||||||
	BANDLIMFUNC bandlimfunc;
 | 
						BANDLIMFUNC bandlimfunc;
 | 
				
			||||||
	TRAFCOUNTFUNC trafcountfunc;
 | 
						TRAFCOUNTFUNC trafcountfunc;
 | 
				
			||||||
	unsigned char *logtarget, *logformat;
 | 
						unsigned char *logtarget, *logformat;
 | 
				
			||||||
 | 
				
			|||||||
@ -37,4 +37,5 @@ struct proxydef childdef = {
 | 
				
			|||||||
	""
 | 
						""
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#include "proxymain.c"
 | 
					#include "proxymain.c"
 | 
				
			||||||
 | 
					#include "log.c"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -116,4 +116,5 @@ struct proxydef childdef = {
 | 
				
			|||||||
	" -s single packet UDP service for request/reply (DNS-like) services\n"
 | 
						" -s single packet UDP service for request/reply (DNS-like) services\n"
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#include "proxymain.c"
 | 
					#include "proxymain.c"
 | 
				
			||||||
 | 
					#include "log.c"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user