diff -c -r -N irc2.8.21+CSr20/Makefile irc2.8.21+CSr24/Makefile *** irc2.8.21+CSr20/Makefile Sun Jan 21 11:37:12 1996 --- irc2.8.21+CSr24/Makefile Wed Jul 24 21:31:56 1996 *************** *** 23,29 **** #-I/usr/gnu/include # Default flags: ! CFLAGS= -I$(INCLUDEDIR) -O2 #IRCDLIBS=-L/usr/lib -L/usr/gnu/lib -lgnuc -O2 IRCLIBS=-lcurses -ltermcap # --- 23,30 ---- #-I/usr/gnu/include # Default flags: ! CFLAGS= -I$(INCLUDEDIR) -g ! #O2 #IRCDLIBS=-L/usr/lib -L/usr/gnu/lib -lgnuc -O2 IRCLIBS=-lcurses -ltermcap # *************** *** 54,60 **** #IRCDLIBS=-lresolv # # Solaris 2 ! #IRCDLIBS=-lsocket -lnsl #IRCLIBS=-lcurses -ltermcap -lresolv -lsocket -lnsl # # ESIX --- 55,61 ---- #IRCDLIBS=-lresolv # # Solaris 2 ! #IRCDLIBS=-lsocket -lnsl -lresolv #IRCLIBS=-lcurses -ltermcap -lresolv -lsocket -lnsl # # ESIX diff -c -r -N irc2.8.21+CSr20/README.CS irc2.8.21+CSr24/README.CS *** irc2.8.21+CSr20/README.CS Sun Jan 21 11:51:06 1996 --- irc2.8.21+CSr24/README.CS Wed Jul 24 22:26:44 1996 *************** *** 1,5 **** --- 1,71 ---- + --- + + This is the README for irc2.8.21+CSr24. 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@stealth.net + + --- + 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 CSr24: + + 1) BUFFERED_LOGS were not logging at all...this is fixed. + 2) Patched match.c to fix coredumps + 3) Attempted to add poll(), using basically all of the code from 2.9 + This is for Solaris folks only, of course. There is a #define in + config.h for "USE_POLL" after the section where you #define SOL20 + 4) Added #define LIMIT_UH. You can now limit your server to only allow + a certain # of connections from a u@h...For example, LIMIT_UH 1 will + only allow 1 u@h per client. If another person with the same u@h tries + to connect, they will be rejected. While on IRC, you can /QUOTE LIMITUH # + 5) Added a notice to opers when a person tries to "evade" identd. + I had this in one of my 2.8.16 ircds, but when ds2 added it to his, it + reminded me that I had forgotten to carry it over to my 2.8.21 series... + Thanks, buddy =) Sorry, I am going to stick with using identd replies + for clients' usernames. + + New in CSr23: + + 1) Changed the timing of the NO_NICK_FLOODS stuff. If you change your + nick 4 times within 15 seconds, you can't change your nick for 30 seconds. + 2) Commented out the flushing of dns cache when /rehashing. There seems + to be a problem on some OS's where the cache isn't cleared and ircd + coredumps soon after the rehash() function ends. + 3) Changed read_motd() to work on all systems. On AIX the last line + of the motd was being read 2 times. + 4) Fixed a small bug where 'motd' wasn't init'd correctly when the + server would start. + + New in CSr22: + + 1) Fixed REJECT_BOTS stuff. This was broken starting with r20 or so. + The actual problem was just a missing closing comment (*/) in comstud.h + 2) Fixed K: lines that I broke in ircd.c in r21. I had an /* instead of */ + which basically commented out all the K: checking. + 3) Fixed the mode #chan +k bug. + 4) Added BETTER_MOTD which keeps the ircd.motd in RAM which saves a lot + of disk access on high-access client servers + If you change the /motd, just /rehash to "reload" it. + 5) Added BUFFERED_LOGS which doesn't write to users.log and clones.log + each time a client exits or is rejected for cloning. This should + save some disk access as well, tho using a bit more RAM :-/ + 6) Disabled channel TS stuff once again. + + + New in CSr21: + + 1) Readded IDLE_CHECK, using ds2's idea of not allowing them to reconnect + after being kicked off. + 2) Added a NO_NICK_FLOODS define, disallowing users to change nicks after + 3 times in 60 seconds. + 3) Added DWildstar's patches for "Non-chanop" messages.. + 4) Fixed bugs in s_user.c dealing with TS (found by Taner) + 5) Hopefully fixed "Invis count off" notices... + 6) Reenabled channel TS stuff. + 7) Tried to fix a bug where the server sends "Odd Server Stuff" to clients New in CSr20: diff -c -r -N irc2.8.21+CSr20/common/inet_addr.c irc2.8.21+CSr24/common/inet_addr.c *** irc2.8.21+CSr20/common/inet_addr.c Sat Jan 6 23:30:09 1996 --- irc2.8.21+CSr24/common/inet_addr.c Wed Jul 24 20:23:43 1996 *************** *** 61,66 **** --- 61,70 ---- #include "nameser.h" #include "resolv.h" + #ifndef INADDR_NONE + #define INADDR_NONE -1 + #endif + /* this is a compatibility routine, not needed on recent BSD releases */ #ifdef NEED_INET_ADDR /* diff -c -r -N irc2.8.21+CSr20/common/match.c irc2.8.21+CSr24/common/match.c *** irc2.8.21+CSr20/common/match.c Sat Jan 6 23:30:09 1996 --- irc2.8.21+CSr24/common/match.c Sat Jul 20 01:10:06 1996 *************** *** 27,34 **** #include "sys.h" - static int calls = 0; - #define MAX_CALLS 200 /* ** Compare if a given string (name) matches the given ** mask (which can contain wild cards: '*' - match any --- 27,32 ---- *************** *** 53,60 **** while (1) { - if (calls++ > MAX_CALLS) - return 1; if (*m == '*') { while (*m == '*') --- 51,56 ---- *************** *** 115,128 **** int match(ma, na) char *ma, *na; { - calls = 0; return _match(ma, na); } int matches(ma, na) char *ma,*na; { - calls = 0; return _match(ma, na); } --- 111,122 ---- diff -c -r -N irc2.8.21+CSr20/include/comstud.h irc2.8.21+CSr24/include/comstud.h *** irc2.8.21+CSr20/include/comstud.h Sun Jan 21 00:06:02 1996 --- irc2.8.21+CSr24/include/comstud.h Wed Jul 24 23:46:24 1996 *************** *** 1,6 **** --- 1,41 ---- #ifndef COMSTUD_H #define COMSTUD_H + /* LIMIT_UH - If you want to limit clients to 1 u@h on your server, + define this to 1. You can also define this to 0 + which disables the check...but it will compile the + code into the server, and then you can /quote limituh # + while opered. + If you never want to use this, #undef it. + Examples: + + #define LIMIT_UH 1 - Starts out limiting 1 client per user@host + #define LIMIT_UH 0 - Starts out with no checking, but you can /quote + #undef LIMIT_UH - Doesn't compile in the code.../quote won't work. + */ + + #define LIMIT_UH 0 + + + /* BUFFERED_LOGS - define this to reduce disk IO when writing users.log + and clones.log + */ + + #define BUFFERED_LOGS + + + /* BETTER_MOTD - define this to keep the MOTD in ram to reduce disk + IO. /REHASH to reload the MOTD. + */ + + #define BETTER_MOTD + + /* NO_NICK_FLOODS - define this to limit local users to 3 nick changes + in 60 seconds + */ + + #define NO_NICK_FLOODS + /* RESTRICT - define this if using dog3 stuff, and wish to disallow /LIST and other CPU intensive commands when in HIGH TRAFFIC MODE *************** *** 68,74 **** if they aren't running identd */ ! #define IDENTD_ONLY /* QUOTE_KLINE - define this if you want /QUOTE KLINE */ --- 103,109 ---- if they aren't running identd */ ! #undef IDENTD_ONLY /* QUOTE_KLINE - define this if you want /QUOTE KLINE */ *************** *** 165,170 **** --- 200,206 ---- which is trying to connect is a bot... If it is, it will be rejected from connecting. See BOTS_NOTICE + */ #define REJECT_BOTS *************** *** 199,205 **** want them logged */ ! #define FNAME_FAILED_OPER "/home/irc/irc2.8.21+CSr20/lib/logs/failed.log" /* CLIENT_NOTICES - define this if you wish to see client connecting and exiting notices via /umode +c --- 235,241 ---- want them logged */ ! #define FNAME_FAILED_OPER "/home/irc/irc2.8.21+CSr24/lib/logs/failed.log" /* CLIENT_NOTICES - define this if you wish to see client connecting and exiting notices via /umode +c *************** *** 248,253 **** --- 284,304 ---- #define USERNAMES_IN_TRACE + /* IDLE_CHECK - define this if you wish to have an idle checker + built into the server + Note: Idletime is not reset on msgs to invalid nicks + or channels + Note: Idletime is not reset on msgs to self + + *** *** *** Note: A user will not be able to reconnect for 60 seconds + until after they are knocked off. If they try to connect + before then, 60 more seconds are added to each attempt. + *** *** *** Note: E: line u@h's are exempt from idle checking. + + */ + + #define IDLE_CHECK + /* KLINE_CHECK - this is how often (in seconds) that K: lines should be checked. Every fifteen minutes is a good number (900 seconds). This reduces *************** *** 274,280 **** and you wish to log clones */ ! #define FNAME_CLONELOG "/home/irc/irc2.8.21+CSr20/lib/logs/clones.log" /* THE REST OF THIS STUFF IS TO CONFIGURE CLONE CHECKING */ --- 325,341 ---- and you wish to log clones */ ! #define FNAME_CLONELOG "/home/irc/irc2.8.21+CSr24/lib/logs/clones.log" ! ! /* DEFAULT_IDLELIMIT - if you have CHECK_IDLE defined above, ! this value is the default # a client ! can be idle before being kicked off of ! IRC ! Note: This value can be changed on IRC with ! /quote idle ! */ ! ! #define DEFAULT_IDLELIMIT 0 /* THE REST OF THIS STUFF IS TO CONFIGURE CLONE CHECKING */ diff -c -r -N irc2.8.21+CSr20/include/config.h irc2.8.21+CSr24/include/config.h *** irc2.8.21+CSr20/include/config.h Sun Jan 21 01:51:18 1996 --- irc2.8.21+CSr24/include/config.h Wed Jul 24 21:32:06 1996 *************** *** 54,59 **** --- 54,67 ---- #undef MAIL50 /* If you're running VMS 5.0 */ #undef PCS /* PCS Cadmus MUNIX, use with BSD flag! */ + #ifdef SOL20 + + #define USE_POLL /* Define this if you want to use poll() + on lame Solaris */ + + #endif + + /* * NOTE: On some systems, valloc() causes many problems. */ *************** *** 108,115 **** * these are only the recommened names and paths. Change as needed. * You must define these to something, even if you don't really want them. */ ! #define DPATH "/home/irc/irc2.8.21+CSr20/lib" /* dir where all ircd stuff is */ ! #define SPATH "/home/irc/irc2.8.21+CSr20/lib/ircd" #define CPATH "ircd.conf" /* server configuration file */ #define MPATH "ircd.motd" /* server MOTD file */ #define LPATH "ircd.log" /* Where the debug file lives, if DEBUGMODE */ --- 116,123 ---- * these are only the recommened names and paths. Change as needed. * You must define these to something, even if you don't really want them. */ ! #define DPATH "/home/irc/irc2.8.21+CSr24/lib" /* dir where all ircd stuff is */ ! #define SPATH "/home/irc/irc2.8.21+CSr24/lib/ircd" #define CPATH "ircd.conf" /* server configuration file */ #define MPATH "ircd.motd" /* server MOTD file */ #define LPATH "ircd.log" /* Where the debug file lives, if DEBUGMODE */ *************** *** 123,130 **** * successful use of /oper. These are either full paths or files within DPATH. */ ! #define FNAME_USERLOG "/home/irc/irc2.8.21+CSr20/logs/users.log" /* */ ! #define FNAME_OPERLOG "/home/irc/irc2.8.21+CSr20/logs/opers.log" /* */ /* CHROOTDIR * --- 131,138 ---- * successful use of /oper. These are either full paths or files within DPATH. */ ! #define FNAME_USERLOG "/home/irc/irc2.8.21+CSr24/logs/users.log" /* */ ! #define FNAME_OPERLOG "/home/irc/irc2.8.21+CSr24/logs/opers.log" /* */ /* CHROOTDIR * diff -c -r -N irc2.8.21+CSr20/include/h.h irc2.8.21+CSr24/include/h.h *** irc2.8.21+CSr20/include/h.h Sat Jan 20 23:33:15 1996 --- irc2.8.21+CSr24/include/h.h Wed Jul 24 21:31:34 1996 *************** *** 26,38 **** #include "comstud.h" #ifdef HIGHEST_CONNECTION extern void check_max_count(); #endif /* HIGHEST_CONNECTION */ ! extern int s_count, c_count, ch_count, u_count, i_count; ! extern int o_count, m_clients, m_servers, m_invis; ! extern void compute_lusers(); #if defined(USE_DICH_CONF) || defined(B_LINES) || defined(E_LINES) #include "dich_conf.h" --- 26,49 ---- #include "comstud.h" + #ifdef LIMIT_UH + extern int uhlimit; + #endif + #ifdef HIGHEST_CONNECTION extern void check_max_count(); #endif /* HIGHEST_CONNECTION */ ! ! #ifdef BETTER_MOTD ! extern aMotd *motd; ! extern struct tm *motd_tm; ! #endif ! ! extern int idlelimit; ! extern int s_count, c_count, ch_count, u_count, i_count; ! extern int o_count, m_clients, m_servers, m_invis; ! extern void compute_lusers(); #if defined(USE_DICH_CONF) || defined(B_LINES) || defined(E_LINES) #include "dich_conf.h" *************** *** 69,74 **** --- 80,91 ---- extern aClone *Clones; extern aClone *make_clone PROTO(()); extern aClone *find_clone PROTO(()); + #endif + + #ifdef IDLE_CHECK + extern anIdle *Idles; + extern anIdle *make_idle PROTO(()); + extern anIdle *find_idle PROTO(()); #endif extern time_t NOW; diff -c -r -N irc2.8.21+CSr20/include/msg.h irc2.8.21+CSr24/include/msg.h *** irc2.8.21+CSr20/include/msg.h Sat Jan 6 23:30:08 1996 --- irc2.8.21+CSr24/include/msg.h Wed Jul 24 21:34:14 1996 *************** *** 87,92 **** --- 87,98 ---- #ifdef QUOTE_KLINE #define MSG_KLINE "KLINE" /* KLINE */ #endif + #ifdef IDLE_CHECK + #define MSG_IDLE "IDLE" /* IDLE */ + #endif + #ifdef LIMIT_UH + #define MSG_LIMITUH "LIMITUH" /* LIMITUH */ + #endif #define MAXPARA 15 #ifdef DOG3 *************** *** 96,101 **** --- 102,113 ---- #ifdef QUOTE_KLINE extern int m_kline(); #endif + #ifdef IDLE_CHECK + extern int m_idle(); + #endif + #ifdef LIMIT_UH + extern int m_limituh(); + #endif extern int m_private(), m_topic(), m_join(), m_part(), m_mode(); extern int m_ping(), m_pong(), m_wallops(), m_kick(); extern int m_nick(), m_error(), m_notice(); *************** *** 182,187 **** --- 194,205 ---- #endif #ifdef QUOTE_KLINE { MSG_KLINE, m_kline, 0, MAXPARA, 1 ,0L }, + #endif + #ifdef IDLE_CHECK + { MSG_IDLE, m_idle, 0, MAXPARA, 1 ,0L }, + #endif + #ifdef LIMIT_UH + { MSG_LIMITUH, m_limituh, 0, MAXPARA, 1 ,0L }, #endif #if defined(NPATH) && !defined(CLIENT_COMPILE) { MSG_NOTE, m_note, 0, 1, 1 ,0L }, diff -c -r -N irc2.8.21+CSr20/include/numeric.h irc2.8.21+CSr24/include/numeric.h *** irc2.8.21+CSr20/include/numeric.h Sat Jan 6 23:30:08 1996 --- irc2.8.21+CSr24/include/numeric.h Sat Jun 8 15:39:27 1996 *************** *** 166,171 **** --- 166,172 ---- #define ERR_SERVICENAMEINUSE 434 #define ERR_SERVICECONFUSED 435 #define ERR_NICKCOLLISION 436 + #define ERR_TOOMANYNICKS 437 #define ERR_USERNOTINCHANNEL 441 #define ERR_NOTONCHANNEL 442 diff -c -r -N irc2.8.21+CSr20/include/patchlevel.h irc2.8.21+CSr24/include/patchlevel.h *** irc2.8.21+CSr20/include/patchlevel.h Mon Jan 8 20:33:43 1996 --- irc2.8.21+CSr24/include/patchlevel.h Wed Jul 24 22:29:51 1996 *************** *** 17,21 **** */ #ifndef PATCHLEVEL ! #define PATCHLEVEL "2.8.21+CSr20" #endif --- 17,21 ---- */ #ifndef PATCHLEVEL ! #define PATCHLEVEL "2.8.21+CSr24" #endif diff -c -r -N irc2.8.21+CSr20/include/struct.h irc2.8.21+CSr24/include/struct.h *** irc2.8.21+CSr20/include/struct.h Sat Jan 6 23:30:08 1996 --- irc2.8.21+CSr24/include/struct.h Sat Jun 8 15:39:27 1996 *************** *** 53,59 **** --- 53,61 ---- typedef struct SMode Mode; typedef long ts_val; + typedef struct IdleItem anIdle; typedef struct CloneItem aClone; + typedef struct MotdItem aMotd; #ifndef VMSP #include "class.h" *************** *** 240,245 **** --- 242,255 ---- #define CURSES_TERM 1 #define TERMCAP_TERM 2 + struct IdleItem { + char username[USERLEN+1]; + char hostname[HOSTLEN+1]; + long last; + struct IdleItem *prev; + struct IdleItem *next; + }; + struct CloneItem { char hostname[HOSTLEN+1]; int num; *************** *** 248,253 **** --- 258,268 ---- struct CloneItem *next; }; + struct MotdItem { + char line[82]; + struct MotdItem *next; + }; + struct ConfItem { unsigned int status; /* If CONF_ILLEGAL, delete when no clients */ int clients; /* Number of *LOCAL* clients using this */ *************** *** 370,375 **** --- 385,394 ---- long lastrecvM; /* to check for activity --Mika */ int priority; #endif + #ifdef NO_NICK_FLOODS + long lastnick; + int numnicks; + #endif long receiveK; /* Statistics: total k-bytes received */ u_short sendB; /* counters to count upto 1-k lots of bytes */ u_short receiveB; /* sent and received. */ diff -c -r -N irc2.8.21+CSr20/ircd/channel.c irc2.8.21+CSr24/ircd/channel.c *** irc2.8.21+CSr20/ircd/channel.c Sun Jan 21 17:52:59 1996 --- irc2.8.21+CSr24/ircd/channel.c Sat Jun 8 15:39:30 1996 *************** *** 877,882 **** --- 877,885 ---- fm = *curr; else if (MyClient(sptr) && (*curr != fm)) break; + if (!ischop) + sendto_one(sptr, err_str(ERR_CHANOPRIVSNEEDED), + me.name, parv[0], chptr->chname); if (whatt == MODE_ADD) { lp = &chops[opcnt++]; *************** *** 902,914 **** /* check now so we eat the parameter if present */ if (keychange) break; - *parv = check_string(*parv); { ! u_char *s; for (s = (u_char *)*parv; *s; s++) *s &= 0x7f; } if (MyClient(sptr) && opcnt >= MAXMODEPARAMS) break; if (!fm) --- 905,917 ---- /* check now so we eat the parameter if present */ if (keychange) break; { ! register u_char *s; for (s = (u_char *)*parv; *s; s++) *s &= 0x7f; } + *parv = check_string(*parv); if (MyClient(sptr) && opcnt >= MAXMODEPARAMS) break; if (!fm) *************** *** 969,974 **** --- 972,980 ---- break; if (MyClient(sptr) && opcnt >= MAXMODEPARAMS) break; + if (!ischop) + sendto_one(sptr, err_str(ERR_CHANOPRIVSNEEDED), + me.name, parv[0], chptr->chname); if (whatt == MODE_ADD) { lp = &chops[opcnt++]; *************** *** 990,995 **** --- 996,1004 ---- */ if (limitset || !ischop) { + if (!ischop) + sendto_one(sptr, err_str(ERR_CHANOPRIVSNEEDED), + me.name, parv[0], chptr->chname); if (whatt == MODE_ADD && --parc > 0) parv++; break; *************** *** 2398,2404 **** isnew = ChannelExists(parv[2]) ? 0 : 1; chptr = get_channel(sptr, parv[2], CREATE); oldts = chptr->channelts; ! doesop = (parv[4+args][0] == '@' || parv[4+args][1] == '@'); for (l = chptr->members; l && l->value.cptr; l = l->next) if (l->flags & MODE_CHANOP) --- 2407,2436 ---- isnew = ChannelExists(parv[2]) ? 0 : 1; chptr = get_channel(sptr, parv[2], CREATE); oldts = chptr->channelts; ! ! ! /* we only look if any ops are introduced if we'll actually need ! * to use the info ! */ ! if (!isnew && newts > 0 && oldts > 0 && newts != oldts) ! { ! static char nicks[BUFSIZE]; ! ! strcpy(nicks, parv[4+args]); ! for (s=strtoken(&p, nicks, " "); s; s=strtoken(&p, NULL, " ")) ! if (*s == '@' || s[1] == '@') ! { ! while (*s == '@' || *s == '+') ! s++; ! if (!(acptr = find_chasing(sptr, s, NULL))) ! continue; ! if (acptr->from != cptr) ! continue; ! doesop = 1; ! break; ! } ! } ! for (l = chptr->members; l && l->value.cptr; l = l->next) if (l->flags & MODE_CHANOP) *************** *** 2409,2418 **** --- 2441,2464 ---- oldmode = &chptr->mode; + /* Enables TS + if (newts == 0) + if (haveops || !doesop) + tstosend = oldts; + else + chptr->channelts = tstosend = 0; + else if (oldts == 0) + if (doesop || !haveops) + chptr->channelts = tstosend = newts; + else + tstosend = 0; + /* */ + /* Disables TS: */ if (isnew) chptr->channelts = tstosend = newts; else if (newts == 0 || oldts == 0) chptr->channelts = tstosend = 0; + /* */ else if (newts == oldts) tstosend = oldts; else if (newts < oldts) diff -c -r -N irc2.8.21+CSr20/ircd/clone.c irc2.8.21+CSr24/ircd/clone.c *** irc2.8.21+CSr20/ircd/clone.c Sat Jan 6 23:30:11 1996 --- irc2.8.21+CSr24/ircd/clone.c Sat Jun 8 15:39:34 1996 *************** *** 9,14 **** --- 9,82 ---- #include "comstud.h" + #ifdef IDLE_CHECK + + anIdle *make_idle() + { + Reg1 anIdle *ani = NULL; + Reg2 size = sizeof(anIdle); + + if (!(ani = (anIdle *)MyMalloc(size))) + outofmemory(); + bzero((char *)ani, (int)size); + *ani->hostname = (char) 0; + *ani->username = (char) 0; + ani->last = NOW; + ani->prev = NULL; + if (Idles) + Idles->prev = ani; + ani->next = Idles; + Idles = ani; + return ani; + } + + anIdle *find_idle(cptr) + aClient *cptr; + { + Reg1 anIdle *ani; + char *user = cptr->user->username; + + if (*user == '~') + user++; + for(ani=Idles;ani;ani=ani->next) + if (!mycmp(ani->username, user) && + !mycmp(ani->hostname, cptr->user->host)) + return ani; + return NULL; + } + + void remove_idle(cptr) + anIdle *cptr; + { + if (cptr->prev) + cptr->prev->next = cptr->next; + else + { + Idles = cptr->next; + if (Idles) + Idles->prev = NULL; + } + if (cptr->next) + cptr->next->prev = cptr->prev; + MyFree(cptr); + } + + void update_idles() + { + Reg1 anIdle *ani = Idles; + Reg2 anIdle *temp; + + while (ani != NULL) + { + temp = ani->next; + if (NOW > ani->last) + remove_idle(ani); + ani = temp; + } + } + + #endif /* IDLE_CHECK */ + #ifdef CLONE_CHECK /* ** Create Clone structure *************** *** 63,75 **** { Reg1 aClone *acl = Clones; Reg2 aClone *temp; - time_t old; - old = NOW; while (acl != NULL) { temp = acl->next; ! if ((old - acl->last) > CLONE_RESET) remove_clone(acl); acl = temp; } --- 131,141 ---- { Reg1 aClone *acl = Clones; Reg2 aClone *temp; while (acl != NULL) { temp = acl->next; ! if ((NOW - acl->last) > CLONE_RESET) remove_clone(acl); acl = temp; } diff -c -r -N irc2.8.21+CSr20/ircd/ircd.c irc2.8.21+CSr24/ircd/ircd.c *** irc2.8.21+CSr20/ircd/ircd.c Sat Jan 20 23:38:02 1996 --- irc2.8.21+CSr24/ircd/ircd.c Wed Jul 24 21:31:15 1996 *************** *** 37,42 **** --- 37,43 ---- #include "h.h" #include "dich_conf.h" + /* Lists to do K: line matching -Sol */ aConfList KList1 = { 0, NULL }; /* ordered */ aConfList KList2 = { 0, NULL }; /* ordered, reversed */ *************** *** 55,60 **** --- 56,66 ---- 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 */ int c_count = 0; /* All clients */ int ch_count = 0; /* All channels */ *************** *** 87,92 **** --- 93,107 ---- char clonekillhost[100]; #endif + #ifdef IDLE_CHECK + anIdle *Idles = NULL; + int idlelimit = DEFAULT_IDLELIMIT; + #endif + + #ifdef LIMIT_UH + int uhlimit = LIMIT_UH; + #endif + time_t NOW; aClient me; /* That's me */ aClient *client = &me; /* Pointer to beginning of Client list */ *************** *** 317,323 **** --- 332,350 ---- int ping = 0, i, rflag = 0, checkit = 0; time_t oldest = 0, timeout; static time_t lastcheck = 0; + #ifdef IDLE_CHECK + register int idleflag = 0, checkit2 = 0; + static time_t lastidlecheck = 0; + #endif + #ifdef IDLE_CHECK + if (currenttime-lastidlecheck > 120) + { + update_idles(); + lastidlecheck = currenttime; + checkit2 = 1; + } + #endif /* IDLE_CHECK */ if (rehashed || (currenttime-lastcheck > KLINE_CHECK)) { int ch_ct; *************** *** 372,377 **** --- 399,423 ---- (void)exit_client(cptr, cptr, &me, "Dead socket"); continue; } + #ifdef IDLE_CHECK + idleflag = (checkit2 && IsPerson(cptr)) ? (idlelimit && !IsAnOper(cptr) && + (currenttime-cptr->user->last > idlelimit) && + !find_eline(cptr)) : 0; + if (idleflag) + { + if (!find_idle(cptr)) + { + anIdle *crap; + char *temp = cptr->user->username; + + crap = make_idle(); + if (*temp == '~') + temp++; + strcpy(crap->username, temp); + strcpy(crap->hostname, cptr->user->host); + } + } + #endif killflag = (checkit && IsPerson(cptr)) ? find_kill(cptr) : 0; #ifdef R_LINES_OFTEN *************** *** 387,392 **** --- 433,441 ---- * is already indented enough so I think its justified. -avalon */ if (!killflag && !rflag && + #ifdef IDLE_CHECK + !idleflag && + #endif IsRegistered(cptr) && (ping >= currenttime - cptr->lasttime)) goto ping_timeout; *************** *** 397,402 **** --- 446,454 ---- * to be active, close this connection too. */ if (killflag || rflag || + #ifdef IDLE_CHECK + idleflag || + #endif ((currenttime - cptr->lasttime) >= (2 * ping) && (cptr->flags & FLAGS_PINGSENT)) || (!IsRegistered(cptr) && *************** *** 432,440 **** * on them - send a messgae to the user being killed * first. */ ! if (killflag && IsPerson(cptr)) sendto_ops("Kill line active for %s", get_client_name(cptr, FALSE)); #if defined(R_LINES) && defined(R_LINES_OFTEN) if (IsPerson(cptr) && rflag) sendto_ops("Restricting %s, closing link.", --- 484,497 ---- * on them - send a messgae to the user being killed * first. */ ! if (killflag) /* this is above: && IsPerson(cptr)) */ sendto_ops("Kill line active for %s", get_client_name(cptr, FALSE)); + #ifdef IDLE_CHECK + if (idleflag) + sendto_ops("Idle time limit exceeded for %s", + get_client_name(cptr, FALSE)); + #endif #if defined(R_LINES) && defined(R_LINES_OFTEN) if (IsPerson(cptr) && rflag) sendto_ops("Restricting %s, closing link.", *************** *** 443,448 **** --- 500,510 ---- if (killflag) (void)exit_client(cptr, cptr, &me, "K-Lined"); + #ifdef IDLE_CHECK + else if (idleflag) + (void)exit_client(cptr, cptr, &me, + "Idle time limit exceeded"); + #endif else (void)exit_client(cptr, cptr, &me, "Ping timeout"); i = 0; *************** *** 527,533 **** int portarg = 0; uid_t uid, euid; time_t delay = 0; ! #ifndef AIX struct rlimit r; #endif #ifdef DOG3 --- 589,595 ---- int portarg = 0; uid_t uid, euid; time_t delay = 0; ! #if !defined(AIX) && !defined(ULTRIX) struct rlimit r; #endif #ifdef DOG3 *************** *** 535,546 **** the main loop */ time_t nextfdlistcheck=0; /*end of priority code */ #endif - NOW = time(NULL); #ifdef DBUF_INIT dbuf_init(); /* set up some dbuf stuff to control paging */ #endif ! #ifndef AIX r.rlim_cur = MAXCONNECTIONS; r.rlim_max = MAXCONNECTIONS; setrlimit(RLIMIT_NOFILE, &r); --- 597,612 ---- the main loop */ time_t nextfdlistcheck=0; /*end of priority code */ #endif NOW = time(NULL); + #ifdef BETTER_MOTD + motd = NULL; + motd_tm = NULL; + read_motd(MOTD); + #endif #ifdef DBUF_INIT dbuf_init(); /* set up some dbuf stuff to control paging */ #endif ! #if !defined(AIX) && !defined(ULTRIX) r.rlim_cur = MAXCONNECTIONS; r.rlim_max = MAXCONNECTIONS; setrlimit(RLIMIT_NOFILE, &r); diff -c -r -N irc2.8.21+CSr20/ircd/list.c irc2.8.21+CSr24/ircd/list.c *** irc2.8.21+CSr20/ircd/list.c Sun Jan 21 16:04:16 1996 --- irc2.8.21+CSr24/ircd/list.c Sat Jun 8 15:39:30 1996 *************** *** 130,135 **** --- 130,137 ---- if (size == CLIENT_LOCAL_SIZE) { cptr->since = cptr->lasttime = cptr->firsttime = NOW; + cptr->lastnick = 0; + cptr->numnicks = 0; cptr->confs = NULL; cptr->sockhost[0] = '\0'; cptr->buffer[0] = '\0'; diff -c -r -N irc2.8.21+CSr20/ircd/s_auth.c irc2.8.21+CSr24/ircd/s_auth.c *** irc2.8.21+CSr20/ircd/s_auth.c Sun Jan 21 00:17:52 1996 --- irc2.8.21+CSr24/ircd/s_auth.c Wed Jul 24 22:29:12 1996 *************** *** 234,239 **** --- 234,240 ---- if (!locp || !remp || !*ruser) { + *cptr->username = '\0'; ircstp->is_abad++; return; } diff -c -r -N irc2.8.21+CSr20/ircd/s_bsd.c irc2.8.21+CSr24/ircd/s_bsd.c *** irc2.8.21+CSr20/ircd/s_bsd.c Sun Jan 21 11:10:51 1996 --- irc2.8.21+CSr24/ircd/s_bsd.c Wed Jul 24 20:25:14 1996 *************** *** 61,66 **** --- 61,72 ---- #include #include #include + + #ifdef USE_POLL + #include + #include + #endif /* USE_POLL_ */ + #ifdef AIX # include # include *************** *** 1374,1386 **** ** Do some tricky stuff for client connections to make sure they don't do ** any flooding >:-) -avalon */ ! static int read_packet(cptr, rfd) Reg1 aClient *cptr; ! fd_set *rfd; { Reg1 int dolen = 0, length = 0, done; ! if (FD_ISSET(cptr->fd, rfd) && !(IsPerson(cptr) && DBufLength(&cptr->recvQ) > 6090)) { errno = 0; --- 1380,1392 ---- ** Do some tricky stuff for client connections to make sure they don't do ** any flooding >:-) -avalon */ ! static int read_packet(cptr, msg_ready) Reg1 aClient *cptr; ! int msg_ready; { Reg1 int dolen = 0, length = 0, done; ! if (msg_ready && !(IsPerson(cptr) && DBufLength(&cptr->recvQ) > 6090)) { errno = 0; *************** *** 1489,1494 **** --- 1495,1502 ---- } + #ifndef USE_POLL + /* * Check all connections for new connections and input data that is to be * processed. Also check for connections with data queued and whether we can *************** *** 1762,1768 **** } length = 1; /* for fall through case */ if (!NoNewLine(cptr) || FD_ISSET(i, &read_set)) ! length = read_packet(cptr, &read_set); #ifndef DOG3 if (length > 0) flush_connections(i); --- 1770,1776 ---- } length = 1; /* for fall through case */ if (!NoNewLine(cptr) || FD_ISSET(i, &read_set)) ! length = read_packet(cptr, FD_ISSET(i, &read_set)); #ifndef DOG3 if (length > 0) flush_connections(i); *************** *** 1807,1812 **** --- 1815,2192 ---- } return 0; } + + #else /* USE_POLL */ + + #ifdef DOG3 + + int read_message(delay, listp) + time_t delay; /* Don't ever use ZERO here, unless you mean to poll and then + * you have to have sleep/wait somewhere else in the code.--msa + */ + fdlist *listp; + + #else + + int read_message(delay) + time_t delay; + + #endif + + { + /* + * eliminate the direct FD_ macros as they are select() specific + * and replace them with a higher level abstraction that also works for + * poll()... + */ + #define POLLREADFLAGS (POLLIN|POLLRDNORM) + #define POLLWRITEFLAGS (POLLOUT|POLLWRNORM) + #define SET_READ_EVENT( thisfd ){ CHECK_PFD( thisfd );\ + pfd->events |= POLLREADFLAGS;} + #define SET_WRITE_EVENT( thisfd ){ CHECK_PFD( thisfd );\ + pfd->events |= POLLWRITEFLAGS;} + #define CHECK_PFD( thisfd ) \ + if ( pfd->fd != thisfd ) { \ + pfd = &poll_fdarray[nbr_pfds++];\ + pfd->fd = thisfd; \ + pfd->events = 0; \ + } + + register aClient *cptr; + register int nfds; + struct timeval wait; + + #ifdef pyr + struct timeval nowt; + u_long us; + #endif + pollfd_t poll_fdarray[MAXCONNECTIONS]; + pollfd_t * pfd = poll_fdarray; + pollfd_t * res_pfd = NULL; + pollfd_t * udp_pfd = NULL; + aClient * authclnts[MAXCONNECTIONS]; /* mapping of auth fds to client */ + int nbr_pfds = 0; + time_t delay2 = delay; + u_long usec = 0; + int res, length, fd, i, fdnew; + int auth = 0; + #ifdef DOG3 + register int j; + + /* if it is called with NULL we check all active fd's */ + if (!listp) + { + listp = &default_fdlist; + listp->last_entry = highest_fd+1; /* remember the 0th entry isnt */ + } + + #endif + + #ifdef NPATH + note_delay(&delay); + #endif + #ifdef pyr + (void) gettimeofday(&nowt, NULL); + NOW = nowt.tv_sec; + #endif + + for (res = 0;;) + { + /* set up such that CHECK_FD works */ + nbr_pfds = 0; + pfd = poll_fdarray; + pfd->fd = -1; + auth = 0; + res_pfd = NULL; + udp_pfd = NULL; + + #ifndef DOG3 + for (i = highest_fd; i >= 0; i--) + #else + for (i=listp->entry[j=1];j<=listp->last_entry; + i=listp->entry[++j]) + #endif + { + if (!(cptr = local[i]) || IsLog(cptr)) + continue; + Debug((DEBUG_NOTICE, "fd %d cptr %#x %d %#x %s", + i, cptr, cptr->status, cptr->flags, + get_client_name(cptr,TRUE))); + if (DoingAuth(cptr)) + { + if ( auth == 0 ) + bzero( (char *)&authclnts, + sizeof(authclnts) ); + auth++; + Debug((DEBUG_NOTICE,"auth on %x %d", cptr, + i)); + SET_READ_EVENT(cptr->authfd); + if (cptr->flags & FLAGS_WRAUTH) + SET_WRITE_EVENT(cptr->authfd); + authclnts[cptr->authfd] = cptr; + } + if (DoingDNS(cptr) || DoingAuth(cptr)) + continue; + if (IsListening(cptr)) + { + if ((NOW > cptr->lasttime + 2)) { + SET_READ_EVENT( i ); + } + else if (delay2 > 2) + delay2 = 2; + } + else + { + if (DBufLength(&cptr->recvQ) && delay2 > 2) + delay2 = 1; + if (DBufLength(&cptr->recvQ) < 4088) + SET_READ_EVENT( i ); + } + + if (DBufLength(&cptr->sendQ) || IsConnecting(cptr)) + #ifndef pyr + SET_WRITE_EVENT( i ); + #else + { + if (!(cptr->flags & FLAGS_BLOCKED)) + SET_WRITE_EVENT( i ); + else + delay2 = 0, usec = 500000; + } + if (NOW - cptr->lw.tv_sec && + nowt.tv_usec - cptr->lw.tv_usec < 0) + us = 1000000; + else + us = 0; + us += nowt.tv_usec; + if (us - cptr->lw.tv_usec > 500000) + cptr->flags &= ~FLAGS_BLOCKED; + #endif + } + + if (udpfd >= 0) + { + SET_READ_EVENT(udpfd); + udp_pfd = pfd; + } + if (resfd >= 0) + { + SET_READ_EVENT(resfd); + res_pfd = pfd; + } + Debug((DEBUG_NOTICE, "udpfd %d resfd %d", + udpfd, resfd )); + + wait.tv_sec = MIN(delay2, delay); + wait.tv_usec = usec; + + /* do the wait */ + nfds = poll( poll_fdarray, nbr_pfds, + wait.tv_sec * 1000 + wait.tv_usec/1000); + + if (nfds == -1 && errno == EINTR) + return -1; + else if (nfds >= 0) + break; + report_error("poll %s:%s", &me); + res++; + if (res > 5) + restart("too many poll errors"); + sleep(10); + NOW = time(NULL); + } + + if (res_pfd && (res_pfd->revents & POLLREADFLAGS) ) + { + do_dns_async(); + nfds--; + res_pfd->revents &= ~POLLREADFLAGS; + } + if (udp_pfd && (udp_pfd->revents & POLLREADFLAGS) ) + { + polludp(); + nfds--; + udp_pfd->revents &= ~POLLREADFLAGS; + } + + /* + * loop through all the polled fds testing for whether any + * has an I/O ready + */ + for ( pfd = poll_fdarray, i = 0; + (nfds > 0) && (i < nbr_pfds); + i++, pfd++ ) { + + /* most tests (idle fds) should keep going here */ + if ( pfd->revents == 0 ) + continue; + + /* found something that completed */ + nfds--; + fd = pfd->fd; + + /* check for the auth completions - previously, this was it's + own loop through the fds */ + if (( auth > 0 ) && ( cptr = authclnts[fd]) && ( cptr->authfd == fd)) { + + /* auth I/O ready */ + auth--; + if (pfd->revents & POLLWRITEFLAGS) + send_authports(cptr); + else if (pfd->revents & POLLREADFLAGS) + read_authports(cptr); + continue; + } + + /* + * get the client pointer -- all the previous incarnations + * of this code embedded this test within the subsequent + * 'if' statements - put it here for reusability + */ + if ( !(cptr = local[fd])) + continue; + + /* + * accept connections + */ + if ((pfd->revents & POLLREADFLAGS) && IsListening(cptr)) + { + pfd->revents &= ~POLLREADFLAGS; + cptr->lasttime = NOW; + /* + ** There may be many reasons for error return, but + ** in otherwise correctly working environment the + ** probable cause is running out of file descriptors + ** (EMFILE, ENFILE or others?). The man pages for + ** accept don't seem to list these as possible, + ** although it's obvious that it may happen here. + ** Thus no specific errors are tested at this + ** point, just assume that connections cannot + ** be accepted until some old is closed first. + */ + if ((fdnew = accept(fd, NULL, NULL)) < 0) + { + report_error("Cannot accept connections %s:%s", + cptr); + continue; + } + ircstp->is_ac++; + if (fdnew >= MAXCLIENTS) + { + ircstp->is_ref++; + sendto_ops("All connections in use. (%s)", + get_client_name(cptr, TRUE)); + (void)send(fdnew, + "ERROR :All connections in use\r\n", + 32, 0); + (void)close(fdnew); + continue; + } + /* + * Use of add_connection (which never fails :) meLazy + */ + #ifdef UNIXPORT + if (IsUnixSocket(cptr)) + add_unixconnection(cptr, fdnew); + else + #endif + (void)add_connection(cptr, fdnew); + nextping = NOW; + continue; + } + + /* + * was the next loop - check for actual work to be done + */ + if (IsMe( cptr )) + continue; + if (pfd->revents & POLLWRITEFLAGS ) + { + int write_err = 0; + /* + ** ...room for writing, empty some queue then... + */ + if (IsConnecting(cptr)) + write_err = completed_connection(cptr); + if (!write_err) + (void)send_queued(cptr); + if (IsDead(cptr) || write_err) + { + deadsocket: + (void)exit_client(cptr, cptr, &me, + strerror(get_sockerr(cptr))); + continue; + } + } + length = 1; /* for fall through case */ + if ((!NoNewLine(cptr) || pfd->revents & POLLREADFLAGS) && + !(DoingAuth(cptr) && NOW - cptr->firsttime < 5)) + length = read_packet(cptr, ((pfd->revents & POLLREADFLAGS )!= 0)); + + readcalls++; + if (length == FLUSH_BUFFER) + continue; + else if (length > 0) + flush_connections(cptr->fd); + if (IsDead(cptr)) + goto deadsocket; + if (length > 0) + continue; + + /* Ghost! Unknown users are tagged in parse() since 2.9. + * Let's not drop the uplink but just the ghost's message. + */ + if (length == -3) + continue; + + /* + ** NB: This following section has been modofied to *expect* + ** cptr to be valid (ie if (length == FLUSH_BUFFER) is + ** above and stays there). - avalon 24/9/94 + */ + /* + ** ...hmm, with non-blocking sockets we might get + ** here from quite valid reasons, although.. why + ** would select report "data available" when there + ** wasn't... so, this must be an error anyway... --msa + ** actually, EOF occurs when read() returns 0 and + ** in due course, select() returns that fd as ready + ** for reading even though it ends up being an EOF. -avalon + */ + Debug((DEBUG_ERROR, "READ ERROR: fd = %d %d %d", + cptr->fd, errno, length)); + + if (IsServer(cptr) || IsHandshake(cptr)) + { + int timeconnected = NOW - cptr->firsttime; + + if (length == 0) + sendto_ops("Server %s closed the connection (%d, %2d:%02d:%02d)", + get_client_name(cptr, FALSE), + timeconnected / 86400, + (timeconnected % 86400) / 3600, + (timeconnected % 3600)/60, + timeconnected % 60); + else /* this must be for -1 */ + { + report_error("Lost connection to %s:%s",cptr); + sendto_ops("%s had been connected for %d, %2d:%02d:%02d", + get_client_name(cptr, FALSE), + timeconnected / 86400, + (timeconnected % 86400) / 3600, + (timeconnected % 3600)/60, + timeconnected % 60); + } + } + (void)exit_client(cptr, cptr, &me, length >= 0 ? + "EOF From client" : + strerror(get_sockerr(cptr))); + } + return 0; + } + + #endif /* USE_POLL */ + /* * connect_server diff -c -r -N irc2.8.21+CSr20/ircd/s_conf.c irc2.8.21+CSr24/ircd/s_conf.c *** irc2.8.21+CSr20/ircd/s_conf.c Sun Jan 21 00:02:14 1996 --- irc2.8.21+CSr24/ircd/s_conf.c Wed Jul 24 21:49:12 1996 *************** *** 623,630 **** --- 623,633 ---- for (cltmp = NextClass(FirstClass()); cltmp; cltmp = NextClass(cltmp)) MaxLinks(cltmp) = -1; + /* Let's don't do this...somewhere, the cache doesn't get cleared correctly. + At least on some OS's. - Comstud if (sig != 2) flush_cache(); + */ clear_conf_list(&KList1, 1); clear_conf_list(&KList2, 1); *************** *** 655,660 **** --- 658,670 ---- if (!tmp2->clients) free_conf(tmp2); } + #ifdef BETTER_MOTD + read_motd(MOTD); + #endif + #ifdef BUFFERED_LOGS + cs_buf_logs(1,"",0); + cs_buf_logs(2,"",0); + #endif rehashed = 1; return ret; } *************** *** 1223,1228 **** --- 1233,1269 ---- me.name, cptr->name, (BadPtr(tmp->passwd) || !is_comment(tmp->passwd)) ? "" : tmp->passwd); + + /* Oh, what the fuck...let's put the user@host limit check right here. + I'm not sure that I actually like this patch since you have to loop + through every client on every client-connect...but oh well... - CS + */ + + #ifdef LIMIT_UH + if (!tmp && uhlimit) + { + register aClient *sptr; + register int i; + int num = 0; + + for (i = highest_fd; i >= 0; i--) + { + if (!(sptr=local[i]) || !IsPerson(sptr)) + continue; + if (!strcmp(sptr->user->username, name) && + !strcmp(sptr->sockhost, host)) + if (++num >= uhlimit) + { + sendto_one(cptr, ":%s NOTICE %s :This server is currently limited to %i client%s per user", + me.name, cptr->name, uhlimit, uhlimit==1?"":"s"); + sendto_flagops(5, "Rejecting for too many clients: %s [%s@%s]", + cptr->name, cptr->user->username, cptr->user->host); + return 1; + } + } + } + #endif /* LIMIT_UH */ + return (tmp ? -1 : 0); } diff -c -r -N irc2.8.21+CSr20/ircd/s_debug.c irc2.8.21+CSr24/ircd/s_debug.c *** irc2.8.21+CSr20/ircd/s_debug.c Sun Jan 21 11:47:09 1996 --- irc2.8.21+CSr24/ircd/s_debug.c Wed Jul 24 20:29:07 1996 *************** *** 219,225 **** --- 219,227 ---- #ifdef GETRUSAGE_2 # ifdef SOL20 # include + /* # include + */ # endif # include #else diff -c -r -N irc2.8.21+CSr20/ircd/s_err.c irc2.8.21+CSr24/ircd/s_err.c *** irc2.8.21+CSr20/ircd/s_err.c Sat Jan 6 23:30:11 1996 --- irc2.8.21+CSr24/ircd/s_err.c Sat Jun 8 15:39:34 1996 *************** *** 78,84 **** /* 434 */ ERR_SERVICENAMEINUSE, (char *)NULL, /* 435 */ ERR_SERVICECONFUSED, (char *)NULL, /* 436 */ ERR_NICKCOLLISION, "%s :Nickname collision KILL", ! 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, ERR_USERNOTINCHANNEL, "%s %s :They aren't on that channel", ERR_NOTONCHANNEL, "%s :You're not on that channel", --- 78,89 ---- /* 434 */ ERR_SERVICENAMEINUSE, (char *)NULL, /* 435 */ ERR_SERVICECONFUSED, (char *)NULL, /* 436 */ ERR_NICKCOLLISION, "%s :Nickname collision KILL", ! #ifdef NO_NICK_FLOODS ! /* 437 */ ERR_TOOMANYNICKS, ":Sorry, too many nick changes", ! #else ! 0, (char *)NULL, ! #endif ! 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, ERR_USERNOTINCHANNEL, "%s %s :They aren't on that channel", ERR_NOTONCHANNEL, "%s :You're not on that channel", diff -c -r -N irc2.8.21+CSr20/ircd/s_misc.c irc2.8.21+CSr24/ircd/s_misc.c *** irc2.8.21+CSr20/ircd/s_misc.c Sat Jan 20 18:06:43 1996 --- irc2.8.21+CSr24/ircd/s_misc.c Sat Jun 8 15:39:29 1996 *************** *** 307,312 **** --- 307,362 ---- return namebuf; } + #ifdef BUFFERED_LOGS + + void cs_buf_logs(which, buf, len) + int which; + char *buf; + int len; + { + #define ULOGBUFFERLEN 4000 + #define CLOGBUFFERLEN 2000 + + static char userbuf[ULOGBUFFERLEN]; + static char clonebuf[CLOGBUFFERLEN]; + static int userbuflen = 0, clonebuflen = 0; + int doit=0; + char *filename, *buffer; + int fd, *len2; + + switch(which) + { + case 1: + if (userbuflen+len >= ULOGBUFFERLEN-1) + doit++; + filename = FNAME_USERLOG; + buffer = userbuf; + len2 = &userbuflen; + break; + case 2: + if (clonebuflen+len >= CLOGBUFFERLEN-1) + doit++; + filename = FNAME_CLONELOG; + buffer = clonebuf; + len2 = &clonebuflen; + break; + } + if (!len || doit) + { + if ((fd = open(filename, O_WRONLY|O_APPEND)) != -1) + { + (void)write(fd, buffer, *len2); + close(fd); + } + *buffer = (char) 0; + *len2 = 0; + } + strcat(buffer, buf); + *len2 = *len2 + len; + } + + #endif + /* ** exit_client ** This is old "m_bye". Name changed, because this is not a *************** *** 340,346 **** { Reg1 aClient *acptr; Reg2 aClient *next; ! #ifdef FNAME_USERLOG time_t on_for; #endif char comment1[HOSTLEN + HOSTLEN + 2]; --- 390,396 ---- { Reg1 aClient *acptr; Reg2 aClient *next; ! #if defined(FNAME_USERLOG) || (defined(SYSLOG) && defined(SYSLOG_USERS)) time_t on_for; #endif char comment1[HOSTLEN + HOSTLEN + 2]; *************** *** 364,372 **** sptr->name, sptr->user->username, sptr->user->host); #endif ! #ifdef FNAME_USERLOG on_for = NOW - sptr->firsttime; ! # if defined(USE_SYSLOG) && defined(SYSLOG_USERS) if (IsPerson(sptr)) syslog(LOG_NOTICE, "%s (%3d:%02d:%02d): %s!%s@%s\n", myctime(sptr->firsttime), --- 414,423 ---- sptr->name, sptr->user->username, sptr->user->host); #endif ! #if defined(FNAME_USERLOG) || (defined(SYSLOG) && defined(SYSLOG_USERS)) on_for = NOW - sptr->firsttime; ! #endif ! #if defined(USE_SYSLOG) && defined(SYSLOG_USERS) if (IsPerson(sptr)) syslog(LOG_NOTICE, "%s (%3d:%02d:%02d): %s!%s@%s\n", myctime(sptr->firsttime), *************** *** 374,410 **** on_for % 60, sptr->name, sptr->user->username, sptr->user->host); ! # else { ! char linebuf[160]; ! int logfile; ! /* ! * This conditional makes the logfile active only after ! * it's been created - thus logging can be turned off by ! * removing the file. ! * ! * stop NFS hangs...most systems should be able to open a ! * file in 3 seconds. -avalon (curtesy of wumpus) ! */ ! if (IsPerson(sptr) && ! (logfile = open(FNAME_USERLOG, O_WRONLY|O_APPEND)) != -1) ! { ! (void)irc_sprintf(linebuf, ! "%s (%3d:%02d:%02d): %s!%s@%s [%s]\n", myctime(sptr->firsttime), on_for / 3600, (on_for % 3600)/60, on_for % 60, ! sptr->name, ! sptr->user->username, sptr->user->host, ! sptr->username); (void)write(logfile, linebuf, strlen(linebuf)); (void)close(logfile); } ! /* Modification by stealth@caen.engin.umich.edu */ } ! # endif ! #endif if (sptr->fd >= 0) { if (cptr != NULL && sptr != cptr) --- 425,458 ---- on_for % 60, sptr->name, sptr->user->username, sptr->user->host); ! #endif ! #ifdef FNAME_USERLOG { ! char linebuf[160]; ! int logfile, len; ! if (IsPerson(sptr)) ! { ! len = irc_sprintf(linebuf, ! "%s (%3d:%02d:%02d): %s!%s@%s [%s]\n", myctime(sptr->firsttime), on_for / 3600, (on_for % 3600)/60, on_for % 60, ! sptr->name, sptr->user->username, ! sptr->user->host, sptr->username); ! #ifdef BUFFERED_LOGS ! cs_buf_logs(1, linebuf, len); ! #else ! if ((logfile = open(FNAME_USERLOG, ! O_WRONLY|O_APPEND)) != -1) ! { (void)write(logfile, linebuf, strlen(linebuf)); (void)close(logfile); } ! #endif /* BUFFERED_LOGS */ ! } } ! #endif /* FNAME_OPERLOG */ if (sptr->fd >= 0) { if (cptr != NULL && sptr != cptr) diff -c -r -N irc2.8.21+CSr20/ircd/s_serv.c irc2.8.21+CSr24/ircd/s_serv.c *** irc2.8.21+CSr20/ircd/s_serv.c Sun Jan 21 11:36:44 1996 --- irc2.8.21+CSr24/ircd/s_serv.c Wed Jul 24 23:38:36 1996 *************** *** 252,257 **** --- 252,343 ---- #endif /* DOG3 */ + #ifdef IDLE_CHECK + + int m_idle(cptr, sptr, parc, parv) + aClient *cptr, *sptr; + int parc; + char *parv[]; + { + int temp; + + if (!MyClient(sptr) || !IsAnOper(sptr)) + { + sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); + return 0; + } + if (!parv[1] || !*parv[1]) + { + sendto_one(sptr, ":%s NOTICE %s :The current idle limit is set at %i minutes", + me.name, parv[0], idlelimit/60); + return 0; + } + temp = atoi(parv[1]); + if (temp && (temp < 10)) + { + sendto_one(sptr, ":%s NOTICE %s :Hello??? Try a number > 10.", + me.name, parv[0]); + return 0; + } + idlelimit = temp*60; + sendto_ops("%s has changed the idle time limit to %i minute(s).", + parv[0], idlelimit/60); + sendto_one(sptr, ":%s NOTICE %s :The idle limit is now set to %i minute(s)", + me.name, parv[0], idlelimit/60); + return 0; + } + + #endif + + #ifdef LIMIT_UH + + int m_limituh(cptr, sptr, parc, parv) + aClient *cptr, *sptr; + int parc; + char *parv[]; + { + int temp; + + if (!MyClient(sptr) || !IsAnOper(sptr)) + { + sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); + return 0; + } + if (!parv[1] || !*parv[1]) + { + if (uhlimit) + sendto_one(sptr, ":%s NOTICE %s :The current limit for the number of same u@h's is %i", + me.name, parv[0], uhlimit); + else + sendto_one(sptr, ":%s NOTICE %s :There is currently no limit for the number of same u@h's", + me.name, parv[0]); + return 0; + } + temp = atoi(parv[1]); + if (temp < 0) + { + sendto_one(sptr, ":%s NOTICE %s :Hello??? Try a number >= 0.", + me.name, parv[0]); + return 0; + } + if (uhlimit = temp) + { + sendto_flagops(1,"%s has changed the u@h limit to %i.", + parv[0], uhlimit); + sendto_one(sptr, ":%s NOTICE %s :The u@h limit is now set to %i.", + me.name, parv[0], uhlimit); + } + else + { + sendto_flagops(1,"%s has disabled the u@h limit.", parv[0]); + sendto_one(sptr, ":%s NOTICE %s :The u@h limit is now disabled.", + me.name, parv[0]); + } + return 0; + } + + #endif + /* ** m_version ** parv[0] = sender prefix *************** *** 843,849 **** check_fdlists(); #endif nextping = NOW; ! sendto_ops("Link with %s established.", inpath); (void)add_to_client_hash_table(cptr->name, cptr); /* doesnt duplicate cptr->serv if allocted this struct already */ (void)make_server(cptr); --- 929,935 ---- check_fdlists(); #endif nextping = NOW; ! sendto_ops("Link with %s (%s) established.", inpath, DoesTS(cptr) ? "TS" : "NoTS"); (void)add_to_client_hash_table(cptr->name, cptr); /* doesnt duplicate cptr->serv if allocted this struct already */ (void)make_server(cptr); *************** *** 1287,1293 **** aClient *acptr; char stat = parc > 1 ? parv[1][0] : '\0'; Reg1 int i; ! int doall = 0, wilds = 0; char *name; if (check_registered(sptr)) --- 1373,1379 ---- aClient *acptr; char stat = parc > 1 ? parv[1][0] : '\0'; Reg1 int i; ! int doall = 0, wilds = 0, j; char *name; if (check_registered(sptr)) *************** *** 1315,1320 **** --- 1401,1427 ---- #endif switch (stat) { + case '?': + #ifndef DOG3 + for(i=0;i<=highest_fd;i++) + { + if (!(acptr=local[i]) || !IsServer(acptr)) + continue; + #else + for (i=serv_fdlist.entry[j=1];j<=serv_fdlist.last_entry; + i=serv_fdlist.entry[++j]) + if (!(acptr=local[i])) + continue; + { + #endif + sendto_one(sptr, ":%s NOTICE %s :%s %s %u :%u", + me.name, parv[0], + get_client_name(acptr, TRUE), + DoesTS(acptr) ? "TS" : "NoTS", + (int)DBufLength(&acptr->sendQ), + NOW - acptr->firsttime); + } + break; case 'L' : case 'l' : /* * send info about connections which match, or all if the *************** *** 2112,2117 **** --- 2219,2228 ---- syslog(LOG_WARNING, "Server RESTART by %s\n", get_client_name(sptr,FALSE)); #endif + #ifdef BUFFERED_LOGS + cs_buf_logs(1,"",0); + cs_buf_logs(2,"",0); + #endif server_reboot(); return 0; } *************** *** 2306,2311 **** --- 2417,2466 ---- return 0; } + #ifdef BETTER_MOTD + + void read_motd(filename) + char *filename; + { + register aMotd *temp, *last; + struct stat sb; + char buffer[81], *blah; + FILE *st; + + while(motd) + { + temp = motd->next; + MyFree(motd); + motd = temp; + } + st = fopen(filename, "rt"); + if (!st) + return; + fstat(fileno(st), &sb); + motd_tm = localtime(&sb.st_mtime); + last = NULL; + while(fgets(buffer, 80, st)) + { + if ((blah = strchr(buffer, '\n')) != NULL) + *blah = (char) 0; + if ((blah = strchr(buffer, '\r')) != NULL) + *blah = (char) 0; + temp = (aMotd *) MyMalloc(sizeof(aMotd)); + if (!temp) + outofmemory(); + strcpy(temp->line, buffer); + temp->next = NULL; + if (!motd) + motd = temp; + else + last->next = temp; + last = temp; + } + fclose(st); + } + + #endif + /* ** m_motd ** parv[0] = sender prefix *************** *** 2316,2336 **** int parc; char *parv[]; { int fd; char line[80]; Reg1 char *tmp; struct stat sb; struct tm *tm; if (check_registered(sptr)) return 0; if (hunt_server(cptr, sptr, ":%s MOTD :%s", 1,parc,parv)!=HUNTED_ISME) return 0; ! /* ! * stop NFS hangs...most systems should be able to open a file in ! * 3 seconds. -avalon (curtesy of wumpus) ! */ fd = open(MOTD, O_RDONLY); if (fd == -1) { --- 2471,2518 ---- int parc; char *parv[]; { + #ifdef BETTER_MOTD + register aMotd *temp; + struct tm *tm; + #else int fd; char line[80]; Reg1 char *tmp; struct stat sb; struct tm *tm; + #endif if (check_registered(sptr)) return 0; if (hunt_server(cptr, sptr, ":%s MOTD :%s", 1,parc,parv)!=HUNTED_ISME) return 0; ! ! #ifdef BETTER_MOTD ! tm = motd_tm; ! if (motd == NULL) ! { ! sendto_one(sptr, err_str(ERR_NOMOTD), me.name, parv[0]); ! 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 ! ! /* Here's old MOTD way of opening and reading on every client connect ! and /MOTD. Pretty dumb if you ask me... */ ! fd = open(MOTD, O_RDONLY); if (fd == -1) { *************** *** 2356,2361 **** --- 2538,2544 ---- sendto_one(sptr, rpl_str(RPL_ENDOFMOTD), me.name, parv[0]); (void)close(fd); return 0; + #endif } /* *************** *** 2376,2391 **** return 0; } for (i = highest_fd; i; i--) { if (!(acptr = local[i])) continue; if (!IsUnknown(acptr) && !IsConnecting(acptr) && !IsHandshake(acptr)) continue; sendto_one(sptr, rpl_str(RPL_CLOSING), me.name, parv[0], get_client_name(acptr, TRUE), acptr->status); ! (void)exit_client(acptr, acptr, acptr, "Oper Closing"); closed++; } sendto_one(sptr, rpl_str(RPL_CLOSEEND), me.name, parv[0], closed); --- 2559,2587 ---- return 0; } + if (parv[1] && *parv[1] && !matches(parv[1], "sdkjfkdsjf.aosidasdk.as02ks")) + return 0; for (i = highest_fd; i; i--) { if (!(acptr = local[i])) continue; if (!IsUnknown(acptr) && !IsConnecting(acptr) && !IsHandshake(acptr)) + { + if (parv[1] && *parv[1] && acptr->user) + { + if (IsAnOper(acptr) || + matches(parv[1], acptr->user->host)) + continue; + } + else + continue; + } + else if (parv[1] && *parv[1]) continue; sendto_one(sptr, rpl_str(RPL_CLOSING), me.name, parv[0], get_client_name(acptr, TRUE), acptr->status); ! (void)exit_client(acptr, acptr, acptr, "Closing connection"); closed++; } sendto_one(sptr, rpl_str(RPL_CLOSEEND), me.name, parv[0], closed); *************** *** 2428,2433 **** --- 2624,2633 ---- sendto_one(acptr, ":%s ERROR :Terminated by %s", me.name, get_client_name(sptr, TRUE)); } + #ifdef BUFFERED_LOGS + cs_buf_logs(1,"",0); + cs_buf_logs(2,"",0); + #endif (void)s_die(); return 0; } diff -c -r -N irc2.8.21+CSr20/ircd/s_user.c irc2.8.21+CSr24/ircd/s_user.c *** irc2.8.21+CSr20/ircd/s_user.c Sun Jan 21 15:20:55 1996 --- irc2.8.21+CSr24/ircd/s_user.c Wed Jul 24 22:16:19 1996 *************** *** 50,55 **** --- 50,59 ---- extern char clonekillhost[100]; #endif + #ifdef IDLE_CHECK + anIdle *blahidle; + #endif + static int user_modes[] = { FLAGS_OPER, 'o', FLAGS_LOCOP, 'O', FLAGS_INVISIBLE, 'i', *************** *** 384,389 **** --- 388,395 ---- anUser *user = sptr->user; int i; int reject = 0; + char *bottype = ""; + char origuser[USERLEN+1]; parv[0] = sptr->name; parv[1] = parv[2] = NULL; *************** *** 391,401 **** if (MyConnect(sptr)) { ! if (!strcmp(user->host, "null")) reject = 1; /* Vlad/Com/Joh */ else if (!strcmp(user->host, "1")) reject = 2; /* EggDrop */ - /* else if (!strcmp(user->host, ".")) reject = 3; /* Annoy/OJNK */ if (sptr->flags & FLAGS_GOTID) --- 397,409 ---- if (MyConnect(sptr)) { ! strncpyzt(origuser, username, USERLEN+1); ! if (strstr(sptr->info, "^GuArDiAn^")) ! reject = 4; /* Reject Guardian Bots */ ! else if (!strcmp(user->host, "null")) reject = 1; /* Vlad/Com/Joh */ else if (!strcmp(user->host, "1")) reject = 2; /* EggDrop */ else if (!strcmp(user->host, ".")) reject = 3; /* Annoy/OJNK */ if (sptr->flags & FLAGS_GOTID) *************** *** 423,433 **** aconf = sptr->confs->value.aconf; if ((sptr->flags & FLAGS_DOID) && !(sptr->flags & FLAGS_GOTID)) { - char temp[USERLEN+1]; - - strncpyzt(temp, username, USERLEN+1); *user->username = '~'; ! (void)strncpy(&user->username[1], temp, USERLEN); user->username[USERLEN] = '\0'; #ifdef IDENTD_ONLY ircstp->is_ref++; --- 431,438 ---- aconf = sptr->confs->value.aconf; if ((sptr->flags & FLAGS_DOID) && !(sptr->flags & FLAGS_GOTID)) { *user->username = '~'; ! (void)strncpy(&user->username[1], origuser, USERLEN); user->username[USERLEN] = '\0'; #ifdef IDENTD_ONLY ircstp->is_ref++; *************** *** 440,450 **** strncpyzt(user->username, sptr->username, USERLEN+1); else { - char temp[USERLEN+1]; - - strncpyzt(temp, username, USERLEN+1); *user->username = '~'; ! (void)strncpy(&user->username[1], temp, USERLEN); user->username[USERLEN] = '\0'; } if (!BadPtr(aconf->passwd) && --- 445,452 ---- strncpyzt(user->username, sptr->username, USERLEN+1); else { *user->username = '~'; ! (void)strncpy(&user->username[1], origuser, USERLEN); user->username[USERLEN] = '\0'; } if (!BadPtr(aconf->passwd) && *************** *** 472,477 **** --- 474,529 ---- if (oldstatus == STAT_MASTER && MyConnect(sptr)) (void)m_oper(&me, sptr, 1, parv); + #if defined(NO_MIXED_CASE) || defined(NO_SPECIAL) + { + register char *tmpstr, c; + register int lower, upper, special; + char *Myptr, *Myptr2; + + lower = upper = special = 0; + #ifdef IGNORE_FIRST_CHAR + tmpstr = (username[0] == '~' ? &username[2] : &username[1]); + #else + tmpstr = (username[0] == '~' ? &username[1] : username); + #endif + while(*tmpstr) + { + c = *(tmpstr++); + if (islower(c)) + lower++; + if (isupper(c)) + upper++; + if (!isalnum(c) && !strchr("-_.", c)) + special++; + } + #endif /* NO_MIXED_CASE || NO_SPECIAL */ + #ifdef NO_MIXED_CASE + if (lower && upper) + { + sendto_flagops(5, "Invalid username: %s [%s@%s]", + nick, username, user->host); + ircstp->is_ref++; + return exit_client(cptr, sptr, &me, "Invalid username"); + } + #endif /* NO_MIXED_CASE */ + #ifdef NO_SPECIAL + if (special) + { + sendto_flagops(5,"Invalid username: %s [%s@%s]", + nick, user->username, user->host); + ircstp->is_ref++; + return exit_client(cptr, sptr, &me, "Invalid username"); + } + #endif /* NO_SPECIAL */ + #if defined(NO_MIXED_CASE) || defined(NO_SPECIAL) + } + #endif + + #ifdef REJECT_BOTS + bottype = "Rejecting"; + #elif defined(BOTS_NOTICE) + bottype = "Possible"; + #endif #ifdef B_LINES if (!find_bline(cptr)) { *************** *** 479,523 **** #if defined(BOTS_NOTICE) || defined(REJECT_BOTS) if (reject == 1) { ! ircstp->is_ref++; ! #ifdef BOTS_NOTICE ! sendto_flagops(5,"Possible vlad/joh/com bot: %s [%s@%s]", ! nick, user->username, user->host); ! #endif #ifdef REJECT_BOTS return exit_client(cptr, sptr, &me, "No bots allowed"); #endif } if ((reject == 2) || strstr(nick, "LameHelp")) { ! ircstp->is_ref++; ! #ifdef BOTS_NOTICE ! sendto_flagops(5,"Possible eggdrop bot: %s [%s@%s]", nick, user->username, user->host); - #endif #ifdef REJECT_BOTS return exit_client(cptr, sptr, &me, "No bots allowed"); #endif } if (reject == 3) { ! ircstp->is_ref++; ! #ifdef BOTS_NOTICE ! sendto_flagops(5,"Possible ojnk/annoy bot: %s [%s@%s]", nick, user->username, user->host); #endif #ifdef REJECT_BOTS return exit_client(cptr, sptr, &me, "No bots allowed"); #endif } if (!matches("*bot*", nick)||!matches("*Serv*", nick)|| !matches("*help*", nick)) { ! ircstp->is_ref++; ! sendto_flagops(5,"Possible bot: %s [%s@%s]", nick, user->username, user->host); } #endif /* REJECT_BOTS || BOTS_NOTICE */ #ifdef CLONE_CHECK update_clones(); if ((clone = find_clone(user->host)) == NULL) --- 531,603 ---- #if defined(BOTS_NOTICE) || defined(REJECT_BOTS) if (reject == 1) { ! sendto_flagops(5,"%s vlad/joh/com bot: %s [%s@%s]", ! bottype, nick, user->username, ! user->host); #ifdef REJECT_BOTS + ircstp->is_ref++; return exit_client(cptr, sptr, &me, "No bots allowed"); #endif } if ((reject == 2) || strstr(nick, "LameHelp")) { ! sendto_flagops(5,"%s eggdrop bot: %s [%s@%s]", ! bottype, nick, user->username, user->host); #ifdef REJECT_BOTS + ircstp->is_ref++; return exit_client(cptr, sptr, &me, "No bots allowed"); #endif } if (reject == 3) { ! sendto_flagops(5,"%s ojnk/annoy bot: %s [%s@%s]", ! bottype, nick, user->username, user->host); + #ifdef REJECT_BOTS + ircstp->is_ref++; + return exit_client(cptr, sptr, &me, "No bots allowed"); #endif + } + if (reject == 4) + { + sendto_flagops(5,"%s Guardian bot: %s [%s@%s]", + bottype, + nick, user->username, user->host); #ifdef REJECT_BOTS + ircstp->is_ref++; return exit_client(cptr, sptr, &me, "No bots allowed"); #endif } if (!matches("*bot*", nick)||!matches("*Serv*", nick)|| !matches("*help*", nick)) { ! sendto_flagops(5,"%s bot: %s [%s@%s]", ! bottype, nick, user->username, user->host); + #ifdef REJECT_BOTS + ircstp->is_ref++; + return exit_client(cptr, sptr, &me, "No bots allowed"); + #endif } #endif /* REJECT_BOTS || BOTS_NOTICE */ + + #ifdef IDLE_CHECK + if ((blahidle=find_idle(cptr)) != NULL) + { + if (NOW <= (blahidle->last+60)) + { + blahidle->last += 60; /* Add 60 seconds */ + sendto_flagops(1,"Rejecting idle exceeder %s [%s@%s]", + nick, user->username, user->host); + ircstp->is_ref++; + return exit_client(cptr, sptr, &me, "No bots allowed"); + } + else + remove_idle(blahidle); + } + #endif + #ifdef CLONE_CHECK update_clones(); if ((clone = find_clone(user->host)) == NULL) *************** *** 534,553 **** sendto_flagops(1, "CloneBot protection activated against %s", user->host); if (clone->num >= NUM_CLONES) { - int logfile; #ifdef FNAME_CLONELOG ! if ((logfile = open(FNAME_CLONELOG, O_WRONLY|O_APPEND)) != -1) ! { ! (void)irc_sprintf(buf, ! "%s: Clonebot rejected: %s!%s@%s\n", ! myctime(NOW), parv[0], ! sptr->user->username, ! sptr->user->host); ! (void)write(logfile, buf, strlen(buf)); ! (void)close(logfile); ! } ! #endif sendto_flagops(1, "Rejecting clonebot: %s [%s@%s]", nick, username, user->host); #ifdef KILL_CLONES --- 614,637 ---- sendto_flagops(1, "CloneBot protection activated against %s", user->host); if (clone->num >= NUM_CLONES) { #ifdef FNAME_CLONELOG ! int logfile; ! int len; ! ! len = irc_sprintf(buf, "%s: Clonebot rejected: %s!%s@%s\n", ! myctime(NOW), parv[0], sptr->user->username, ! sptr->user->host); ! #ifdef BUFFERED_LOGS ! cs_buf_logs(2, buf, len); ! #else ! if ((logfile = open(FNAME_CLONELOG, O_WRONLY|O_APPEND)) != -1) ! { ! (void)write(logfile, buf, strlen(buf)); ! (void)close(logfile); ! } ! #endif /* BUFFERED_LOGS */ ! #endif /* FNAME_CLONELOG */ sendto_flagops(1, "Rejecting clonebot: %s [%s@%s]", nick, username, user->host); #ifdef KILL_CLONES *************** *** 562,624 **** #ifdef B_LINES } /* end of check for ip# */ #endif - #if defined(NO_MIXED_CASE) || defined(NO_SPECIAL) - { - register char *tmpstr, c; - register int lower, upper, special; - char *Myptr, *Myptr2; - lower = upper = special = 0; - #ifdef IGNORE_FIRST_CHAR - tmpstr = (username[0] == '~' ? &username[2] : &username[1]); - #else - tmpstr = (username[0] == '~' ? &username[1] : username); - #endif - while(*tmpstr) - { - c = *(tmpstr++); - if (islower(c)) - lower++; - if (isupper(c)) - upper++; - if (!isalnum(c) && !strchr("-_.", c)) - special++; - } - #endif /* NO_MIXED_CASE || NO_SPECIAL */ - #ifdef NO_MIXED_CASE - if (lower && upper) - { - sendto_flagops(5, "Invalid username: %s [%s@%s]", - nick, username, user->host); - ircstp->is_ref++; - return exit_client(cptr, sptr, &me, "Invalid username"); - } - #endif /* NO_MIXED_CASE */ - #ifdef NO_SPECIAL - if (special) - { - sendto_flagops(5,"Invalid username: %s [%s@%s]", - nick, user->username, user->host); - ircstp->is_ref++; - return exit_client(cptr, sptr, &me, "Invalid username"); - } - #endif /* NO_SPECIAL */ - #if defined(NO_MIXED_CASE) || defined(NO_SPECIAL) - } - #endif - #ifdef REJECT_IPHONE - if (!matches("* vc:*", sptr->info)) - { - ircstp->is_ref++; - sendto_flagops(5, "Rejecting IPhone user: [%s!%s@%s]", - nick, user->username, user->host); - return exit_client(cptr, sptr, &me, "No IPhone users"); - } - #endif /* REJECT_IPHONE */ #ifdef CLIENT_NOTICES sendto_flagops(2,"Client connecting: %s [%s@%s]", nick, user->username, user->host); #endif /* CLIENT_NOTICES */ } else strncpyzt(user->username, username, USERLEN+1); --- 646,659 ---- #ifdef B_LINES } /* end of check for ip# */ #endif #ifdef CLIENT_NOTICES sendto_flagops(2,"Client connecting: %s [%s@%s]", nick, user->username, user->host); #endif /* CLIENT_NOTICES */ + if (sptr->flags & FLAGS_GOTID) + if (strcmp(origuser, sptr->username)) + sendto_flagops(1,"Identd response differs: %s [%s]", nick, origuser); } else strncpyzt(user->username, username, USERLEN+1); *************** *** 714,719 **** --- 749,755 ---- char nick[NICKLEN+2], *s; ts_val newts = 0; int doests, sameuser = 0; + int fromts; if (parc < 2) { *************** *** 727,736 **** --- 763,800 ---- newts = atol(parv[3]); doests = (IsServer(cptr) && DoesTS(cptr)); + fromts = (parc > 6); if (MyConnect(sptr) && (s = (char *)index(parv[1], '~'))) *s = '\0'; strncpyzt(nick, parv[1], NICKLEN+1); + + #ifdef NO_NICK_FLOODS + if (MyClient(sptr) && IsRegistered(sptr)) + { + /* "lastnick" will actually be the first time a person did a /nick + if "lastnick" is 0 (has never /nick'd) or if "lastnick" is more + than 15 seconds ago, then "lastnick" will be reset to NOW + Basically, when someone hits 4 nick changes in 15 seconds, boom. + */ + + if (!sptr->lastnick || (NOW-sptr->lastnick > 15)) + { + sptr->numnicks = 0; + sptr->lastnick = NOW; + } + sptr->numnicks++; + if (sptr->numnicks > 3) + { + sptr->lastnick = NOW+15; /* Hurt the person */ + sendto_flagops(1,"Nick flooding detected by: %s [%s@%s]", + sptr->name, sptr->user->username, sptr->user->host); + sendto_one(sptr, err_str(ERR_TOOMANYNICKS), + me.name, sptr->name); + return 0; + } + } + #endif /* * if do_nick_name() returns a null name OR if the server sent a nick * name and do_nick_name() changed it in some way (due to rules of nick *************** *** 886,894 **** ** A new NICK being introduced by a neighbouring ** server (e.g. message type "NICK new" received) */ ! sameuser = (parc > 6) && mycmp(acptr->user->username, parv[5]) == 0 && mycmp(acptr->user->host, parv[6]) == 0; if (!doests || !newts || !acptr->tsinfo || (newts == acptr->tsinfo)) { --- 950,961 ---- ** A new NICK being introduced by a neighbouring ** server (e.g. message type "NICK new" received) */ ! if (acptr->user) ! sameuser = fromts && mycmp(acptr->user->username, parv[5]) == 0 && mycmp(acptr->user->host, parv[6]) == 0; + else + newts = 0; if (!doests || !newts || !acptr->tsinfo || (newts == acptr->tsinfo)) { *************** *** 944,951 **** ** must be killed from the incoming connection, and "old" must ** be purged from all outgoing connections. */ ! sameuser = mycmp(acptr->user->username, sptr->user->username) == 0 && mycmp(acptr->user->host, acptr->user->host) == 0; if (!doests || !newts || !acptr->tsinfo || (newts == acptr->tsinfo)) { sendto_flagops(4,"Nick change collision from %s to %s(%s <- %s)(both killed)", --- 1011,1021 ---- ** must be killed from the incoming connection, and "old" must ** be purged from all outgoing connections. */ ! if (acptr->user) ! sameuser = mycmp(acptr->user->username, sptr->user->username) == 0 && mycmp(acptr->user->host, acptr->user->host) == 0; + else + newts = 0; if (!doests || !newts || !acptr->tsinfo || (newts == acptr->tsinfo)) { sendto_flagops(4,"Nick change collision from %s to %s(%s <- %s)(both killed)", *************** *** 1759,1764 **** --- 1829,1840 ---- sptr->flags |= FLAGS_INVISIBLE; i_count++; m_invis++; + #else + if (atoi(host) & FLAGS_INVISIBLE) + { + m_invis++; + i_count++; + } #endif sptr->flags |= (UFLAGS & atoi(host)); strncpyzt(user->host, host, sizeof(user->host)); *************** *** 2270,2283 **** #ifdef FNAME_OPERLOG { int logfile; ! /* * This conditional makes the logfile active only after * it's been created - thus logging can be turned off by * removing the file. - * - * stop NFS hangs...most systems should be able to open a - * file in 3 seconds. -avalon (curtesy of wumpus) */ if (IsPerson(sptr) && (logfile = open(FNAME_OPERLOG, O_WRONLY|O_APPEND)) != -1) --- 2346,2356 ---- #ifdef FNAME_OPERLOG { int logfile; ! /* * This conditional makes the logfile active only after * it's been created - thus logging can be turned off by * removing the file. */ if (IsPerson(sptr) && (logfile = open(FNAME_OPERLOG, O_WRONLY|O_APPEND)) != -1) *************** *** 2287,2298 **** parv[0], sptr->user->username, sptr->sockhost); (void)write(logfile, buf, strlen(buf)); - (void)close(logfile); } - /* Modification by pjg */ } ! #endif #ifdef USE_SERVICES check_services_butone(SERVICE_WANT_OPER, sptr, ":%s MODE %s :+o", parv[0], parv[0]); --- 2360,2369 ---- parv[0], sptr->user->username, sptr->sockhost); (void)write(logfile, buf, strlen(buf)); (void)close(logfile); } } ! #endif /* FNAME_OPERLOG */ #ifdef USE_SERVICES check_services_butone(SERVICE_WANT_OPER, sptr, ":%s MODE %s :+o", parv[0], parv[0]);