diff -c -r irc2.8.21+CSr20/README.CS irc2.8.21+CSr22/README.CS *** irc2.8.21+CSr20/README.CS Sun Jan 21 11:51:06 1996 --- irc2.8.21+CSr22/README.CS Sat Apr 27 21:41:40 1996 *************** *** 1,6 **** --- 1,34 ---- 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 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: 1) Removed an #ifdef from dbuf.c which causes some problems on some OS's diff -c -r irc2.8.21+CSr20/include/comstud.h irc2.8.21+CSr22/include/comstud.h *** irc2.8.21+CSr20/include/comstud.h Sun Jan 21 00:06:02 1996 --- irc2.8.21+CSr22/include/comstud.h Sat Apr 27 21:58:46 1996 *************** *** 1,6 **** --- 1,26 ---- #ifndef COMSTUD_H #define COMSTUD_H + + /* 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 */ --- 88,94 ---- if they aren't running identd */ ! #undef IDENTD_ONLY /* QUOTE_KLINE - define this if you want /QUOTE KLINE */ *************** *** 165,170 **** --- 185,191 ---- 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 --- 220,226 ---- want them logged */ ! #define FNAME_FAILED_OPER "/home/irc/irc2.8.21+CSr22/lib/logs/failed.log" /* CLIENT_NOTICES - define this if you wish to see client connecting and exiting notices via /umode +c *************** *** 248,253 **** --- 269,289 ---- #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 */ --- 310,326 ---- and you wish to log clones */ ! #define FNAME_CLONELOG "/home/irc/irc2.8.21+CSr22/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 irc2.8.21+CSr20/include/config.h irc2.8.21+CSr22/include/config.h *** irc2.8.21+CSr20/include/config.h Sun Jan 21 01:51:18 1996 --- irc2.8.21+CSr22/include/config.h Sat Apr 27 20:45:32 1996 *************** *** 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 */ --- 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+CSr22/lib" /* dir where all ircd stuff is */ ! #define SPATH "/home/irc/irc2.8.21+CSr22/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 * --- 123,130 ---- * successful use of /oper. These are either full paths or files within DPATH. */ ! #define FNAME_USERLOG "/home/irc/irc2.8.21+CSr22/logs/users.log" /* */ ! #define FNAME_OPERLOG "/home/irc/irc2.8.21+CSr22/logs/opers.log" /* */ /* CHROOTDIR * diff -c -r irc2.8.21+CSr20/include/h.h irc2.8.21+CSr22/include/h.h *** irc2.8.21+CSr20/include/h.h Sat Jan 20 23:33:15 1996 --- irc2.8.21+CSr22/include/h.h Sat Apr 27 16:28:15 1996 *************** *** 30,38 **** 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" --- 30,45 ---- 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 **** --- 76,87 ---- 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 irc2.8.21+CSr20/include/msg.h irc2.8.21+CSr22/include/msg.h *** irc2.8.21+CSr20/include/msg.h Sat Jan 6 23:30:08 1996 --- irc2.8.21+CSr22/include/msg.h Fri Apr 5 20:22:34 1996 *************** *** 87,92 **** --- 87,95 ---- #ifdef QUOTE_KLINE #define MSG_KLINE "KLINE" /* KLINE */ #endif + #ifdef IDLE_CHECK + #define MSG_IDLE "IDLE" /* IDLE */ + #endif #define MAXPARA 15 #ifdef DOG3 *************** *** 96,101 **** --- 99,107 ---- #ifdef QUOTE_KLINE extern int m_kline(); #endif + #ifdef IDLE_CHECK + extern int m_idle(); + #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 **** --- 188,196 ---- #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 #if defined(NPATH) && !defined(CLIENT_COMPILE) { MSG_NOTE, m_note, 0, 1, 1 ,0L }, diff -c -r irc2.8.21+CSr20/include/numeric.h irc2.8.21+CSr22/include/numeric.h *** irc2.8.21+CSr20/include/numeric.h Sat Jan 6 23:30:08 1996 --- irc2.8.21+CSr22/include/numeric.h Fri Apr 5 20:22:34 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 irc2.8.21+CSr20/include/patchlevel.h irc2.8.21+CSr22/include/patchlevel.h *** irc2.8.21+CSr20/include/patchlevel.h Mon Jan 8 20:33:43 1996 --- irc2.8.21+CSr22/include/patchlevel.h Fri Apr 5 20:24:03 1996 *************** *** 17,21 **** */ #ifndef PATCHLEVEL ! #define PATCHLEVEL "2.8.21+CSr20" #endif --- 17,21 ---- */ #ifndef PATCHLEVEL ! #define PATCHLEVEL "2.8.21+CSr22" #endif diff -c -r irc2.8.21+CSr20/include/struct.h irc2.8.21+CSr22/include/struct.h *** irc2.8.21+CSr20/include/struct.h Sat Jan 6 23:30:08 1996 --- irc2.8.21+CSr22/include/struct.h Sat Apr 27 15:49:56 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 irc2.8.21+CSr20/ircd/channel.c irc2.8.21+CSr22/ircd/channel.c *** irc2.8.21+CSr20/ircd/channel.c Sun Jan 21 17:52:59 1996 --- irc2.8.21+CSr22/ircd/channel.c Sat Apr 27 21:28:36 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 irc2.8.21+CSr20/ircd/clone.c irc2.8.21+CSr22/ircd/clone.c *** irc2.8.21+CSr20/ircd/clone.c Sat Jan 6 23:30:11 1996 --- irc2.8.21+CSr22/ircd/clone.c Fri Apr 5 20:22:36 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 irc2.8.21+CSr20/ircd/ircd.c irc2.8.21+CSr22/ircd/ircd.c *** irc2.8.21+CSr20/ircd/ircd.c Sat Jan 20 23:38:02 1996 --- irc2.8.21+CSr22/ircd/ircd.c Sat Apr 27 17:39:31 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,103 ---- char clonekillhost[100]; #endif + #ifdef IDLE_CHECK + anIdle *Idles = NULL; + int idlelimit = DEFAULT_IDLELIMIT; + #endif + time_t NOW; aClient me; /* That's me */ aClient *client = &me; /* Pointer to beginning of Client list */ *************** *** 317,323 **** --- 328,346 ---- 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 **** --- 395,419 ---- (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 **** --- 429,437 ---- * 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 **** --- 442,450 ---- * 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.", --- 480,493 ---- * 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 **** --- 496,506 ---- 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 --- 585,591 ---- 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); --- 593,604 ---- the main loop */ time_t nextfdlistcheck=0; /*end of priority code */ #endif NOW = time(NULL); + read_motd(MOTD); #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 irc2.8.21+CSr20/ircd/list.c irc2.8.21+CSr22/ircd/list.c *** irc2.8.21+CSr20/ircd/list.c Sun Jan 21 16:04:16 1996 --- irc2.8.21+CSr22/ircd/list.c Fri Apr 5 20:22:35 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 irc2.8.21+CSr20/ircd/s_auth.c irc2.8.21+CSr22/ircd/s_auth.c *** irc2.8.21+CSr20/ircd/s_auth.c Sun Jan 21 00:17:52 1996 --- irc2.8.21+CSr22/ircd/s_auth.c Fri Apr 5 20:22:35 1996 *************** *** 234,239 **** --- 234,240 ---- if (!locp || !remp || !*ruser) { + *cptr->username = '\0'; ircstp->is_abad++; return; } diff -c -r irc2.8.21+CSr20/ircd/s_conf.c irc2.8.21+CSr22/ircd/s_conf.c *** irc2.8.21+CSr20/ircd/s_conf.c Sun Jan 21 00:02:14 1996 --- irc2.8.21+CSr22/ircd/s_conf.c Sat Apr 27 20:49:39 1996 *************** *** 655,660 **** --- 655,667 ---- 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; } diff -c -r irc2.8.21+CSr20/ircd/s_err.c irc2.8.21+CSr22/ircd/s_err.c *** irc2.8.21+CSr20/ircd/s_err.c Sat Jan 6 23:30:11 1996 --- irc2.8.21+CSr22/ircd/s_err.c Fri Apr 5 20:22:36 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 irc2.8.21+CSr20/ircd/s_misc.c irc2.8.21+CSr22/ircd/s_misc.c *** irc2.8.21+CSr20/ircd/s_misc.c Sat Jan 20 18:06:43 1996 --- irc2.8.21+CSr22/ircd/s_misc.c Sat Apr 27 21:09:26 1996 *************** *** 307,312 **** --- 307,361 ---- 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]; + int userbuflen = 0, clonebuflen = 0, 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]; --- 389,395 ---- { 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), --- 413,422 ---- 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) --- 424,457 ---- 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 irc2.8.21+CSr20/ircd/s_serv.c irc2.8.21+CSr22/ircd/s_serv.c *** irc2.8.21+CSr20/ircd/s_serv.c Sun Jan 21 11:36:44 1996 --- irc2.8.21+CSr22/ircd/s_serv.c Sat Apr 27 22:56:21 1996 *************** *** 51,72 **** #ifdef HIGHEST_CONNECTION int max_connection_count = 1, max_client_count = 1; #endif #ifdef HIGHEST_CONNECTION void check_max_count() { ! if (m_clients > max_client_count) ! max_client_count = m_clients; ! if ((m_clients + m_servers) > max_connection_count) ! { ! max_connection_count = m_clients + m_servers; ! if (max_connection_count % 10 == 0) ! sendto_flagops(1, ! "New highest connections: %d (%d clients)", ! max_connection_count, max_client_count); ! } } #endif /* HIGHEST_CONNECTION */ --- 51,76 ---- #ifdef HIGHEST_CONNECTION int max_connection_count = 1, max_client_count = 1; + time_t max_connection_time = 0; #endif #ifdef HIGHEST_CONNECTION void check_max_count() { ! if (!max_connection_time) ! max_connection_time = NOW; ! if (m_clients > max_client_count) ! max_client_count = m_clients; ! if ((m_clients + m_servers) > max_connection_count) ! { ! max_connection_count = m_clients + m_servers; ! max_connection_time = NOW; ! if (max_connection_count % 10 == 0) ! sendto_flagops(1, ! "New highest connections: %d (%d clients)", ! max_connection_count, max_client_count); ! } } #endif /* HIGHEST_CONNECTION */ *************** *** 252,257 **** --- 256,298 ---- #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 + /* ** m_version ** parv[0] = sender prefix *************** *** 1289,1294 **** --- 1330,1336 ---- Reg1 int i; int doall = 0, wilds = 0; char *name; + char *ptr; if (check_registered(sptr)) return 0; *************** *** 1406,1413 **** --- 1448,1458 ---- sendto_one(sptr, rpl_str(RPL_STATSUPTIME), me.name, parv[0], now/86400, (now/3600)%24, (now/60)%60, now%60); #ifdef HIGHEST_CONNECTION + ptr = ctime(&max_connection_time); sendto_one(sptr, rpl_str(RPL_STATSCONN), me.name, parv[0], max_connection_count, max_client_count); + sendto_one(sptr, ":%s %d %s :Highest connection reached at %s", + me.name, RPL_MOTD, parv[0], ptr); #endif break; } *************** *** 1543,1548 **** --- 1588,1594 ---- char *parv[]; { aClient *acptr; + char *ptr; if (check_registered_user(sptr)) return 0; *************** *** 1590,1597 **** --- 1636,1648 ---- sendto_one(sptr, rpl_str(RPL_LUSERME), me.name, parv[0], m_cs, m_ss); #ifdef HIGHEST_CONNECTION + ptr = ctime(&max_connection_time); + if (strchr(ptr, '\n')) + *strchr(ptr, '\n') = (char) 0; sendto_one(sptr, rpl_str(RPL_STATSCONN), me.name, parv[0], max_connection_count, max_client_count); + sendto_one(sptr, ":%s %d %s :Highest connection reached at %s", + me.name, RPL_MOTD, parv[0], ptr); #endif return 0; } *************** *** 2112,2117 **** --- 2163,2172 ---- 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 **** --- 2361,2411 ---- 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(!feof(st)) + { + 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) { --- 2416,2462 ---- 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); ! 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 **** --- 2482,2488 ---- 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); --- 2503,2531 ---- 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 **** --- 2568,2577 ---- 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 irc2.8.21+CSr20/ircd/s_user.c irc2.8.21+CSr22/ircd/s_user.c *** irc2.8.21+CSr20/ircd/s_user.c Sun Jan 21 15:20:55 1996 --- irc2.8.21+CSr22/ircd/s_user.c Sat Apr 27 20:41:09 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,394 ---- anUser *user = sptr->user; int i; int reject = 0; + char *bottype = ""; 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) --- 396,407 ---- if (MyConnect(sptr)) { ! 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) *************** *** 472,477 **** --- 478,533 ---- 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) --- 535,607 ---- #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 --- 618,641 ---- 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,620 **** #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); --- 650,656 ---- *************** *** 714,719 **** --- 750,756 ---- char nick[NICKLEN+2], *s; ts_val newts = 0; int doests, sameuser = 0; + int fromts; if (parc < 2) { *************** *** 727,736 **** --- 764,792 ---- 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)) + { + if (!sptr->lastnick || (NOW-sptr->lastnick > 60)) + sptr->numnicks = 0; + sptr->lastnick = NOW; + sptr->numnicks++; + if (sptr->numnicks > 3) + { + 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)) { --- 942,953 ---- ** 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)", --- 1003,1013 ---- ** 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 **** --- 1821,1832 ---- 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) --- 2338,2348 ---- #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]); --- 2352,2361 ---- 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]);