[X2serv-cvs] CVS: x2/source chan.c,1.84,1.85 config.h,1.70,1.71 main.c,1.58,1.59 misc.c,1.47,1.48 pa
Brought to you by:
sirvulcan
From: Alex S. <ru...@us...> - 2003-05-18 03:43:48
|
Update of /cvsroot/x2serv/x2/source In directory sc8-pr-cvs1:/tmp/cvs-serv28690/source Modified Files: chan.c config.h main.c misc.c parse.c Log Message: added network access logging Index: chan.c =================================================================== RCS file: /cvsroot/x2serv/x2/source/chan.c,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -r1.84 -r1.85 *** chan.c 15 Sep 2002 07:41:11 -0000 1.84 --- chan.c 18 May 2003 03:43:45 -0000 1.85 *************** *** 927,930 **** --- 927,933 ---- ChanNode->NumOfNicks++; /* Incriment ppl in chan counter */ + LogAccess(UserNode, ChanNode->Name, ChanNode->NumOfNicks); + + NewCUser = malloc(sizeof(struct ChanUserStruct)); NewCUser->User = UserNode; Index: config.h =================================================================== RCS file: /cvsroot/x2serv/x2/source/config.h,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -r1.70 -r1.71 *** config.h 15 May 2003 03:36:09 -0000 1.70 --- config.h 18 May 2003 03:43:45 -0000 1.71 *************** *** 101,104 **** --- 101,105 ---- #define GLINEFILENAME "gline.dat" #define SUPERGLINEFILENAME "supergline.dat" + #define HITLOGFILENAME "logs/afternet.access.log" /* This is part of the on-connect probes; x2 sends a *************** *** 646,650 **** Uplink[MAXLEN], ServAddress[16], Password[20], IrcNick[MAXNICKLEN], ! CommandMark, HomeDir[2048]; extern int ServiceNumeric; --- 647,651 ---- Uplink[MAXLEN], ServAddress[16], Password[20], IrcNick[MAXNICKLEN], ! CommandMark, HomeDir[2048], AccessLog[2048]; extern int ServiceNumeric; Index: main.c =================================================================== RCS file: /cvsroot/x2serv/x2/source/main.c,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -r1.58 -r1.59 *** main.c 15 Sep 2002 07:41:12 -0000 1.58 --- main.c 18 May 2003 03:43:45 -0000 1.59 *************** *** 40,47 **** FLOODCONTROL, NETLINK, NETTALK, PUBLIC, NETBURSTING; unsigned char CLONERES=0, MAXCLONES, MAXCHAN, DEBUG, SUB7SCAN=0, LITMUS=0, SDBOT=0; ! char ServiceName[MAXLEN], Uplink[MAXLEN], ServAddress[16], Password[20], ! IrcNick[MAXNICKLEN], ! CommandMark, HomeDir[2048]; int ServiceNumeric = 53; char NumNick[NUMNICKLEN] = "1X2"; --- 40,47 ---- FLOODCONTROL, NETLINK, NETTALK, PUBLIC, NETBURSTING; unsigned char CLONERES=0, MAXCLONES, MAXCHAN, DEBUG, SUB7SCAN=0, LITMUS=0, SDBOT=0; ! char ServiceName[MAXLEN] = "UNSET", Uplink[MAXLEN], ServAddress[16], Password[20], ! IrcNick[MAXNICKLEN] = "X2", ! CommandMark = '.', HomeDir[2048]="", AccessLog[2048]=""; int ServiceNumeric = 53; char NumNick[NUMNICKLEN] = "1X2"; *************** *** 215,218 **** --- 215,224 ---- strcpy(HomeDir, StrBuffr); printf("Home Directory: %s\n", HomeDir); + } + else if (!strcmp(StrBuffr, "ACCESSLOG")) + { + fscanf(ConfFile, "%s", StrBuffr); + strcpy(AccessLog, StrBuffr); + printf("Logging network access to %s\n", AccessLog); } else if (!strcmp(StrBuffr, "PINGOUTCONNECT")) Index: misc.c =================================================================== RCS file: /cvsroot/x2serv/x2/source/misc.c,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -r1.47 -r1.48 *** misc.c 15 May 2003 03:36:09 -0000 1.47 --- misc.c 18 May 2003 03:43:45 -0000 1.48 *************** *** 29,32 **** --- 29,33 ---- #include "match.h" #include "server.h" + #include "time.h" char *parmstr; *************** *** 283,286 **** --- 284,331 ---- } fclose(TheFile); + } + + char *time2apache(char *timestr) + { + char b[MAXLEN]; + char *buff = b; + char* m,*d,*t,*y,*w; + static char str[MAXLEN]; + + + strcpy(buff, timestr); + + w = (char *)mysep(&buff, " "); + m = (char *)mysep(&buff, " "); + d = (char *)mysep(&buff, " "); + t = (char *)mysep(&buff, " "); + y = (char *)mysep(&buff, " "); + + if(!(m&&d&&t&&y)) + { + return "TIME ERROR"; + } + sprintf(str, "%s/%s/%s:%s -0700", + d,m,y,t); + return str; + } + + /* Makes an apache style log of connections and channel joins + * for things like awstats to analyze + */ + void LogAccess(UserListType uptr, char* item, int size) + { + FILE* LOGFILE; + char buff[MAXLEN*4]; + + if(strcmp(AccessLog, "none")) + { + if((LOGFILE = fopen(AccessLog, "a+")) != NULL) + { + fprintf(LOGFILE, "%s - - [%s] \"GET /%s HTTP/1.1\" 200 %d \"%s\" \"IRC\"\n", + uptr->Address, time2apache(time2str(time(NULL))), item, size, uptr->RealName ); + fclose(LOGFILE); + } + } } Index: parse.c =================================================================== RCS file: /cvsroot/x2serv/x2/source/parse.c,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -r1.76 -r1.77 *** parse.c 15 May 2003 03:36:09 -0000 1.76 --- parse.c 18 May 2003 03:43:45 -0000 1.77 *************** *** 428,431 **** --- 428,432 ---- { char* dq = unsigned32ToDotQuad(IP); + LogAccess(UserPtr, "", 1); if(!GlineCheck(UserPtr, dq) && !SuperGlineCheck(UserPtr, dq)) { |