diff -c -r irc2.8.21+CSr27/README.CS irc2.8.21+CSr28/README.CS *** irc2.8.21+CSr27/README.CS Mon Nov 11 20:11:04 1996 --- irc2.8.21+CSr28/README.CS Tue Mar 25 22:13:01 1997 *************** *** 1,6 **** --- ! This is the README for irc2.8.21+CSr27. Basically, this is just a list of changes...more information can be found in include/comstud.h. Any questions or comments can be directed to cbehrens@concentric.net --- 1,6 ---- --- ! This is the README for irc2.8.21+CSr28. Basically, this is just a list of changes...more information can be found in include/comstud.h. Any questions or comments can be directed to cbehrens@concentric.net *************** *** 12,21 **** NOTE: Please change values in comstud.h and dog3.h to your liking... The default values are probably less than ideal for you! ! New in CSr27: ! Still being developed... 1) There are noticable differences in I: lines now. There are 4 special characters that you can stick in front of a hostname or ip# that do special things. --- 12,46 ---- NOTE: Please change values in comstud.h and dog3.h to your liking... The default values are probably less than ideal for you! ! New in CSr28: ! 1) duh. '#' won't work in I: lines for passing identd (See #1 in CSr27 ! below). This has been changed to '$'. ! 2) Fixed a memory leak in DICHCONF/Kline stuff. ! 3) /whowas code totally rewritten. This code is better than Avalon's ! ever was. You can now raise NICKNAMEHISTORYLENGTH in config.h to ! a value that makes sense with today's number of clients. Without ! rewriting, you could expect server lockup, mostly during splits. ! These changes should lower CPU usage quite a bit, especially during ! splits. ! 4) /who code tweaked. IsMember() = CPU hog...IsMember() has been changed ! and m_who does less find_user_link()s now...much less. This is ! a big reducer of CPU usage. Also another "bug" was removed from ! m_who that can possibly cause server lockups. The possibility still ! remains, though...not sure how to improve it further without totally ! breaking /who. ! 5) This goes with #4, but... ! /who nickname was optimized tremendously. However, this breaks /who ! if you do /who username and username happens to match a nickname. ! Oh well...too bad. ! 6) Hash table values for clients and channels raised ! 7) Various res.c changes that are in 2.9.x. I'm hoping these will fix ! my coredumps, but I highly doubt it. ! 8) Maybe other things...I dunno... + + New in CSr27: + 1) There are noticable differences in I: lines now. There are 4 special characters that you can stick in front of a hostname or ip# that do special things. Common subdirectories: irc2.8.21+CSr27/common and irc2.8.21+CSr28/common Common subdirectories: irc2.8.21+CSr27/doc and irc2.8.21+CSr28/doc Common subdirectories: irc2.8.21+CSr27/include and irc2.8.21+CSr28/include Common subdirectories: irc2.8.21+CSr27/ircd and irc2.8.21+CSr28/ircd diff -c -r irc2.8.21+CSr27/common/send.c irc2.8.21+CSr28/common/send.c *** irc2.8.21+CSr27/common/send.c Mon Nov 11 17:22:44 1996 --- irc2.8.21+CSr28/common/send.c Tue Mar 25 21:18:56 1997 *************** *** 46,58 **** #define NEWLINE "\r\n" #endif - static char sendbuf[2048]; static int send_message PROTO((aClient *, char *, int)); - #ifndef CLIENT_COMPILE - static int sentalong[MAXCONNECTIONS]; - #endif - /* ** dead_link ** An error has been detected. The link *must* be closed, --- 46,53 ---- *************** *** 315,321 **** { va_list vl; #endif ! /* # ifdef NPATH check_command((long)1, pattern, p1, p2, p3); --- 310,316 ---- { va_list vl; #endif ! char sendbuf[2048]; /* # ifdef NPATH check_command((long)1, pattern, p1, p2, p3); *************** *** 384,389 **** --- 379,385 ---- Reg1 Link *lp; Reg2 aClient *acptr; Reg3 int i; + int sentalong[MAXCONNECTIONS]; # ifdef USE_VARARGS va_start(vl); *************** *** 591,596 **** --- 587,593 ---- register Link *channels; register Link *users; register aClient *cptr; + int sentalong[MAXCONNECTIONS]; # ifdef USE_VARARGS va_start(vl); *************** *** 1145,1150 **** --- 1142,1148 ---- #endif Reg1 int i; Reg2 aClient *cptr; + int sentalong[MAXCONNECTIONS]; #ifdef USE_VARARGS va_start(vl); *************** *** 1173,1180 **** --- 1171,1234 ---- # endif return; } + + /* + ** sendto_wallops_butone + ** Send message to all operators. + ** one - client not to send message to + ** from- client which message is from *NEVER* NULL!! + */ + #ifndef USE_VARARGS + /*VARARGS*/ + void sendto_wallops_butone(one, from, pattern, p1, p2, p3, p4, p5, p6, p7, p8) + aClient *one, *from; + char *pattern, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8; + { + #else + void sendto_wallops_butone(one, from, pattern, va_alist) + aClient *one, *from; + char *pattern; + va_dcl + { + va_list vl; #endif + Reg1 int i; + Reg2 aClient *cptr; + int sentalong[MAXCONNECTIONS]; + #ifdef USE_VARARGS + va_start(vl); + #endif + bzero((char *)sentalong,sizeof(sentalong)); + for (cptr = client; cptr; cptr = cptr->next) + { + if (!SendWallops(cptr)) + continue; + if (!(IsServer(from) || IsMe(from)) && + MyClient(cptr) && !IsOper(cptr)) + continue; + if (MyClient(cptr) && !IsAnOper(cptr) && + !(IsServer(from) || IsMe(from))) + continue; + i = cptr->from->fd; /* find connection oper is on */ + if (sentalong[i]) /* sent message along it already ? */ + continue; + if (cptr->from == one) + continue; /* ...was the one I should skip */ + sentalong[i] = 1; + # ifdef USE_VARARGS + sendto_prefix_one(cptr->from, from, pattern, vl); + } + va_end(vl); + # else + sendto_prefix_one(cptr->from, from, pattern, + p1, p2, p3, p4, p5, p6, p7, p8); + } + # endif + return; + } + #endif /* CLIENT_COMPILE */ + /* * to - destination client * from - client which message is from *************** *** 1198,1204 **** { va_list vl; #endif ! static char sender[HOSTLEN+NICKLEN+USERLEN+5]; Reg3 anUser *user; char *par; int flag = 0; --- 1252,1258 ---- { va_list vl; #endif ! char sender[HOSTLEN+NICKLEN+USERLEN+5]; Reg3 anUser *user; char *par; int flag = 0; *************** *** 1287,1292 **** --- 1341,1348 ---- char *p1,*p2,*p3,*p4,*p5,*p6,*p7,*p8,*p9; { register int len,j,i,fd; + char sendbuf[2048]; + len = format(sendbuf,formp,p1,p2,p3,p4,p5,p6,p7,p8,p9); for(fd=listp->entry[j=1]; j<= listp->last_entry ; fd=listp->entry[++j]) diff -c -r irc2.8.21+CSr27/common/support.c irc2.8.21+CSr28/common/support.c *** irc2.8.21+CSr27/common/support.c Mon Nov 11 18:29:01 1996 --- irc2.8.21+CSr28/common/support.c Fri Feb 14 17:00:11 1997 *************** *** 31,44 **** extern void outofmemory(); #endif ! char *mystrdup(s) ! char *s; { ! char *t; ! ! if ((t = (char *) MyMalloc(strlen(s) + 1)) == NULL) return NULL; ! return (char *) strcpy(t, s); } #ifdef NEED_STRTOKEN --- 31,43 ---- extern void outofmemory(); #endif ! char *mstrcpy(dest, src) ! char **dest; ! char *src; { ! if ((*dest = (char *) MyMalloc(strlen(src) + 1)) == NULL) return NULL; ! return (char *) strcpy(*dest, src); } #ifdef NEED_STRTOKEN Common subdirectories: irc2.8.21+CSr27/doc/Europe and irc2.8.21+CSr28/doc/Europe Common subdirectories: irc2.8.21+CSr27/doc/US-Admin and irc2.8.21+CSr28/doc/US-Admin Common subdirectories: irc2.8.21+CSr27/doc/history and irc2.8.21+CSr28/doc/history diff -c -r irc2.8.21+CSr27/include/comstud.h irc2.8.21+CSr28/include/comstud.h *** irc2.8.21+CSr27/include/comstud.h Mon Nov 11 20:32:40 1996 --- irc2.8.21+CSr28/include/comstud.h Tue Mar 25 21:25:49 1997 *************** *** 1,6 **** --- 1,31 ---- #ifndef COMSTUD_H #define COMSTUD_H + /* D_LINES + - Define this for .conf lines that basically + ignore a site. If they try to connect to your + server, the connection will be closed immediately. + Note: You must specify ip#'s...and usernames aren't + allowed (won't be matched). + */ + + #define D_LINES + + /* FNAME_DLINE_LOG + - Define this to a filename to log ip#'s that have + been rejected from connecting to the server... + */ + + #define FNAME_DLINE_LOG "./logs/dlines.log" + + + /* STRICT_USERNAMES + - Define this if you only want letters, numbers, + -, and _ to be allowed in usernames... + */ + + #define STRICT_USERNAMES + /* RESTRICT_STATSK - Define this if you want to restrict /stats k so that it will only show if a certain spec is banned. diff -c -r irc2.8.21+CSr27/include/config.h irc2.8.21+CSr28/include/config.h *** irc2.8.21+CSr27/include/config.h Mon Nov 11 20:13:12 1996 --- irc2.8.21+CSr28/include/config.h Tue Mar 25 21:24:52 1997 *************** *** 418,433 **** /* * this defines the length of the nickname history. each time a user changes * nickname or signs off, their old nickname is added to the top of the list. - * The following sizes are recommended: - * 8MB or less core memory : 500 (at least 1/4 of max users) - * 8MB-16MB core memory : 500-750 (1/4 -> 1/2 of max users) - * 16MB-32MB core memory : 750-1000 (1/2 -> 3/4 of max users) - * 32MB or more core memory : 1000+ (> 3/4 if max users) - * where max users is the expected maximum number of users. - * (100 nicks/users ~ 25k) - * NOTE: this is directly related to the amount of memory ircd will use whilst - * resident and running - it hardly ever gets swapped to disk! You can - * ignore these recommendations- they only are meant to serve as a guide */ #define NICKNAMEHISTORYLENGTH 15000 --- 418,423 ---- diff -c -r irc2.8.21+CSr27/include/h.h irc2.8.21+CSr28/include/h.h *** irc2.8.21+CSr27/include/h.h Mon Nov 11 20:16:48 1996 --- irc2.8.21+CSr28/include/h.h Tue Mar 18 17:50:25 1997 *************** *** 34,40 **** #ifdef BETTER_MOTD extern aMotd *motd; ! extern struct tm *motd_tm; #endif --- 34,40 ---- #ifdef BETTER_MOTD extern aMotd *motd; ! extern struct tm motd_tm; #endif *************** *** 65,70 **** --- 65,82 ---- extern aConfList EList3; /* what we can't sort */ #endif /* E_LINES */ + #ifdef D_LINES + extern aConfList DList1; /* ordered */ + extern aConfList DList2; /* ordered, reversed */ + extern aConfList DList3; /* what we can't sort */ + #endif /* D_LINES */ + + #ifdef J_LINES + extern aConfList JList1; /* ordered */ + extern aConfList JList2; /* ordered, reversed */ + extern aConfList JList3; /* what we can't sort */ + #endif /* J_LINES */ + #ifdef DOG3 #include "fdlist.h" *************** *** 213,218 **** --- 225,232 ---- /*VARARGS3*/ extern void sendto_ops_butone(); /*VARARGS3*/ + extern void sendto_wallops_butone(); + /*VARARGS3*/ extern void sendto_prefix_one(); extern int writecalls, writeb[]; *************** *** 254,259 **** --- 268,274 ---- extern aServer *make_server PROTO(()); extern aClient *make_client PROTO((aClient *)); extern Link *find_user_link PROTO((Link *, aClient *)); + extern Link *find_channel_link PROTO((Link *, aChannel *)); extern void add_client_to_list PROTO((aClient *)); extern void checklist PROTO(()); extern void remove_client_from_list PROTO((aClient *)); *************** *** 288,294 **** extern aClient *hash_find_nickserver PROTO((char *, aClient *)); extern aClient *hash_find_server PROTO((char *, aClient *)); ! extern void add_history PROTO((aClient *)); extern aClient *get_history PROTO((char *, time_t)); extern void initwhowas PROTO(()); extern void off_history PROTO((aClient *)); --- 303,309 ---- extern aClient *hash_find_nickserver PROTO((char *, aClient *)); extern aClient *hash_find_server PROTO((char *, aClient *)); ! extern void add_history PROTO((aClient *, int)); extern aClient *get_history PROTO((char *, time_t)); extern void initwhowas PROTO(()); extern void off_history PROTO((aClient *)); diff -c -r irc2.8.21+CSr27/include/hash.h irc2.8.21+CSr28/include/hash.h *** irc2.8.21+CSr27/include/hash.h Sun Sep 15 14:35:36 1996 --- irc2.8.21+CSr28/include/hash.h Tue Mar 25 21:36:44 1997 *************** *** 20,30 **** #ifndef __hash_include__ #define __hash_include__ typedef struct hashentry { int hits; int links; void *list; ! } aHashEntry; extern int HASHSIZE; extern int CHANNELHASHSIZE; --- 20,46 ---- #ifndef __hash_include__ #define __hash_include__ + #define BITS_PER_COL 3 + #define BITS_PER_COL_MASK 0x7 + #define MAX_SUB (1< #endif + #include "hash.h" + typedef struct ConfItem aConfItem; typedef struct Client aClient; typedef struct Channel aChannel; *************** *** 60,65 **** --- 62,69 ---- typedef struct CloneItem aClone; typedef struct MotdItem aMotd; + typedef struct Whowas aWhowas; + #ifndef VMSP #include "class.h" #include "dbuf.h" /* THIS REALLY SHOULDN'T BE HERE!!! --msa */ *************** *** 302,307 **** --- 306,328 ---- struct MotdItem *next; }; + struct Whowas + { + int hashv; + char *name; + char *username; + char *hostname; + char *servername; + char *realname; + char *away; + time_t logoff; + struct Client *online; /* Pointer to new nickname for chasing or NULL */ + struct Whowas *next; /* for hash table... */ + struct Whowas *prev; /* for hash table... */ + struct Whowas *cnext; /* for client struct linked list */ + struct Whowas *cprev; /* for client struct linked list */ + }; + struct ConfItem { unsigned int status; /* If CONF_ILLEGAL, delete when no clients */ int clients; /* Number of *LOCAL* clients using this */ *************** *** 339,344 **** --- 360,367 ---- #define CONF_HUB 0x04000 #define CONF_BOT_IGNORE 0x08000 #define CONF_ELINE 0x10000 + #define CONF_DLINE 0x20000 + #define CONF_JLINE 0x40000 #define CONF_OPS (CONF_OPERATOR | CONF_LOCOP) #define CONF_SERVER_MASK (CONF_CONNECT_SERVER | CONF_NOCONNECT_SERVER) *************** *** 389,394 **** --- 412,418 ---- struct Client *next,*prev, *hnext; anUser *user; /* ...defined, if this is a User */ aServer *serv; /* ...defined, if this is a server */ + aWhowas *whowas; /* Pointers to whowas structs */ #ifdef USE_SERVICES aService *service; #endif *************** *** 600,607 **** #define ShowChannel(v,c) (PubChannel(c) || IsMember((v),(c))) #define PubChannel(x) ((!x) || ((x)->mode.mode &\ (MODE_PRIVATE | MODE_SECRET)) == 0) ! #define IsMember(user,chan) (find_user_link((chan)->members,user) ? 1 : 0) #define IsChannelName(name) ((name) && (*(name) == '#' || *(name) == '&')) /* Misc macros */ --- 624,635 ---- #define ShowChannel(v,c) (PubChannel(c) || IsMember((v),(c))) #define PubChannel(x) ((!x) || ((x)->mode.mode &\ (MODE_PRIVATE | MODE_SECRET)) == 0) ! #ifdef THIS_ONE_IS_MUCH_BETTER #define IsMember(user,chan) (find_user_link((chan)->members,user) ? 1 : 0) + #endif + #define IsMember(blah,chan) ((blah && blah->user && \ + find_channel_link((blah->user)->channel, chan)) ? 1 : 0) + #define IsChannelName(name) ((name) && (*(name) == '#' || *(name) == '&')) /* Misc macros */ Only in irc2.8.21+CSr27/include: whowas.h diff -c -r irc2.8.21+CSr27/ircd/Makefile irc2.8.21+CSr28/ircd/Makefile *** irc2.8.21+CSr27/ircd/Makefile Tue Oct 8 15:11:28 1996 --- irc2.8.21+CSr28/ircd/Makefile Fri Feb 14 16:53:28 1997 *************** *** 208,221 **** s_user.o: s_user.c ../include/struct.h ../include/config.h ../include/sys.h \ ../include/common.h ../include/dbuf.h ../include/channel.h \ ! ../include/msg.h ../include/numeric.h ../include/whowas.h \ ! ../include/comstud.h $(CC) $(CFLAGS) -c s_user.c s_serv.o: s_serv.c ../include/struct.h ../include/config.h ../include/sys.h \ ../include/common.h ../include/dbuf.h ../include/channel.h \ ! ../include/msg.h ../include/numeric.h ../include/whowas.h \ ! ../include/comstud.h $(CC) $(CFLAGS) -c s_serv.c s_numeric.o: s_numeric.c ../include/config.h ../include/sys.h \ --- 208,219 ---- s_user.o: s_user.c ../include/struct.h ../include/config.h ../include/sys.h \ ../include/common.h ../include/dbuf.h ../include/channel.h \ ! ../include/msg.h ../include/numeric.h ../include/comstud.h $(CC) $(CFLAGS) -c s_user.c s_serv.o: s_serv.c ../include/struct.h ../include/config.h ../include/sys.h \ ../include/common.h ../include/dbuf.h ../include/channel.h \ ! ../include/msg.h ../include/numeric.h ../include/comstud.h $(CC) $(CFLAGS) -c s_serv.c s_numeric.o: s_numeric.c ../include/config.h ../include/sys.h \ *************** *** 225,231 **** whowas.o: ../include/struct.h ../include/config.h ../include/sys.h \ ../include/common.h ../include/dbuf.h ../include/numeric.h \ ! ../include/whowas.h ../include/comstud.h whowas.c $(CC) $(CFLAGS) -c whowas.c hash.o: ../include/struct.h ../include/sys.h ../include/hash.h hash.c \ --- 223,229 ---- whowas.o: ../include/struct.h ../include/config.h ../include/sys.h \ ../include/common.h ../include/dbuf.h ../include/numeric.h \ ! ../include/comstud.h whowas.c $(CC) $(CFLAGS) -c whowas.c hash.o: ../include/struct.h ../include/sys.h ../include/hash.h hash.c \ *************** *** 265,278 **** s_conf.o: ../include/comstud.h ../include/dbuf.h ../include/sys.h s_conf.c s_user.o: ../include/comstud.h ../include/struct.h ../include/config.h s_user.o: ../include/dbuf.h ../include/sys.h ../include/channel.h ! s_user.o: ../include/msg.h ../include/numeric.h ../include/whowas.h s_user.c s_serv.o: ../include/comstud.h ../include/struct.h ../include/config.h s_serv.o: ../include/dbuf.h ../include/sys.h ../include/channel.h ! s_serv.o: ../include/msg.h ../include/numeric.h ../include/whowas.h s_serv.c s_numeric.o: ../include/config.h ../include/sys.h ../include/struct.h s_numeric.o: ../include/comstud.h ../include/dbuf.h ../include/numeric.h s_numeric.c whowas.o: ../include/comstud.h ../include/struct.h ../include/config.h ../include/dbuf.h ! whowas.o: ../include/comstud.h ../include/numeric.h ../include/whowas.h ../include/sys.h whowas.c class.o: ../include/struct.h ../include/class.h ../include/numeric.h class.o: ../include/comstud.h ../include/common.h ../include/config.h class.c hash.o: ../include/config.h ../include/sys.h ../include/hash.h --- 263,276 ---- s_conf.o: ../include/comstud.h ../include/dbuf.h ../include/sys.h s_conf.c s_user.o: ../include/comstud.h ../include/struct.h ../include/config.h s_user.o: ../include/dbuf.h ../include/sys.h ../include/channel.h ! s_user.o: ../include/msg.h ../include/numeric.h s_user.c s_serv.o: ../include/comstud.h ../include/struct.h ../include/config.h s_serv.o: ../include/dbuf.h ../include/sys.h ../include/channel.h ! s_serv.o: ../include/msg.h ../include/numeric.h s_serv.c s_numeric.o: ../include/config.h ../include/sys.h ../include/struct.h s_numeric.o: ../include/comstud.h ../include/dbuf.h ../include/numeric.h s_numeric.c whowas.o: ../include/comstud.h ../include/struct.h ../include/config.h ../include/dbuf.h ! whowas.o: ../include/comstud.h ../include/numeric.h ../include/sys.h whowas.c class.o: ../include/struct.h ../include/class.h ../include/numeric.h class.o: ../include/comstud.h ../include/common.h ../include/config.h class.c hash.o: ../include/config.h ../include/sys.h ../include/hash.h Common subdirectories: irc2.8.21+CSr27/ircd/crypt and irc2.8.21+CSr28/ircd/crypt diff -c -r irc2.8.21+CSr27/ircd/dich_conf.c irc2.8.21+CSr28/ircd/dich_conf.c *** irc2.8.21+CSr27/ircd/dich_conf.c Fri Sep 27 14:38:42 1996 --- irc2.8.21+CSr28/ircd/dich_conf.c Fri Dec 6 14:50:02 1996 *************** *** 382,387 **** --- 382,388 ---- memset(base[compare].sub, 0, sizeof(aConfList)); } addto_conf_list(base[compare].sub, my_conf, cmp_field); + MyFree(field); return; } if (!matches(field, base[compare].pattern)) diff -c -r irc2.8.21+CSr27/ircd/hash.c irc2.8.21+CSr28/ircd/hash.c *** irc2.8.21+CSr27/ircd/hash.c Mon Nov 11 20:33:34 1996 --- irc2.8.21+CSr28/ircd/hash.c Tue Mar 25 20:28:40 1997 *************** *** 26,68 **** #include "hash.h" #include "h.h" ! #define MAX_INITIAL 4096 ! #define MAX_INITIAL_MASK (MAX_INITIAL-1) - #define CH_MAX_INITIAL 1024 - #define CH_MAX_INITIAL_MASK (CH_MAX_INITIAL-1) - - #define BITS_PER_COL 3 - #define BITS_PER_COL_MASK 0x7 - #define MAX_SUB (1<> 1) + lower; nname++; } ! ret = ((hash & MAX_INITIAL_MASK) << BITS_PER_COL) + (hash2 & BITS_PER_COL_MASK); return ret; } --- 85,91 ---- hash2 = (hash2 >> 1) + lower; nname++; } ! ret = ((hash & U_MAX_INITIAL_MASK) << BITS_PER_COL) + (hash2 & BITS_PER_COL_MASK); return ret; } *************** *** 122,132 **** unsigned int hash_channel_name(name) char *name; { ! register char *hname = name; ! register unsigned int hash = 0; ! register int hash2 = 0; ! register char lower; ! register int i = 30; while(*hname && --i) { --- 101,111 ---- unsigned int hash_channel_name(name) char *name; { ! register unsigned char *hname = (unsigned char *) name; ! register unsigned int hash = 0; ! register int hash2 = 0; ! register char lower; ! register int i = 30; while(*hname && --i) { *************** *** 139,144 **** --- 118,144 ---- (hash2 & BITS_PER_COL_MASK); } + unsigned int hash_whowas_name(name) + char *name; + { + register unsigned char *nname = (unsigned char *) name; + register unsigned int hash = 0; + register int hash2 = 0; + register int ret; + register char lower; + + while (*nname) + { + lower = tolower(*nname); + hash = (hash << 1) + lower; + hash2 = (hash2 >> 1) + lower; + nname++; + } + ret = ((hash & WW_MAX_INITIAL_MASK) << BITS_PER_COL) + + (hash2 & BITS_PER_COL_MASK); + return ret; + } + /* * clear_*_hash_table * diff -c -r irc2.8.21+CSr27/ircd/ircd.c irc2.8.21+CSr28/ircd/ircd.c *** irc2.8.21+CSr27/ircd/ircd.c Mon Nov 11 20:15:50 1996 --- irc2.8.21+CSr28/ircd/ircd.c Tue Mar 18 17:47:06 1997 *************** *** 49,54 **** --- 49,61 ---- aConfList BList3 = { 0, NULL }; /* what we can't sort */ #endif /* B_LINES */ + #ifdef D_LINES + /* Lists of sites to totally ignore! */ + aConfList DList1 = { 0, NULL }; /* ordered */ + aConfList DList2 = { 0, NULL }; /* ordered, reversed */ + aConfList DList3 = { 0, NULL }; /* what we can't sort */ + #endif /* D_LINES */ + #ifdef E_LINES aConfList EList1 = { 0, NULL }; /* ordered */ aConfList EList2 = { 0, NULL }; /* ordered, reversed */ *************** *** 55,63 **** aConfList EList3 = { 0, NULL }; /* what we can't sort */ #endif /* E_LINES */ #ifdef BETTER_MOTD aMotd *motd; ! struct tm *motd_tm; #endif int s_count = 1; /* All servers */ --- 62,77 ---- aConfList EList3 = { 0, NULL }; /* what we can't sort */ #endif /* E_LINES */ + #ifdef J_LINES + /* Lists of sites to totally ignore! */ + aConfList JList1 = { 0, NULL }; /* ordered */ + aConfList JList2 = { 0, NULL }; /* ordered, reversed */ + aConfList JList3 = { 0, NULL }; /* what we can't sort */ + #endif /* J_LINES */ + #ifdef BETTER_MOTD aMotd *motd; ! struct tm motd_tm; #endif int s_count = 1; /* All servers */ *************** *** 740,746 **** #endif #ifdef BETTER_MOTD motd = NULL; - motd_tm = NULL; read_motd(MOTD); #endif #ifndef IRC_UID --- 754,759 ---- *************** *** 1015,1020 **** --- 1028,1044 ---- if (dorehash) { (void)rehash(&me, &me, 1); + #ifdef SEPARATE_QUOTE_KLINES_BY_DATE + { + struct tm *tmptr; + char timebuffer[20], filename[200]; + + tmptr = localtime(&NOW); + strftime(timebuffer, 20, "%y%m%d", tmptr); + sprintf(filename, "%s.%s", klinefile, timebuffer); + initconf(0,filename); + } + #endif dorehash = 0; } /* diff -c -r irc2.8.21+CSr27/ircd/list.c irc2.8.21+CSr28/ircd/list.c *** irc2.8.21+CSr27/ircd/list.c Wed Sep 25 01:27:37 1996 --- irc2.8.21+CSr28/ircd/list.c Tue Mar 25 20:26:10 1997 *************** *** 262,268 **** cptr->next->prev = cptr->prev; if (IsPerson(cptr) && cptr->user) { ! add_history(cptr); off_history(cptr); } if (cptr->user) --- 262,268 ---- cptr->next->prev = cptr->prev; if (IsPerson(cptr) && cptr->user) { ! add_history(cptr, 0); off_history(cptr); } if (cptr->user) *************** *** 315,329 **** Reg2 aClient *ptr; { if (ptr) ! while (lp) ! { ! if (lp->value.cptr == ptr) ! return (lp); ! lp = lp->next; ! } return NULL; } Link *make_link() { Reg1 Link *lp; --- 315,338 ---- Reg2 aClient *ptr; { if (ptr) ! for(;lp;lp=lp->next) ! if (lp->value.cptr == ptr) ! return (lp); return NULL; } + + Link *find_channel_link(lp, chptr) + Reg1 Link *lp; + Reg2 aChannel *chptr; + { + if (chptr) + for(;lp;lp=lp->next) + if (lp->value.chptr == chptr) + return lp; + return NULL; + } + Link *make_link() { Reg1 Link *lp; *************** *** 462,464 **** --- 471,517 ---- me.name, RPL_STATSDEBUG, name, inuse, mem); } #endif + + void add_whowas_to_clist(bucket, whowas) + aWhowas **bucket; + aWhowas *whowas; + { + whowas->cprev = NULL; + if ((whowas->cnext = *bucket) != NULL) + whowas->cnext->cprev = whowas; + *bucket = whowas; + } + + void del_whowas_from_clist(bucket, whowas) + aWhowas **bucket; + aWhowas *whowas; + { + if (whowas->cprev) + whowas->cprev->cnext = whowas->cnext; + else + *bucket = whowas->cnext; + if (whowas->cnext) + whowas->cnext->cprev = whowas->cprev; + } + + void add_whowas_to_list(bucket, whowas) + aWhowas **bucket; + aWhowas *whowas; + { + whowas->prev = NULL; + if ((whowas->next = *bucket) != NULL) + whowas->next->prev = whowas; + *bucket = whowas; + } + + void del_whowas_from_list(bucket, whowas) + aWhowas **bucket; + aWhowas *whowas; + { + if (whowas->prev) + whowas->prev->next = whowas->next; + else + *bucket = whowas->next; + if (whowas->next) + whowas->next->prev = whowas->prev; + } Only in irc2.8.21+CSr27/ircd: list2.c Only in irc2.8.21+CSr27/ircd: poll.c diff -c -r irc2.8.21+CSr27/ircd/res.c irc2.8.21+CSr28/ircd/res.c *** irc2.8.21+CSr27/ircd/res.c Tue Sep 17 16:16:44 1996 --- irc2.8.21+CSr28/ircd/res.c Tue Mar 25 17:41:17 1997 *************** *** 48,53 **** --- 48,54 ---- static int proc_answer PROTO((ResRQ *, HEADER *, char *, char *)); static int query_name PROTO((char *, int, int, ResRQ *)); static aCache *make_cache PROTO((ResRQ *)); + static aCache *rem_list PROTO((aCache *)); static aCache *find_cache_name PROTO((char *)); static aCache *find_cache_number PROTO((ResRQ *, char *)); static int add_request PROTO((ResRQ *)); *************** *** 87,93 **** int ret = 0; #ifdef LRAND48 ! srand48(NOW); #endif if (op & RES_INITLIST) { --- 88,94 ---- int ret = 0; #ifdef LRAND48 ! srand48(time(NULL)); #endif if (op & RES_INITLIST) { *************** *** 225,241 **** { r2ptr = rptr->next; tout = rptr->sentat + rptr->timeout; ! if (now >= tout) ! if (--rptr->retries <= 0) ! { #ifdef DEBUG ! Debug((DEBUG_ERROR,"timeout %x now %d cptr %x", ! rptr, now, rptr->cinfo.value.cptr)); #endif ! reinfo.re_timeouts++; ! cptr = rptr->cinfo.value.cptr; ! switch (rptr->cinfo.flags) ! { case ASYNC_CLIENT : ClearDNS(cptr); if (!DoingAuth(cptr)) --- 226,241 ---- { r2ptr = rptr->next; tout = rptr->sentat + rptr->timeout; ! if ((now >= tout) && (--rptr->retries <= 0)) ! { #ifdef DEBUG ! Debug((DEBUG_ERROR,"timeout %x now %d cptr %x", ! rptr, now, rptr->cinfo.value.cptr)); #endif ! reinfo.re_timeouts++; ! cptr = rptr->cinfo.value.cptr; ! switch (rptr->cinfo.flags) ! { case ASYNC_CLIENT : ClearDNS(cptr); if (!DoingAuth(cptr)) *************** *** 245,265 **** sendto_ops("Host %s unknown", rptr->name); break; ! } ! rem_request(rptr); ! continue; ! } ! else ! { rptr->sentat = now; rptr->timeout += rptr->timeout; resend_query(rptr); #ifdef DEBUG Debug((DEBUG_INFO,"r %x now %d retry %d c %x", rptr, now, rptr->retries, rptr->cinfo.value.cptr)); #endif ! } if (!next || tout < next) next = tout; } --- 245,266 ---- sendto_ops("Host %s unknown", rptr->name); break; ! } ! rem_request(rptr); ! continue; ! } ! else ! { rptr->sentat = now; rptr->timeout += rptr->timeout; resend_query(rptr); + tout = now + rptr->timeout; #ifdef DEBUG Debug((DEBUG_INFO,"r %x now %d retry %d c %x", rptr, now, rptr->retries, rptr->cinfo.value.cptr)); #endif ! } if (!next || tout < next) next = tout; } *************** *** 443,449 **** bzero(buf, sizeof(buf)); r = res_mkquery(QUERY, name, class, type, NULL, 0, NULL, ! buf, sizeof(buf)); if (r <= 0) { h_errno = NO_RECOVERY; --- 444,450 ---- bzero(buf, sizeof(buf)); r = res_mkquery(QUERY, name, class, type, NULL, 0, NULL, ! (u_char *)buf, sizeof(buf)); if (r <= 0) { h_errno = NO_RECOVERY; *************** *** 523,529 **** #else while (hptr->qdcount-- > 0) #endif ! if ((n = dn_skipname(cp, eob)) == -1) break; else cp += (n + QFIXEDSZ); --- 524,530 ---- #else while (hptr->qdcount-- > 0) #endif ! if ((n = dn_skipname((u_char *)cp, (u_char *)eob)) == -1) break; else cp += (n + QFIXEDSZ); *************** *** 531,548 **** * proccess each answer sent to us blech. */ while (hptr->ancount-- > 0 && cp && cp < eob) { ! n = dn_expand(buf, eob, cp, hostbuf, sizeof(hostbuf)); if (n <= 0) break; cp += n; ! type = (int)_getshort(cp); cp += sizeof(short); ! class = (int)_getshort(cp); cp += sizeof(short); ! rptr->ttl = _getlong(cp); cp += sizeof(rptr->ttl); ! dlen = (int)_getshort(cp); cp += sizeof(short); rptr->type = type; --- 532,550 ---- * proccess each answer sent to us blech. */ while (hptr->ancount-- > 0 && cp && cp < eob) { ! n = dn_expand((u_char *)buf, (u_char *)eob, (u_char *)cp, ! hostbuf, sizeof(hostbuf)); if (n <= 0) break; cp += n; ! type = (int)_getshort((u_char *)cp); cp += sizeof(short); ! class = (int)_getshort((u_char *)cp); cp += sizeof(short); ! rptr->ttl = _getlong((u_char *)cp); cp += sizeof(rptr->ttl); ! dlen = (int)_getshort((u_char *)cp); cp += sizeof(short); rptr->type = type; *************** *** 579,586 **** cp += dlen; break; case T_PTR : ! if((n = dn_expand(buf, eob, cp, hostbuf, ! sizeof(hostbuf) )) < 0) { cp = NULL; break; --- 581,589 ---- cp += dlen; break; case T_PTR : ! if ((n = dn_expand((u_char *)buf, (u_char *)eob, ! (u_char *)cp, hostbuf, ! sizeof(hostbuf) )) < 0) { cp = NULL; break; *************** *** 728,733 **** --- 731,739 ---- { struct hostent *hp2 = NULL; + if (BadPtr(rptr->he.h_name)) /* Kludge! 960907/Vesa */ + goto getres_err; + Debug((DEBUG_DNS, "relookup %s <-> %s", rptr->he.h_name, inetntoa((char *)&rptr->he.h_addr))); /* *************** *** 938,949 **** Debug((DEBUG_DNS,"u_l:add name %s hal %x ac %d", s, cp->he.h_aliases, addrcount)); #endif ! base[addrcount-1] = s; base[addrcount] = NULL; - if (i) - rptr->he.h_aliases[i-1] = NULL; - else - rptr->he.h_name = NULL; } } for (i = 0; cp->he.h_addr_list[i]; i++) --- 944,951 ---- Debug((DEBUG_DNS,"u_l:add name %s hal %x ac %d", s, cp->he.h_aliases, addrcount)); #endif ! mstrcpy(&base[addrcount-1], s); base[addrcount] = NULL; } } for (i = 0; cp->he.h_addr_list[i]; i++) *************** *** 971,982 **** */ if (!t) { ! base = cp->he.h_addr_list; addrcount++; ! t = (char *)MyRealloc(*base, addrcount * sizeof(struct in_addr)); ! base = (char **)MyRealloc((char *)base, ! (addrcount + 1) * sizeof(char *)); cp->he.h_addr_list = base; #ifdef DEBUG Debug((DEBUG_DNS,"u_l:add IP %x hal %x ac %d", --- 973,986 ---- */ if (!t) { ! struct in_addr **ab; ! ! ab = (struct in_addr **)cp->he.h_addr_list; addrcount++; ! t = (char *)MyRealloc((char *)*ab, addrcount * sizeof(struct in_addr)); ! base = (char **)MyRealloc((char *)ab, ! (addrcount + 1) * sizeof(*ab)); cp->he.h_addr_list = base; #ifdef DEBUG Debug((DEBUG_DNS,"u_l:add IP %x hal %x ac %d", *************** *** 985,996 **** addrcount)); #endif for (; addrcount; addrcount--) ! { ! *base++ = t; t += sizeof(struct in_addr); ! } ! *base = NULL; ! bcopy(s, *--base, sizeof(struct in_addr)); } } return; --- 989,1000 ---- addrcount)); #endif for (; addrcount; addrcount--) ! { ! *ab++ = (struct in_addr *)t; t += sizeof(struct in_addr); ! } ! *ab = NULL; ! bcopy(s, (char *)*--ab, sizeof(struct in_addr)); } } return; *************** *** 1071,1077 **** } for (cp = cachetop; cp; cp = cp->list_next) ! { /* * single address entry...would have been done by hashed * search above... --- 1075,1086 ---- } for (cp = cachetop; cp; cp = cp->list_next) ! { ! if (!cp->he.h_addr_list && !cp->he.h_aliases) ! { ! cp = rem_list(cp); ! continue; ! } /* * single address entry...would have been done by hashed * search above... *************** *** 1092,1098 **** update_list(rptr, cp); return cp; } ! } return NULL; } --- 1101,1107 ---- update_list(rptr, cp); return cp; } ! } return NULL; } *************** *** 1113,1121 **** ** Make cache entry. First check to see if the cache already exists ** and if so, return a pointer to it. */ ! if ((cp = find_cache_number(rptr, (char *)&rptr->he.h_addr.s_addr))) ! return cp; ! for (i = 1; rptr->he.h_addr_list[i].s_addr; i++) if ((cp = find_cache_number(rptr, (char *)&(rptr->he.h_addr_list[i].s_addr)))) return cp; --- 1122,1128 ---- ** Make cache entry. First check to see if the cache already exists ** and if so, return a pointer to it. */ ! for (i = 0; rptr->he.h_addr_list[i].s_addr; i++) if ((cp = find_cache_number(rptr, (char *)&(rptr->he.h_addr_list[i].s_addr)))) return cp; *************** *** 1126,1132 **** cp = (aCache *)MyMalloc(sizeof(aCache)); bzero((char *)cp, sizeof(aCache)); hp = &cp->he; ! for (i = 0; i < MAXADDRS; i++) if (!rptr->he.h_addr_list[i].s_addr) break; --- 1133,1139 ---- cp = (aCache *)MyMalloc(sizeof(aCache)); bzero((char *)cp, sizeof(aCache)); hp = &cp->he; ! for (i = 0; i < MAXADDRS - 1; i++) if (!rptr->he.h_addr_list[i].s_addr) break; *************** *** 1142,1148 **** for (n = 0; n < i; n++, s += sizeof(struct in_addr)) { *t++ = s; ! bcopy((char *)&(rptr->he.h_addr_list[n].s_addr), s, sizeof(struct in_addr)); } *t = (char *)NULL; --- 1149,1155 ---- for (n = 0; n < i; n++, s += sizeof(struct in_addr)) { *t++ = s; ! bcopy((char *)&rptr->he.h_addr_list[n], s, sizeof(struct in_addr)); } *t = (char *)NULL; *************** *** 1150,1156 **** /* ** an array of pointers to CNAMEs. */ ! for (i = 0; i < MAXALIASES; i++) if (!rptr->he.h_aliases[i]) break; i++; --- 1157,1163 ---- /* ** an array of pointers to CNAMEs. */ ! for (i = 0; i < MAXALIASES - 1; i++) if (!rptr->he.h_aliases[i]) break; i++; *************** *** 1180,1185 **** --- 1187,1213 ---- } /* + * rem_list + */ + static aCache *rem_list(cp) + aCache *cp; + { + aCache **cpp, *cr = cp->list_next; + /* + * remove cache entry from linked list + */ + for (cpp = &cachetop; *cpp; cpp = &((*cpp)->list_next)) + if (*cpp == cp) + { + *cpp = cp->list_next; + MyFree((char *)cp); + break; + } + return cr; + } + + + /* * rem_cache * delete a cache entry from the cache structures and lists and return * all memory used for the cache back to the memory pool. diff -c -r irc2.8.21+CSr27/ircd/res_init.c irc2.8.21+CSr28/ircd/res_init.c *** irc2.8.21+CSr27/ircd/res_init.c Sun Sep 15 14:35:38 1996 --- irc2.8.21+CSr28/ircd/res_init.c Tue Mar 25 17:52:41 1997 *************** *** 74,85 **** (void)strncpy(_res.defdname, cp, sizeof(_res.defdname)); haveenv++; } if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { /* read the config file */ while (fgets(buf, sizeof(buf), fp) != NULL) { /* read default domain name */ ! if (!strncmp(buf, "domain", sizeof("domain") - 1)) { if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("domain") - 1; --- 74,93 ---- (void)strncpy(_res.defdname, cp, sizeof(_res.defdname)); haveenv++; } + #define MATCH(line, name) \ + (!strncmp(line, name, sizeof(name) - 1) && \ + (line[sizeof(name) - 1] == ' ' || \ + line[sizeof(name) - 1] == '\t')) + if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { /* read the config file */ while (fgets(buf, sizeof(buf), fp) != NULL) { + /* skip comments */ + if (*buf == ';' || *buf == '#') + continue; /* read default domain name */ ! if (MATCH(buf, "domain")) { if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("domain") - 1; *************** *** 88,100 **** if ((*cp == '\0') || (*cp == '\n')) continue; (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); ! if ((cp = index(_res.defdname, '\n')) != NULL) ! *cp = '\0'; havesearch = 0; continue; } /* set search list */ ! if (!strncmp(buf, "search", sizeof("search") - 1)) { if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("search") - 1; --- 96,109 ---- if ((*cp == '\0') || (*cp == '\n')) continue; (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); ! if ((cp = (char *) ! strpbrk(ircd_res.defdname, " \t\n")) != NULL) ! *cp = '\0'; havesearch = 0; continue; } /* set search list */ ! if (MATCH(buf, "search")) if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("search") - 1; *************** *** 130,137 **** continue; } /* read nameservers to query */ ! if (!strncmp(buf, "nameserver", sizeof("nameserver") - 1) && ! nserv < MAXNS) { cp = buf + sizeof("nameserver") - 1; while (*cp == ' ' || *cp == '\t') cp++; --- 139,145 ---- continue; } /* read nameservers to query */ ! if (MATCH(buf, "nameserver") && nserv < MAXNS) { cp = buf + sizeof("nameserver") - 1; while (*cp == ' ' || *cp == '\t') cp++; diff -c -r irc2.8.21+CSr27/ircd/s_bsd.c irc2.8.21+CSr28/ircd/s_bsd.c *** irc2.8.21+CSr27/ircd/s_bsd.c Mon Nov 11 21:19:22 1996 --- irc2.8.21+CSr28/ircd/s_bsd.c Tue Mar 25 20:26:38 1997 *************** *** 1105,1111 **** #ifdef _SEQUENT_ rcvbufmax = sndbufmax = 8192; ! readbuf = (char *)MyMalloc(8192 * sizeof(char)); return; #endif --- 1105,1111 ---- #ifdef _SEQUENT_ rcvbufmax = sndbufmax = 8192; ! readbuf = (char *)MyMalloc((rcvbufmax+1) * sizeof(char)); return; #endif *************** *** 1117,1123 **** (char *)&rcvbufmax, optlen) >= 0)) rcvbufmax += 1024; getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&rcvbufmax, &optlen); ! readbuf = (char *)MyMalloc(rcvbufmax * sizeof(char)); #ifdef SOL20 sndbufmax = rcvbufmax; if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, --- 1117,1123 ---- (char *)&rcvbufmax, optlen) >= 0)) rcvbufmax += 1024; getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&rcvbufmax, &optlen); ! readbuf = (char *)MyMalloc((rcvbufmax+1) * sizeof(char)); #ifdef SOL20 sndbufmax = rcvbufmax; if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, *************** *** 1129,1135 **** rcvbufmax = READBUFSIZE; sndbufmax = rcvbufmax > 8192 ? 8192 : rcvbufmax; ! readbuf = (char *)MyMalloc(rcvbufmax * sizeof(char)); } /* --- 1129,1135 ---- rcvbufmax = READBUFSIZE; sndbufmax = rcvbufmax > 8192 ? 8192 : rcvbufmax; ! readbuf = (char *)MyMalloc((rcvbufmax+1) * sizeof(char)); } /* *************** *** 1683,1688 **** --- 1683,1693 ---- } if (FD_ISSET(i, &read_set) && IsListening(cptr)) { + #ifdef D_LINES + struct sockaddr_in addr; + int len = sizeof(struct sockaddr_in); + char host[HOSTLEN+2]; + #endif FD_CLR(i, &read_set); cptr->lasttime = NOW; /* *************** *** 1696,1702 **** --- 1701,1711 ---- ** point, just assume that connections cannot ** be accepted until some old is closed first. */ + #ifdef D_LINES + if ((fd=accept(i, (struct sockaddr *)&addr, &len)) < 0) + #else if ((fd = accept(i, NULL, NULL)) < 0) + #endif { #ifdef SOL20 /* If a connection is closed before the accept(), it *************** *** 1707,1712 **** --- 1716,1745 ---- cptr); continue; } + #ifdef D_LINES + strncpyzt(host, + (char *)inetntoa((char *)&addr.sin_addr), + sizeof(host)); + if (find_dline(host)) + { + #ifdef FNAME_DLINE_LOG + int logfile; + char buf[512]; + + if ((logfile = + open(FNAME_DLINE_LOG, + O_WRONLY|O_APPEND)) != -1) + { + (void)irc_sprintf(buf, "%s Failed connection from %s\n", + myctime(NOW), host); + (void)write(logfile, buf, strlen(buf)); + (void)close(logfile); + } + #endif /* FNAME_DLINE_LOG */ + close(fd); + continue; + } + #endif ircstp->is_ac++; if (fd >= MAXCLIENTS) { *************** *** 2025,2030 **** --- 2058,2068 ---- continue; if (rr && IsListening(cptr)) { + #ifdef D_LINES + struct sockaddr_in addr; + int len = sizeof(struct sockaddr_in); + char host[HOSTLEN+2]; + #endif rr = 0; cptr->lasttime = NOW; /* *************** *** 2038,2044 **** ** point, just assume that connections cannot ** be accepted until some old is closed first. */ ! if ((newfd = accept(fd, NULL, NULL)) < 0) { #ifdef SOL20 /* If a connection is closed before the accept(), it --- 2076,2086 ---- ** point, just assume that connections cannot ** be accepted until some old is closed first. */ ! #ifdef D_LINES ! if ((newfd = accept(fd, (struct sockaddr *)&addr, &len)) < 0) ! #else ! if ((newfd = accept(fd, NULL, NULL)) < 0) ! #endif { #ifdef SOL20 /* If a connection is closed before the accept(), it *************** *** 2049,2054 **** --- 2091,2120 ---- cptr); break; } + #ifdef D_LINES + strncpyzt(host, + (char *)inetntoa((char *)&addr.sin_addr), + sizeof(host)); + if (find_dline(host)) + { + #ifdef FNAME_DLINE_LOG + int logfile; + char buf[512]; + + if ((logfile = + open(FNAME_DLINE_LOG, + O_WRONLY|O_APPEND)) != -1) + { + (void)irc_sprintf(buf, "%s Failed connection from %s\n", + myctime(NOW), host); + (void)write(logfile, buf, strlen(buf)); + (void)close(logfile); + } + #endif /* FNAME_DLINE_LOG */ + close(newfd); + continue; + } + #endif ircstp->is_ac++; if (newfd >= MAXCLIENTS) { diff -c -r irc2.8.21+CSr27/ircd/s_conf.c irc2.8.21+CSr28/ircd/s_conf.c *** irc2.8.21+CSr27/ircd/s_conf.c Wed Oct 9 15:08:19 1996 --- irc2.8.21+CSr28/ircd/s_conf.c Tue Mar 25 21:15:10 1997 *************** *** 626,632 **** if (sig != 2) flush_cache(); */ - clear_conf_list(&KList1, 1); clear_conf_list(&KList2, 1); clear_conf_list(&KList3, 1); --- 626,631 ---- *************** *** 640,645 **** --- 639,654 ---- clear_conf_list(&EList2, 1); clear_conf_list(&EList3, 1); #endif /* E_LINES */ + #ifdef D_LINES + clear_conf_list(&DList1, 1); + clear_conf_list(&DList2, 1); + clear_conf_list(&DList3, 1); + #endif /* D_LINES */ + #ifdef J_LINES + clear_conf_list(&JList1, 1); + clear_conf_list(&JList2, 1); + clear_conf_list(&JList3, 1); + #endif /* J_LINES */ (void) initconf(0, configfile); (void) initconf(0, klinefile); close_listeners(); *************** *** 734,740 **** case '+': aconf->flags |= FLAGS_NEED_IDENTD; break; ! case '#': aconf->flags |= FLAGS_PASS_IDENTD; break; } --- 743,749 ---- case '+': aconf->flags |= FLAGS_NEED_IDENTD; break; ! case '$': aconf->flags |= FLAGS_PASS_IDENTD; break; } *************** *** 844,849 **** --- 853,864 ---- ccount++; aconf->status = CONF_CONNECT_SERVER; break; + #ifdef D_LINES + case 'D': + case 'd': + aconf->status = CONF_DLINE; + break; + #endif #ifdef E_LINES case 'E': /* Addresses that we don't want to check */ case 'e': /* for bots. */ *************** *** 858,863 **** --- 873,884 ---- case 'i': /* to connect me */ aconf->status = CONF_CLIENT; break; + #ifdef J_LINES + case 'J': /* Unused as of yet..*/ + case 'j': + aconf->status = CONF_JLINE; + break; + #endif /* J_LINES */ case 'K': /* Kill user line on irc.conf */ case 'k': aconf->status = CONF_KILL; *************** *** 1096,1102 **** --- 1117,1167 ---- MyFree(host); } #endif /* E_LINES */ + #ifdef D_LINES + if (aconf->host && (aconf->status & CONF_DLINE)) + { + char *host = host_field(aconf); + dontadd = 1; + switch (sortable(host)) + { + case 0 : + l_addto_conf_list(&DList3, aconf, host_field); + break; + case 1 : + addto_conf_list(&DList1, aconf, host_field); + break; + case -1 : + addto_conf_list(&DList2, aconf, rev_host_field); + break; + } + + MyFree(host); + } + #endif /* D_LINES */ + #ifdef J_LINES + if (aconf->host && (aconf->status & CONF_JLINE)) + { + char *host = host_field(aconf); + + dontadd = 1; + switch (sortable(host)) + { + case 0 : + l_addto_conf_list(&JList3, aconf, host_field); + break; + case 1 : + addto_conf_list(&JList1, aconf, host_field); + break; + case -1 : + addto_conf_list(&JList2, aconf, rev_host_field); + break; + } + + MyFree(host); + } + #endif /* J_LINES */ + (void)collapse(aconf->host); (void)collapse(aconf->name); Debug((DEBUG_NOTICE, *************** *** 1211,1217 **** if (tmp->status == CONF_KILL) if (!match(name,kuser) && !match(host,khost)) { ! if (MyClient(sptr)) sendto_one(sptr, ":%s NOTICE %s :K: line not added. %s@%s already matched by %s@%s", me.name, sptr->name, kuser, khost, name, host ); return 1; } --- 1276,1282 ---- if (tmp->status == CONF_KILL) if (!match(name,kuser) && !match(host,khost)) { ! if (sptr && MyClient(sptr)) sendto_one(sptr, ":%s NOTICE %s :K: line not added. %s@%s already matched by %s@%s", me.name, sptr->name, kuser, khost, name, host ); return 1; } *************** *** 1376,1382 **** { char *host, *name; aConfItem *tmp; ! char *rev; aConfList *list; if (!cptr->user) --- 1441,1447 ---- { char *host, *name; aConfItem *tmp; ! char *rev = NULL; aConfList *list; if (!cptr->user) *************** *** 1444,1449 **** --- 1509,1570 ---- } #endif /* E_LINES */ + #ifdef D_LINES + int find_dline(ip) + char *ip; + { + aConfItem *tmp; + char *rev = NULL; + + if (strlen(ip) > (size_t) HOSTLEN) + return 0; + + rev = (char *) MyMalloc(strlen(ip)+1); + reverse(rev, ip); + + /* Start with hostnames of the form "*word" (most frequent) -Sol */ + if ((tmp = find_matching_conf(DList2, rev)) != NULL) + goto found_match; + if ((tmp = find_matching_conf(DList1, ip)) != NULL) + goto found_match; + if ((tmp = l_find_matching_conf(DList3, ip)) != NULL) + goto found_match; + + found_match: + MyFree(rev); + + return (tmp ? -1 : 0); + } + #endif /* D_LINES */ + + #ifdef J_LINES + int find_jline(ip) + char *ip; + { + aConfItem *tmp; + char *rev = NULL; + + if (strlen(ip) > (size_t) HOSTLEN) + return 0; + + rev = (char *) MyMalloc(strlen(ip)+1); + reverse(rev, ip); + + /* Start with hostnames of the form "*word" (most frequent) -Sol */ + if ((tmp = find_matching_conf(JList2, rev)) != NULL) + goto found_match; + if ((tmp = find_matching_conf(JList1, ip)) != NULL) + goto found_match; + if ((tmp = l_find_matching_conf(JList3, ip)) != NULL) + goto found_match; + + found_match: + MyFree(rev); + + return (tmp ? -1 : 0); + } + #endif /* J_LINES */ + #ifdef R_LINES /* find_restrict works against host/name and calls an outside program * to determine whether a client is allowed to connect. This allows diff -c -r irc2.8.21+CSr27/ircd/s_debug.c irc2.8.21+CSr28/ircd/s_debug.c *** irc2.8.21+CSr27/ircd/s_debug.c Sun Sep 15 14:35:37 1996 --- irc2.8.21+CSr28/ircd/s_debug.c Fri Feb 14 16:46:51 1997 *************** *** 202,208 **** #include "numeric.h" #include "common.h" #include "sys.h" - #include "whowas.h" #include "hash.h" #include #ifdef HPUX --- 202,207 ---- *************** *** 445,452 **** totww = 0, tot = 0; ! count_whowas_memory(&wwu, &wwa, &wwam); ! wwm = sizeof(aName) * NICKNAMEHISTORYLENGTH; for (acptr = client; acptr; acptr = acptr->next) { --- 444,452 ---- totww = 0, tot = 0; ! count_whowas_memory(&wwu, &wwm, &wwa, &wwam); ! wwm += sizeof(aWhowas) * NICKNAMEHISTORYLENGTH; ! wwm += sizeof(aWhowas *) * WW_MAX; for (acptr = client; acptr; acptr = acptr->next) { diff -c -r irc2.8.21+CSr27/ircd/s_err.c irc2.8.21+CSr28/ircd/s_err.c *** irc2.8.21+CSr27/ircd/s_err.c Wed Sep 25 20:12:36 1996 --- irc2.8.21+CSr28/ircd/s_err.c Wed Dec 18 18:33:11 1996 *************** *** 255,263 **** /* 221 */ RPL_UMODEIS, "%s", /* 222 */ RPL_STATSBLINE, "%c %s * %s %d %d", /* 223 */ RPL_STATSELINE, "%c %s * %s %d %d", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, ! 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, ! 0, (char *)NULL, /* 231 */ RPL_SERVICEINFO, (char *)NULL, /* 232 */ RPL_ENDOFSERVICES, (char *)NULL, /* 233 */ RPL_SERVICE, (char *)NULL, --- 255,264 ---- /* 221 */ RPL_UMODEIS, "%s", /* 222 */ RPL_STATSBLINE, "%c %s * %s %d %d", /* 223 */ RPL_STATSELINE, "%c %s * %s %d %d", + /* 224 */ RPL_STATSDLINE, "%c %s * %s %d %d", + /* 225 */ RPL_STATSJLINE, "%c %s * %s %d %d", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, ! 0, (char *)NULL, 0, (char *)NULL, /* 231 */ RPL_SERVICEINFO, (char *)NULL, /* 232 */ RPL_ENDOFSERVICES, (char *)NULL, /* 233 */ RPL_SERVICE, (char *)NULL, diff -c -r irc2.8.21+CSr27/ircd/s_serv.c irc2.8.21+CSr28/ircd/s_serv.c *** irc2.8.21+CSr27/ircd/s_serv.c Mon Nov 11 20:16:33 1996 --- irc2.8.21+CSr28/ircd/s_serv.c Tue Mar 25 21:14:22 1997 *************** *** 1317,1323 **** if (IsNeedIdentd(tmp)) strcat(string, "+"); if (IsPassIdentd(tmp)) ! strcat(string, "#"); /* * On K line the passwd contents can be /* displayed on STATS reply. -Vesa --- 1317,1323 ---- if (IsNeedIdentd(tmp)) strcat(string, "+"); if (IsPassIdentd(tmp)) ! strcat(string, "$"); /* * On K line the passwd contents can be /* displayed on STATS reply. -Vesa *************** *** 1504,1509 **** --- 1504,1513 ---- { if (!(acptr = local[i])) continue; + if (IsPerson(acptr) && + !IsAnOper(acptr) && !IsAnOper(sptr) && + (acptr != sptr)) + continue; if (IsInvisible(acptr) && (doall || wilds) && !(MyConnect(sptr) && IsOper(sptr)) && !IsAnOper(acptr) && (acptr != sptr)) *************** *** 1537,1542 **** --- 1541,1556 ---- report_configured_links(sptr, CONF_CONNECT_SERVER| CONF_NOCONNECT_SERVER); break; + #ifdef D_LINES + case 'D' : case 'd' : + report_conf_links(sptr, &DList1, RPL_STATSDLINE, 'D', + NULL, NULL, NULL); + report_conf_links(sptr, &DList2, RPL_STATSDLINE, 'D', + NULL, NULL, NULL); + report_conf_links(sptr, &DList3, RPL_STATSDLINE, 'D', + NULL, NULL, NULL); + break; + #endif #ifdef E_LINES case 'E' : case 'e' : report_conf_links(sptr, &EList1, RPL_STATSELINE, 'E', *************** *** 1553,1558 **** --- 1567,1582 ---- case 'I' : case 'i' : report_configured_links(sptr, CONF_CLIENT); break; + #ifdef J_LINES + case 'J' : case 'j' : + report_conf_links(sptr, &JList1, RPL_STATSJLINE, 'J', + NULL, NULL, NULL); + report_conf_links(sptr, &JList2, RPL_STATSJLINE, 'J', + NULL, NULL, NULL); + report_conf_links(sptr, &JList3, RPL_STATSJLINE, 'J', + NULL, NULL, NULL); + break; + #endif case 'K' : case 'k' : tmpptr = NULL; user = host = NULL; *************** *** 1979,1985 **** return 0; } ! if (!IsServer(sptr)) { pv[0] = parv[0]; pv[1] = "#wallops"; --- 2003,2009 ---- return 0; } ! if (!IsServer(sptr) && MyConnect(sptr) && !IsOper(sptr)) { pv[0] = parv[0]; pv[1] = "#wallops"; *************** *** 1987,1993 **** pv[3] = NULL; return m_private(cptr, sptr, 3, pv); } ! sendto_ops_butone(IsServer(cptr) ? cptr : NULL, sptr, ":%s WALLOPS :%s", parv[0], message); #ifdef USE_SERVICES check_services_butone(SERVICE_WANT_WALLOP, sptr, ":%s WALLOP :%s", --- 2011,2017 ---- pv[3] = NULL; return m_private(cptr, sptr, 3, pv); } ! sendto_wallops_butone(IsServer(cptr) ? cptr : NULL, sptr, ":%s WALLOPS :%s", parv[0], message); #ifdef USE_SERVICES check_services_butone(SERVICE_WANT_WALLOP, sptr, ":%s WALLOP :%s", *************** *** 2049,2054 **** --- 2073,2079 ---- return 0; } + #ifdef QUOTE_KLINE int numchar(string, c) *************** *** 2366,2372 **** sendto_one(sptr, ":%s NOTICE %s :Problem writing to the configfile", me.name, parv[0]); close(out); sendto_one(sptr, ":%s NOTICE %s :Added K-Line [%s@%s] to configfile", me.name, parv[0], user, host); - return 0; } --- 2391,2396 ---- *************** *** 2736,2761 **** char *filename; { int fd; ! register aMotd *temp, *last; ! struct stat sb; ! char line[80]; register char *tmp; ! while(motd) { ! temp = motd->next; MyFree(motd); - motd = temp; } ! ! ! if ((fd = open(MOTD, O_RDONLY)) == -1) ! return; ! (void)fstat(fd, &sb); ! motd_tm = localtime(&sb.st_mtime); ! (void)dgets(-1, NULL, 0); /* make sure buffer is at empty pos */ last = NULL; ! while (dgets(fd, line, sizeof(line)-1) > 0) { if ((tmp = (char *)index(line,'\n'))) *tmp = '\0'; --- 2760,2783 ---- char *filename; { int fd; ! register aMotd *temp, *last; ! struct stat sb; ! char line[80]; register char *tmp; ! if ((fd = open(MOTD, O_RDONLY)) == -1) ! return; ! if (fstat(fd, &sb) == -1) ! return; ! for(;motd;motd=last) { ! last = motd->next; MyFree(motd); } ! motd_tm = *localtime(&sb.st_mtime); ! (void)dgets(-1, NULL, 0); /* make sure buffer is at empty pos */ last = NULL; ! while (dgets(fd, line, sizeof(line)-1) > 0) { if ((tmp = (char *)index(line,'\n'))) *tmp = '\0'; *************** *** 2772,2779 **** last->next = temp; last = temp; } ! (void)dgets(-1, NULL, 0); /* make sure buffer is at empty pos */ ! (void)close(fd); } #endif --- 2794,2801 ---- last->next = temp; last = temp; } ! (void)dgets(-1, NULL, 0); /* make sure buffer is at empty pos */ ! (void)close(fd); } #endif *************** *** 2806,2812 **** return 0; #ifdef BETTER_MOTD ! tm = motd_tm; if (motd == NULL) { sendto_one(sptr, err_str(ERR_NOMOTD), me.name, parv[0]); --- 2828,2834 ---- return 0; #ifdef BETTER_MOTD ! tm = &motd_tm; if (motd == NULL) { sendto_one(sptr, err_str(ERR_NOMOTD), me.name, parv[0]); *************** *** 2813,2828 **** return 0; } sendto_one(sptr, rpl_str(RPL_MOTDSTART), me.name, parv[0], me.name); - if (tm) sendto_one(sptr, ":%s %d %s :- %d/%d/%d %d:%02d", me.name, RPL_MOTD, parv[0], tm->tm_mday, tm->tm_mon+1, 1900+tm->tm_year, tm->tm_hour, tm->tm_min); ! temp=motd; ! while(temp) ! { sendto_one(sptr, rpl_str(RPL_MOTD), me.name, parv[0], temp->line); - temp=temp->next; - } sendto_one(sptr, rpl_str(RPL_ENDOFMOTD), me.name, parv[0]); return 0; #else --- 2835,2845 ---- return 0; } sendto_one(sptr, rpl_str(RPL_MOTDSTART), me.name, parv[0], me.name); sendto_one(sptr, ":%s %d %s :- %d/%d/%d %d:%02d", me.name, RPL_MOTD, parv[0], tm->tm_mday, tm->tm_mon+1, 1900+tm->tm_year, tm->tm_hour, tm->tm_min); ! for(temp=motd;temp;temp=temp->next) sendto_one(sptr, rpl_str(RPL_MOTD), me.name, parv[0], temp->line); sendto_one(sptr, rpl_str(RPL_ENDOFMOTD), me.name, parv[0]); return 0; #else diff -c -r irc2.8.21+CSr27/ircd/s_user.c irc2.8.21+CSr28/ircd/s_user.c *** irc2.8.21+CSr27/ircd/s_user.c Mon Nov 11 18:03:23 1996 --- irc2.8.21+CSr28/ircd/s_user.c Tue Mar 25 21:12:30 1997 *************** *** 431,436 **** --- 431,443 ---- strncpyzt(user->host, me.sockhost, HOSTLEN+1); else strncpyzt(user->host, sptr->sockhost, HOSTLEN+1); + if (strchr(user->host, '\n')) + { + sendto_flagops(OPERS, "%s tried an invalid hostname", + sptr->name); + ircstp->is_ref++; + return exit_client(cptr, sptr, &me, "Invalid hostname"); + } aconf = sptr->confs->value.aconf; if (sptr->flags & FLAGS_GOTID) strncpyzt(user->username, sptr->username, USERLEN+1); *************** *** 481,487 **** --- 488,520 ---- #endif if (oldstatus == STAT_MASTER && MyConnect(sptr)) (void)m_oper(&me, sptr, 1, parv); + #ifdef STRICT_USERNAMES + { + register char *tmpstr; + register int special = 0; + static char validchars[]= + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_"; + tmpstr = (user->username[0] == '~') ? + user->username+1 : + user->username; + while(*tmpstr) + { + if (!strchr(validchars, *tmpstr)) + special++; + tmpstr++; + } + if (special) + { + sendto_flagops(BMODE,"Invalid username: %s [%s@%s]", + nick, user->username, user->host); + ircstp->is_ref++; + sendto_one(sptr, ":%s NOTICE %s :Sorry, your userid contains invalid characters.", me.name, parv[0]); + sendto_one(sptr, ":%s NOTICE %s :Only letters and numbers are allowed.", me.name, parv[0]); + return exit_client(cptr, sptr, &me, "Invalid username"); + } + } + #else /* STRICT_USERNAMES */ #if defined(NO_MIXED_CASE) || defined(NO_SPECIAL) { register char *tmpstr, c; *************** *** 531,537 **** --- 564,572 ---- #if defined(NO_MIXED_CASE) || defined(NO_SPECIAL) } #endif + #endif /* STRICT_USERNAMES */ + #ifdef REJECT_BOTS bottype = "Rejecting"; #elif defined(BOTS_NOTICE) *************** *** 1171,1177 **** timedelta; sendto_common_channels(sptr, ":%s NICK :%s", parv[0], nick); if (sptr->user) ! add_history(sptr); sendto_TS_serv_butone(1, cptr, ":%s NICK %s :%ld", parv[0], nick, sptr->tsinfo); sendto_TS_serv_butone(0, cptr, ":%s NICK :%s", parv[0], --- 1206,1212 ---- timedelta; sendto_common_channels(sptr, ":%s NICK :%s", parv[0], nick); if (sptr->user) ! add_history(sptr, 1); sendto_TS_serv_butone(1, cptr, ":%s NICK %s :%ld", parv[0], nick, sptr->tsinfo); sendto_TS_serv_butone(0, cptr, ":%s NICK :%s", parv[0], *************** *** 1452,1460 **** return m_message(cptr, sptr, parc, parv, 1); } ! static void do_who(sptr, acptr, repchan) ! aClient *sptr, *acptr; aChannel *repchan; { char status[5]; int i = 0; --- 1487,1497 ---- return m_message(cptr, sptr, parc, parv, 1); } ! static void do_who(sptr, acptr, repchan, lp) ! aClient *sptr; ! aClient *acptr; aChannel *repchan; + Link *lp; { char status[5]; int i = 0; *************** *** 1465,1474 **** status[i++] = 'H'; if (IsAnOper(acptr)) status[i++] = '*'; ! if (repchan && is_chan_op(acptr, repchan)) ! status[i++] = '@'; ! else if (repchan && has_voice(acptr, repchan)) ! status[i++] = '+'; status[i] = '\0'; sendto_one(sptr, rpl_str(RPL_WHOREPLY), me.name, sptr->name, (repchan) ? (repchan->chname) : "*", acptr->user->username, --- 1502,1516 ---- status[i++] = 'H'; if (IsAnOper(acptr)) status[i++] = '*'; ! if ((repchan != NULL) && (lp == NULL)) ! lp = find_user_link(repchan->members, acptr); ! if (lp != NULL) ! { ! if (lp->flags & CHFL_CHANOP) ! status[i++] = '@'; ! else if (lp->flags & CHFL_VOICE) ! status[i++] = '+'; ! } status[i] = '\0'; sendto_one(sptr, rpl_str(RPL_WHOREPLY), me.name, sptr->name, (repchan) ? (repchan->chname) : "*", acptr->user->username, *************** *** 1476,1482 **** status, acptr->hopcount, acptr->info); } - /* ** m_who ** parv[0] = sender prefix --- 1518,1523 ---- *************** *** 1492,1512 **** Reg2 char *mask = parc > 1 ? parv[1] : NULL; Reg3 Link *lp; aChannel *chptr; ! aChannel *mychannel; char *channame = NULL, *s; int oper = parc > 2 ? (*parv[2] == 'o' ): 0; /* Show OPERS only */ int member; - if (!BadPtr(mask)) - { - if ((s = (char *)index(mask, ','))) - { - parv[1] = ++s; - (void)m_who(cptr, sptr, parc, parv); - } - clean_channelname(mask); - } - mychannel = NullChn; if (sptr->user) if ((lp = sptr->user->channel)) --- 1533,1544 ---- Reg2 char *mask = parc > 1 ? parv[1] : NULL; Reg3 Link *lp; aChannel *chptr; ! aChannel *mychannel = NULL; char *channame = NULL, *s; int oper = parc > 2 ? (*parv[2] == 'o' ): 0; /* Show OPERS only */ int member; + int maxmatches = 500; mychannel = NullChn; if (sptr->user) if ((lp = sptr->user->channel)) *************** *** 1513,1519 **** mychannel = lp->value.chptr; /* Allow use of m_who without registering */ ! /* ** Following code is some ugly hacking to preserve the ** functions of the old implementation. (Also, people --- 1545,1555 ---- mychannel = lp->value.chptr; /* Allow use of m_who without registering */ ! /* Not anymore...- Comstud */ ! ! if (check_registered_user(sptr)) ! return 0; ! /* ** Following code is some ugly hacking to preserve the ** functions of the old implementation. (Also, people *************** *** 1520,1561 **** ** will complain when they try to use masks like "12tes*" ** and get people on channel 12 ;) --msa */ ! if (!mask || *mask == '\0') ! mask = NULL; ! else if (mask[1] == '\0' && mask[0] == '*') ! { ! mask = NULL; ! if (mychannel) ! channame = mychannel->chname; ! } ! else if (mask[1] == '\0' && mask[0] == '0') /* "WHO 0" for irc.el */ ! mask = NULL; else channame = mask; - (void)collapse(mask); if (IsChannelName(channame)) ! { /* * List all users on a given channel */ chptr = find_channel(channame, NULL); if (chptr) ! { ! member = IsMember(sptr, chptr); ! if (member || !SecretChannel(chptr)) for (lp = chptr->members; lp; lp = lp->next) ! { if (oper && !IsAnOper(lp->value.cptr)) continue; if (IsInvisible(lp->value.cptr) && !member) continue; ! do_who(sptr, lp->value.cptr, chptr); ! } ! } ! } else for (acptr = client; acptr; acptr = acptr->next) ! { aChannel *ch2ptr = NULL; int showperson, isinvis; --- 1556,1618 ---- ** will complain when they try to use masks like "12tes*" ** and get people on channel 12 ;) --msa */ ! if (mask) ! (void)collapse(mask); ! if (!mask || (*mask == (char) 0)) ! goto endofwho; ! else if ((*(mask+1) == (char) 0) && (*mask == '*')) ! { ! if (!mychannel) ! goto endofwho; ! channame = mychannel->chname; ! } else channame = mask; if (IsChannelName(channame)) ! { /* * List all users on a given channel */ chptr = find_channel(channame, NULL); if (chptr) ! { ! member = IsMember(sptr, chptr); ! if (member || !SecretChannel(chptr)) for (lp = chptr->members; lp; lp = lp->next) ! { if (oper && !IsAnOper(lp->value.cptr)) continue; if (IsInvisible(lp->value.cptr) && !member) continue; ! do_who(sptr, lp->value.cptr, chptr, lp); ! } ! } ! } ! else if (mask && ! ((acptr = find_client(mask, NULL)) != NULL) && ! IsPerson(acptr) && (!oper || IsAnOper(acptr))) ! { ! int isinvis = 0; ! aChannel *ch2ptr = NULL; ! ! isinvis = IsInvisible(acptr); ! for (lp = acptr->user->channel; lp; lp = lp->next) ! { ! chptr = lp->value.chptr; ! member = IsMember(sptr, chptr); ! if (isinvis && !member) ! continue; ! if (member || (!isinvis && PubChannel(chptr))) ! { ! ch2ptr = chptr; ! break; ! } ! } ! do_who(sptr, acptr, ch2ptr, NULL); ! } else for (acptr = client; acptr; acptr = acptr->next) ! { aChannel *ch2ptr = NULL; int showperson, isinvis; *************** *** 1563,1568 **** --- 1620,1626 ---- continue; if (oper && !IsAnOper(acptr)) continue; + showperson = 0; /* * Show user if they are on the same channel, or not *************** *** 1573,1609 **** */ isinvis = IsInvisible(acptr); for (lp = acptr->user->channel; lp; lp = lp->next) ! { chptr = lp->value.chptr; member = IsMember(sptr, chptr); if (isinvis && !member) continue; ! if (member || (!isinvis && ShowChannel(sptr, chptr))) ! { ch2ptr = chptr; showperson = 1; break; ! } if (HiddenChannel(chptr) && !SecretChannel(chptr) && !isinvis) showperson = 1; ! } if (!acptr->user->channel && !isinvis) showperson = 1; - /* - ** This is brute force solution, not efficient...? ;( - ** Show entry, if no mask or any of the fields match - ** the mask. --msa - */ if (showperson && ! (!mask || ! match(mask, acptr->name) == 0 || ! match(mask, acptr->user->username) == 0 || ! match(mask, acptr->user->host) == 0 || ! match(mask, acptr->user->server) == 0 || ! match(mask, acptr->info) == 0)) ! do_who(sptr, acptr, ch2ptr); ! } sendto_one(sptr, rpl_str(RPL_ENDOFWHO), me.name, parv[0], BadPtr(mask) ? "*" : mask); return 0; --- 1631,1667 ---- */ isinvis = IsInvisible(acptr); for (lp = acptr->user->channel; lp; lp = lp->next) ! { chptr = lp->value.chptr; member = IsMember(sptr, chptr); if (isinvis && !member) continue; ! if (member || (!isinvis && PubChannel(chptr))) ! { ch2ptr = chptr; showperson = 1; break; ! } if (HiddenChannel(chptr) && !SecretChannel(chptr) && !isinvis) showperson = 1; ! } if (!acptr->user->channel && !isinvis) showperson = 1; if (showperson && ! (!mask || ! !match(mask, acptr->name) || ! !match(mask, acptr->user->username) || ! !match(mask, acptr->user->host) || ! !match(mask, acptr->user->server) || ! !match(mask, acptr->info))) ! { ! do_who(sptr, acptr, ch2ptr, NULL); ! if (!--maxmatches) ! goto endofwho; ! } ! } ! endofwho: sendto_one(sptr, rpl_str(RPL_ENDOFWHO), me.name, parv[0], BadPtr(mask) ? "*" : mask); return 0; diff -c -r irc2.8.21+CSr27/ircd/whowas.c irc2.8.21+CSr28/ircd/whowas.c *** irc2.8.21+CSr27/ircd/whowas.c Mon Nov 11 18:02:51 1996 --- irc2.8.21+CSr28/ircd/whowas.c Tue Mar 25 20:15:35 1997 *************** *** 1,140 **** /************************************************************************ ! * IRC - Internet Relay Chat, ircd/whowas.c ! * Copyright (C) 1990 Markku Savela ! * ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 1, or (at your option) ! * any later version. ! * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! */ /* ! * --- avalon --- 6th April 1992 ! * rewritten to scrap linked lists and use a table of structures which ! * is referenced like a circular loop. Should be faster and more efficient. ! */ ! #ifndef lint ! static char sccsid[] = "@(#)whowas.c 2.16 08 Nov 1993 (C) 1988 Markku Savela"; ! #endif #include "struct.h" #include "common.h" #include "sys.h" #include "numeric.h" - #include "whowas.h" #include "h.h" ! static aName was[NICKNAMEHISTORYLENGTH]; ! static int ww_index = 0; ! void add_history(cptr) ! Reg1 aClient *cptr; { ! aName ntmp; ! Reg2 aName *np = &ntmp, *np2; ! strncpyzt(np->ww_nick, cptr->name, NICKLEN+1); ! strncpyzt(np->ww_info, cptr->info, REALLEN+1); ! np->ww_user = cptr->user; ! np->ww_logout = NOW; ! np->ww_online = (cptr->from != NULL) ? cptr : NULL; ! np->ww_user->refcnt++; ! ! np2 = &was[ww_index]; ! if (np2->ww_user) ! free_user(np2->ww_user, np2->ww_online); ! ! bcopy((char *)&ntmp, (char *)np2, sizeof(aName)); ! ! ww_index++; ! if (ww_index >= NICKNAMEHISTORYLENGTH) ! ww_index = 0; ! return; } ! /* ! ** get_history ! ** Return the current client that was using the given ! ** nickname within the timelimit. Returns NULL, if no ! ** one found... ! */ ! aClient *get_history(nick, timelimit) ! char *nick; ! time_t timelimit; { ! Reg1 aName *wp, *wp2; ! Reg2 int i = 0; ! wp = wp2 = &was[ww_index]; ! timelimit = NOW-timelimit; ! ! do { ! if (!mycmp(nick, wp->ww_nick) && wp->ww_logout >= timelimit) ! break; ! wp++; ! if (wp == &was[NICKNAMEHISTORYLENGTH]) ! i = 1, wp = was; ! } while (wp != wp2); ! ! if (wp != wp2 || !i) ! return (wp->ww_online); ! return (NULL); } ! void off_history(cptr) ! Reg3 aClient *cptr; { ! Reg1 aName *wp; ! Reg2 int i; ! for (i = NICKNAMEHISTORYLENGTH, wp = was; i; wp++, i--) ! if (wp->ww_online == cptr) ! wp->ww_online = NULL; ! return; } ! void initwhowas() { ! Reg1 int i; ! for (i = 0; i < NICKNAMEHISTORYLENGTH; i++) ! bzero((char *)&was[i], sizeof(aName)); ! return; ! } ! /* ** m_whowas ! ** parv[0] = sender prefix ! ** parv[1] = nickname queried */ ! int m_whowas(cptr, sptr, parc, parv) ! aClient *cptr, *sptr; ! int parc; ! char *parv[]; { ! Reg1 aName *wp, *wp2 = NULL; ! Reg2 int j = 0; ! Reg3 anUser *up = NULL; ! int max = -1; ! char *p, *nick, *s; ! if (parc < 2) ! { sendto_one(sptr, err_str(ERR_NONICKNAMEGIVEN), ! me.name, parv[0]); return 0; ! } if (parc > 2) max = atoi(parv[2]); if (parc > 3) --- 1,182 ---- /************************************************************************ ! * IRC - Internet Relay Chat, ircd/whowas.c ! * Copyright (C) 1990 Markku Savela ! * ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 1, or (at your option) ! * any later version. ! * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! */ /* ! * --- avalon --- 6th April 1992 ! * rewritten to scrap linked lists and use a table of structures which ! * is referenced like a circular loop. Should be faster and more efficient. ! */ ! /* ! * --- comstud --- 25th March 1997 ! * Everything rewritten from scratch. Avalon's code is shit. My version ! * is faster and more efficient. No more hangs on /squits and you can ! * safely raise NICKNAMEHISTORYLENGTH to a higher value without hurting ! * performance ! */ #include "struct.h" #include "common.h" #include "sys.h" #include "numeric.h" #include "h.h" + + aWhowas WHOWAS[NICKNAMEHISTORYLENGTH]; + aWhowas *WHOWASHASH[WW_MAX]; ! int whowas_next = 0; ! void add_history(cptr, online) ! aClient *cptr; ! int online; { ! aWhowas *new; ! new = &WHOWAS[whowas_next]; ! if (new->hashv != -1) ! { ! if (new->online) ! del_whowas_from_clist(&(new->online->whowas), ! new); ! del_whowas_from_list(&WHOWASHASH[new->hashv], new); ! if (new->name) ! MyFree(new->name); ! if (new->username) ! MyFree(new->username); ! if (new->servername) ! MyFree(new->servername); ! if (new->hostname) ! MyFree(new->hostname); ! if (new->realname) ! MyFree(new->realname); ! if (new->away) ! MyFree(new->away); ! } ! new->hashv = hash_whowas_name(cptr->name); ! new->logoff = NOW; ! mstrcpy(&new->name, cptr->name); ! mstrcpy(&new->username, cptr->user->username); ! mstrcpy(&new->hostname, cptr->user->host); ! mstrcpy(&new->realname, cptr->info); ! mstrcpy(&new->servername, cptr->user->server); ! if (cptr->user->away) ! mstrcpy(&new->away, cptr->user->away); ! else ! new->away = NULL; ! if (online) ! { ! new->online = cptr; ! add_whowas_to_clist(&(cptr->whowas), new); ! } ! else ! new->online = NULL; ! add_whowas_to_list(&WHOWASHASH[new->hashv], new); ! whowas_next++; ! if (whowas_next == NICKNAMEHISTORYLENGTH) ! whowas_next = 0; } ! void off_history(cptr) ! aClient *cptr; { ! aWhowas *temp, *next; ! for(temp=cptr->whowas;temp;temp=next) ! { ! next = temp->cnext; ! temp->online = NULL; ! del_whowas_from_clist(&(cptr->whowas), temp); ! } } ! aClient *get_history(nick, timelimit) ! char *nick; ! time_t timelimit; { ! aWhowas *temp; ! int blah; ! timelimit = NOW - timelimit; ! blah = hash_whowas_name(nick); ! temp = WHOWASHASH[blah]; ! for(;temp;temp=temp->next) ! { ! if (mycmp(nick, temp->name)) ! continue; ! if (temp->logoff < timelimit) ! continue; ! return temp->online; ! } ! return NULL; } ! void count_whowas_memory(wwu, wwum, wwa, wwam) ! int *wwu, *wwa; ! u_long *wwum, *wwam; { ! register aWhowas *tmp; ! register int i; ! int u = 0, a = 0; ! u_long um = 0, am = 0; ! for (i = 0, tmp = &WHOWAS[0]; i < NICKNAMEHISTORYLENGTH; i++, tmp++) ! if (tmp->hashv != -1) ! { ! u++; ! um += (strlen(tmp->name) + 1); ! um += (strlen(tmp->username) + 1); ! um += (strlen(tmp->hostname) + 1); ! um += (strlen(tmp->servername) + 1); ! if (tmp->away) ! { ! a++; ! am += (strlen(tmp->away) + 1); ! } ! } ! *wwu = u; ! *wwum = um; ! *wwa = a; ! *wwam = am; ! return; ! } /* ** m_whowas ! ** parv[0] = sender prefix ! ** parv[1] = nickname queried */ ! int m_whowas(cptr, sptr, parc, parv) ! aClient *cptr, *sptr; ! int parc; ! char *parv[]; { ! register aWhowas *temp; ! register int cur = 0; ! int max = -1, found = 0; ! char *p, *nick, *s; ! if (parc < 2) ! { sendto_one(sptr, err_str(ERR_NONICKNAMEGIVEN), ! me.name, parv[0]); return 0; ! } if (parc > 2) max = atoi(parv[2]); if (parc > 3) *************** *** 145,217 **** if (!MyConnect(sptr) && (max > 20)) max = 20; for (s = parv[1]; (nick = strtoken(&p, s, ",")); s = NULL) ! { ! wp = wp2 = &was[ww_index - 1]; ! do { ! if (wp < was) ! wp = &was[NICKNAMEHISTORYLENGTH - 1]; ! if (mycmp(nick, wp->ww_nick) == 0) ! { ! up = wp->ww_user; ! sendto_one(sptr, rpl_str(RPL_WHOWASUSER), ! me.name, parv[0], wp->ww_nick, ! up->username, ! up->host, wp->ww_info); ! sendto_one(sptr, rpl_str(RPL_WHOISSERVER), ! me.name, parv[0], wp->ww_nick, ! up->server, myctime(wp->ww_logout)); ! if (up->away) ! sendto_one(sptr, rpl_str(RPL_AWAY), ! me.name, parv[0], ! wp->ww_nick, up->away); ! j++; ! } ! if (max > 0 && j >= max) ! break; ! wp--; ! } while (wp != wp2); ! ! if (up == NULL) ! sendto_one(sptr, err_str(ERR_WASNOSUCHNICK), ! me.name, parv[0], nick); ! ! if (p) ! p[-1] = ','; ! } ! sendto_one(sptr, rpl_str(RPL_ENDOFWHOWAS), me.name, parv[0], parv[1]); ! return 0; ! } ! ! ! void count_whowas_memory(wwu, wwa, wwam) ! int *wwu, *wwa; ! u_long *wwam; { ! Reg1 anUser *tmp; ! Reg2 int i, j; ! int u = 0, a = 0; ! u_long am = 0; ! for (i = 0; i < NICKNAMEHISTORYLENGTH; i++) ! if ((tmp = was[i].ww_user)) ! if (!was[i].ww_online) ! { ! for (j = 0; j < i; j++) ! if (was[j].ww_user == tmp) ! break; ! if (j < i) ! continue; ! u++; ! if (tmp->away) ! { ! a++; ! am += (strlen(tmp->away)+1); ! } ! } ! *wwu = u; ! *wwa = a; ! *wwam = am; ! ! return; } --- 187,237 ---- if (!MyConnect(sptr) && (max > 20)) max = 20; for (s = parv[1]; (nick = strtoken(&p, s, ",")); s = NULL) ! { ! temp = WHOWASHASH[hash_whowas_name(nick)]; ! found = 0; ! for(;temp;temp=temp->next) ! { ! if (!mycmp(nick, temp->name)) ! { ! sendto_one(sptr, rpl_str(RPL_WHOWASUSER), ! me.name, parv[0], temp->name, ! temp->username, ! temp->hostname, ! temp->realname); ! sendto_one(sptr, rpl_str(RPL_WHOISSERVER), ! me.name, parv[0], temp->name, ! temp->servername, myctime(temp->logoff)); ! if (temp->away) ! sendto_one(sptr, rpl_str(RPL_AWAY), ! me.name, parv[0], ! temp->name, temp->away); ! cur++; ! found++; ! } ! if (max > 0 && cur >= max) ! break; ! } ! if (!found) ! sendto_one(sptr, err_str(ERR_WASNOSUCHNICK), ! me.name, parv[0], nick); ! if (p) ! p[-1] = ','; ! } ! sendto_one(sptr, rpl_str(RPL_ENDOFWHOWAS), me.name, parv[0], parv[1]); ! return 0; ! } ! void initwhowas() { ! register int i; ! for (i=0;i