diff -c -r irc2.8.21+CSr25/Makefile irc2.8.21+CSr27/Makefile *** irc2.8.21+CSr25/Makefile Sun Sep 15 16:18:25 1996 --- irc2.8.21+CSr27/Makefile Thu Oct 17 16:08:44 1996 *************** *** 19,41 **** CC=gcc RM=/bin/rm - # # Default flags: - INCLUDEDIR=../include CFLAGS= -I$(INCLUDEDIR) -O2 -fexpensive-optimizations -funroll-loops -fomit-frame-pointer - IRCDLIBS= - # - # Solaris 2 flags: - #IRCDLIBS=-L/usr/lib -lsocket -lnsl -lresolv - - # Others: - #O2 #IRCDLIBS=-L/usr/lib -L/usr/gnu/lib -lgnuc -O2 #IRCLIBS=-lcurses -ltermcap # # use the following on MIPS: #CFLAGS= -systype bsd43 -DSYSTYPE_BSD43 -I$(INCLUDEDIR) --- 19,40 ---- CC=gcc RM=/bin/rm + INCLUDEDIR=../include + #-I/usr/include + #-I/usr/gnu/include # Default flags: CFLAGS= -I$(INCLUDEDIR) -O2 -fexpensive-optimizations -funroll-loops -fomit-frame-pointer #O2 #IRCDLIBS=-L/usr/lib -L/usr/gnu/lib -lgnuc -O2 #IRCLIBS=-lcurses -ltermcap + # Solaris 2 + IRCDLIBS=-L/usr/lib -lsocket -lnsl -lresolv + + + # # use the following on MIPS: #CFLAGS= -systype bsd43 -DSYSTYPE_BSD43 -I$(INCLUDEDIR) *************** *** 89,95 **** # # WARNING: if you are making ircd SUID or SGID, check config.h to make sure # you are not defining CMDLINE_CONFIG ! IRCDMODE = 711 # IRCDDIR must be the same as DPATH in include/config.h # --- 88,94 ---- # # WARNING: if you are making ircd SUID or SGID, check config.h to make sure # you are not defining CMDLINE_CONFIG ! IRCDMODE = 771 # IRCDDIR must be the same as DPATH in include/config.h # diff -c -r irc2.8.21+CSr25/README.CS irc2.8.21+CSr27/README.CS *** irc2.8.21+CSr25/README.CS Sun Sep 15 16:01:11 1996 --- irc2.8.21+CSr27/README.CS Mon Nov 11 20:11:04 1996 *************** *** 1,6 **** --- ! This is the README for irc2.8.21+CSr25. Basically, this is just a list of changes...more information can be found in include/comstud.h. Any questions or comments can be directed to cbehrens@concentric.net --- 1,6 ---- --- ! This is the README for irc2.8.21+CSr27. Basically, this is just a list of changes...more information can be found in include/comstud.h. Any questions or comments can be directed to cbehrens@concentric.net *************** *** 12,17 **** --- 12,116 ---- NOTE: Please change values in comstud.h and dog3.h to your liking... The default values are probably less than ideal for you! + New in CSr27: + + Still being developed... + + 1) There are noticable differences in I: lines now. + There are 4 special characters that you can stick in front + of a hostname or ip# that do special things. + These characers are: + - This will never put a ~ for a user not running identd + + This will force people matching this I: to require identd + ! This means to only allow 1 connection per ip# in this I: + # This means to allow a client to connect even if they don't + have identd. (This is only useful if your server is compiled + for IDENTD_ONLY) + Examples: + a) I:x::!*@*ppp*::class will only allow X connections per ip# for people + who have *ppp* in their hostname where X is given in the Y: line. + (See below in CSr25 about Y: lines). + If there is no ! and you have a limit in your Y: line, then it matches + full user@host instead of just host. + + b) I:x::-*@*.cris.com::class will never show a ~, even though they may + not be running identd. (This is equivilent to the old way of not + specifying a @ in the I: line). + + 2) Rewrote parts of read_message() for the select() loop. There used to + be 3 loops, which have now been condensed to 1. + 3) Rewrote poll() usage in read_message() so that poll() will finally work + on Solaris and you can get > 1024 fds w/o using 99% CPU! + 4) Added extra charaters to deny in usernames for NO_SPECIAL. Also fixed + the fact that it wasn't checking identd replies, too. + 5) Rewrote parts of check_pings() to try and make it more optimized.. + 6) #define RESTRICT_STATSK -- + This restricts users from getting the full listing + of /stats K which they really don't need. If the user is on another + server, /stats k will just tell them if they are banned or + not. If they are, it shows them the bans. If the user is on your + server, they may: /stats k * and it'll tell them + if that nick or user@host is banned. And yes, opers can still get + the full stats k output. Maybe this is bad, maybe not, but I did it. + So, opers can /stats k, or they can /stats k * + 7) #define PASS_KLINES -- + Hrm, well, this will pass /quote kline's to our downlinks/uplinks. + This is not very useful right now, as it sends to ALL servers connected + to you. Note that all servers cept +CS servers (currently) will + ignore it. See #8: + 8) #define ALLOW_KLINES_FROM_SERVERS -- + Define this if you wish to parse the klines that are sent from #7. + Note, you have to select which servers to accept from. See #9: + 9) #define ALLOWED_KLINES -- + Define this to the servers you wish to allow klines from. Ie, + #define ALLOWED_KLINES "*.cris.com *.netcom.com" + This only allows k-lines to be accepted from those servers! + 10) Changed some values in config.h dealing with auto-reconnecting + to servers. Servers are trying to reconnect too quickly and + are causing a lot of problems. It's good to wait about 30 seconds + before trying to reconnect. + 11) Added a /quote HTM which tries to tell you our current rate of + in coming data...not sure if it's totally accurate, but it's + interesting.. + 12) Added /quote ADDKLINES for those using dated klines files... + It allows you to /quote addklines 961017 + 13) Eliminated mass messaging by disallowing more than 10 nicknames + for PRIVMSG nick1,nick2,...nick10. It notices /oper's if a person + tries more than 20, which means he's probably trying to abuse. + Some people are going to be pissed, because it breaks their + chanop-wall scripts, but screw them. Privmsg nick1,nick2 should be + disallowed to happen at the same time (without penalty anyway). + (Maybe it should just lag the users really bad?) + 14) Added a lot of typecasting to s_bsd.c, which at least eliminates + all compiler warnings on Solaris, which should be okay for other + OS's (?) + 15) Fixed the problem of rehashing with a new P: line on Solaris. + You can now add ports as you wish without a problem. + 16) Fixed the accept: Protocol error on Solaris. Solaris's accept() + returns EPROTO when a connection dies before or as it's accept()'d. + 17) Fixed some other getsockopt() errors that would happen occasionally... + (at least on Solaris) + 18) Added more stats to /stats ? (to be more like Taner's) + 19) Added RPL_ENDOFTRACE to be like /digi and +th + 20) Added more informative messages to the user for Invalid username + rejections and bot rejections. + 21) Fixed a problem with early releases of CSr25 where it was trying to + kill people who were already killed (m_kill). Don't ask =) + 22) Now canonizing blah,blah,blah in /topic, /list and, /whowas. + 23) Upped the NICKNAMEHISTORYLENGTH size in config.h to 15000. This uses + around 3 megs of RAM. If you don't have that to spare, lower this. + Currently, there is usually around 10000 out of 15000 used. + 24) When a KILL line takes effect, kick the user off with the reason, + instead of just "K-lined". + 25) Cleaned up a lot of the code that figures out the MAX_BUFFER size + for reads and writes. + 26) Upped listen(, 5) to listen(, 1024) + 27) Fixed a place where fds weren't being removed from the fdlists when + a client was exiting. + 28) Removed the source ports for clients from /stats L + + CSr26 wasn't released. + New in CSr25: 1) Fixed a bug in a patch that DWildstar gave me in CSr21. *************** *** 36,63 **** notices to it. 7) Created a new usermode +l, and moved UH_LIMIT reject notices there 8) Got rid of the +r usermode, which is in 2.9 servers. - 9) USERHOST and ISON do not "lag" users now, so NOTIFY, won't penalize you. - 10) A couple things dealing with K-lines. K-lines now by default are - put in a separate file. This file is set by KPATH in config.h - #define PUT_KLINES_IN_IRCD_CONF if you don't wish to use a separate - file for klines. Purpose of keeping klines in a separate file is for - easier management of your klines. Another #define for klines is - SEPARATE_QUOTE_KLINES_BY_DATE. This #define will put your quote klines - in a file something like klines.conf-960915 if KPATH is defined to be - "klines.conf". When you /rehash or start ircd, these dated files are - NOT loaded. You will have to manually move them into klines.conf. - The purpose of this is to decide at the end of the day which quote klines - you would like to keep, etc. - 11) #define NO_REDUNDANT_KLINES if you want your /quote kline to reject - any klines that are already in your .conf. This patch came from - teletype. I didn't use his code to remove old redundant ones that - are already in your .conf, but will come up with something in the - future. - 12) Fixed dependancies in the Makefiles for comstud.h, etc. - 13) Fixed NO_NICK_FLOODS so that if a user is trying to switch to a nickname - that already exists, it won't penalize him/her. - New in CSr24: 1) BUFFERED_LOGS were not logging at all...this is fixed. --- 135,141 ---- Common subdirectories: irc2.8.21+CSr25/common and irc2.8.21+CSr27/common Common subdirectories: irc2.8.21+CSr25/doc and irc2.8.21+CSr27/doc Common subdirectories: irc2.8.21+CSr25/include and irc2.8.21+CSr27/include Common subdirectories: irc2.8.21+CSr25/ircd and irc2.8.21+CSr27/ircd diff -c -r irc2.8.21+CSr25/common/parse.c irc2.8.21+CSr27/common/parse.c *** irc2.8.21+CSr25/common/parse.c Mon Sep 9 16:08:11 1996 --- irc2.8.21+CSr27/common/parse.c Tue Sep 17 21:42:58 1996 *************** *** 239,244 **** --- 239,251 ---- for (ch = buffer; *ch == ' '; ch++) ; para[0] = from->name; + #ifdef MAJORLOGGING + add_command(buffer); + numcommands++; + if (numcommands > 100000) + free_and_write_commands(); + + #endif if (*ch == ':') { /* diff -c -r irc2.8.21+CSr25/common/send.c irc2.8.21+CSr27/common/send.c *** irc2.8.21+CSr25/common/send.c Mon Sep 9 15:15:40 1996 --- irc2.8.21+CSr27/common/send.c Mon Nov 11 17:22:44 1996 *************** *** 97,102 **** --- 97,103 ---- ** client and try to send it. if we cant send it, it goes into the sendQ ** -avalon */ + void flush_connections(fd) int fd; { *************** *** 103,115 **** #ifdef SENDQ_ALWAYS Reg1 int i; Reg2 aClient *cptr; if (fd == me.fd) ! { for (i = highest_fd; i >= 0; i--) if ((cptr = local[i]) && DBufLength(&cptr->sendQ) > 0) (void)send_queued(cptr); ! } else if (fd >= 0 && (cptr = local[fd]) && DBufLength(&cptr->sendQ) > 0) (void)send_queued(cptr); #endif --- 104,156 ---- #ifdef SENDQ_ALWAYS Reg1 int i; Reg2 aClient *cptr; + int length = 1; if (fd == me.fd) ! { for (i = highest_fd; i >= 0; i--) + { if ((cptr = local[i]) && DBufLength(&cptr->sendQ) > 0) (void)send_queued(cptr); ! if (!cptr) ! continue; ! length = 1; ! if (!NoNewLine(cptr)) ! length = read_packet(cptr, 0); ! if (length == FLUSH_BUFFER) ! continue; ! if (IsDead(cptr)) ! { ! (void)exit_client(cptr, cptr, &me, ! strerror(get_sockerr(cptr))); ! continue; ! } ! if (length > 0) ! continue; ! if (IsServer(cptr) || IsHandshake(cptr)) ! { ! int connected = NOW - cptr->firsttime; ! ! if (length == 0) ! sendto_ops("Server %s closed the connection", ! get_client_name(cptr,FALSE)); ! else ! report_error("Lost connection to %s:%s", ! cptr); ! ! sendto_ops("%s had been connected for %d day%s, %2d:%02d:%02d", ! cptr->name, ! connected/86400, ! (connected/86400 == 1) ? "" : "s", ! (connected % 86400) / 3600, ! (connected % 3600) / 60, ! connected % 60); ! } ! (void)exit_client(cptr, cptr, &me, length >= 0 ? ! "EOF From client" : ! strerror(get_sockerr(cptr))); ! } ! } else if (fd >= 0 && (cptr = local[fd]) && DBufLength(&cptr->sendQ) > 0) (void)send_queued(cptr); #endif diff -c -r irc2.8.21+CSr25/common/support.c irc2.8.21+CSr27/common/support.c *** irc2.8.21+CSr25/common/support.c Thu Jul 25 19:37:24 1996 --- irc2.8.21+CSr27/common/support.c Mon Nov 11 18:29:01 1996 *************** *** 31,36 **** --- 31,46 ---- extern void outofmemory(); #endif + char *mystrdup(s) + char *s; + { + char *t; + + if ((t = (char *) MyMalloc(strlen(s) + 1)) == NULL) + return NULL; + return (char *) strcpy(t, s); + } + #ifdef NEED_STRTOKEN /* ** strtoken.c -- walk through a string of tokens, using a set Common subdirectories: irc2.8.21+CSr25/doc/Europe and irc2.8.21+CSr27/doc/Europe Common subdirectories: irc2.8.21+CSr25/doc/US-Admin and irc2.8.21+CSr27/doc/US-Admin Common subdirectories: irc2.8.21+CSr25/doc/history and irc2.8.21+CSr27/doc/history diff -c -r irc2.8.21+CSr25/include/comstud.h irc2.8.21+CSr27/include/comstud.h *** irc2.8.21+CSr25/include/comstud.h Sun Sep 15 16:02:01 1996 --- irc2.8.21+CSr27/include/comstud.h Mon Nov 11 20:32:40 1996 *************** *** 1,6 **** --- 1,43 ---- #ifndef COMSTUD_H #define COMSTUD_H + /* RESTRICT_STATSK + - Define this if you want to restrict /stats k so + that it will only show if a certain spec is banned. + Ie, /stats k will tell you if you are banned or not. + /stats k tells you if that + person is banned. + */ + + #define RESTRICT_STATSK + + /* PASS_KLINES + - This will pass klines to up/downlinks for them + to deal with as they want.. + */ + + #undef PASS_KLINES + + /* ALLOW_KLINES_FROM_SERVERS + - Define this if you want to accept K-lines from + other servers. Use #define ALLOWED_KLINES to + pick which servers you want to accept them from + */ + + #define ALLOW_KLINES_FROM_SERVERS + + /* ALLOWED_KLINES + - This defines which servers you want to accept + klines from. For example: + #define ALLOWED_KLINES "*.netcom.com *.cerf.net" + If you get a KLINE from those servers, it'll + put them in. + Note: This is only if ALLOW_KLINES_FROM_SERVERS is + #defined. + */ + + #define ALLOWED_KLINES "*.cris.com" + /* NO_REDUNDANT_KLINES - This will check the kline that you try and put in via /quote kline and will not allow it if it matches *************** *** 39,45 **** kline.conf. */ ! #define SEPARATE_QUOTE_KLINES_BY_DATE /* LIMIT_UH - Use this if you want to use the connect frequency field in the Y: lines to limit that class to a --- 76,82 ---- kline.conf. */ ! #undef SEPARATE_QUOTE_KLINES_BY_DATE /* LIMIT_UH - Use this if you want to use the connect frequency field in the Y: lines to limit that class to a *************** *** 272,278 **** want them logged */ ! #define FNAME_FAILED_OPER "/home/irc/irc2.8.21+CSr25/lib/logs/failed.log" /* CLIENT_NOTICES - define this if you wish to see client connecting and exiting notices via /umode +c --- 309,315 ---- want them logged */ ! #define FNAME_FAILED_OPER "/home/irc2.8.21+CSr27/lib/logs/failed.log" /* CLIENT_NOTICES - define this if you wish to see client connecting and exiting notices via /umode +c *************** *** 362,368 **** and you wish to log clones */ ! #define FNAME_CLONELOG "/home/irc/irc2.8.21+CSr25/logs/clones.log" /* DEFAULT_IDLELIMIT - if you have CHECK_IDLE defined above, this value is the default # a client --- 399,405 ---- and you wish to log clones */ ! #define FNAME_CLONELOG "/home/irc/irc2.8.21+CSr27/lib/logs/clones.log" /* DEFAULT_IDLELIMIT - if you have CHECK_IDLE defined above, this value is the default # a client diff -c -r irc2.8.21+CSr25/include/config.h irc2.8.21+CSr27/include/config.h *** irc2.8.21+CSr25/include/config.h Sun Sep 15 16:19:36 1996 --- irc2.8.21+CSr27/include/config.h Mon Nov 11 20:13:12 1996 *************** *** 41,47 **** /* SGI Nothing needed (IRIX 4.0.4) */ #undef SVR3 /* SVR3 stuff - being worked on where poss. */ #undef DYNIXPTX /* Sequents Brain-dead Posix implement. */ ! #undef SOL20 /* Solaris2 */ #undef ESIX /* ESIX */ #undef NEXT /* NeXTStep */ #undef SVR4 --- 41,47 ---- /* SGI Nothing needed (IRIX 4.0.4) */ #undef SVR3 /* SVR3 stuff - being worked on where poss. */ #undef DYNIXPTX /* Sequents Brain-dead Posix implement. */ ! #define SOL20 /* Solaris2 */ #undef ESIX /* ESIX */ #undef NEXT /* NeXTStep */ #undef SVR4 *************** *** 55,64 **** #ifdef SOL20 ! /* POLL seems to be broken/using 99% CPU, so this is disabled until ! I can take a look at it */ ! ! #undef USE_POLL /* Define this if you want to use poll() on lame Solaris */ #endif --- 55,61 ---- #ifdef SOL20 ! #define USE_POLL /* Define this if you want to use poll() on lame Solaris */ #endif *************** *** 118,125 **** * 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+CSr25/lib" /* dir where all ircd stuff is */ ! #define SPATH "/home/irc/irc2.8.21+CSr25/lib/ircd" #define CPATH "ircd.conf" /* server configuration file */ #define KPATH "klines/klines.conf" /* config file containing K: lines */ #define MPATH "ircd.motd" /* server MOTD file */ --- 115,122 ---- * 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+CSr27" /* dir where all ircd stuff is */ ! #define SPATH "/home/irc/irc2.8.21+CSr27/lib/ircd" #define CPATH "ircd.conf" /* server configuration file */ #define KPATH "klines/klines.conf" /* config file containing K: lines */ #define MPATH "ircd.motd" /* server MOTD file */ *************** *** 416,422 **** * 1 server = 1 connection, 1 user = 1 connection. * This should be at *least* 3: 1 listen port, 1 dns port + 1 client */ ! #define MAXCONNECTIONS 1024 /* * this defines the length of the nickname history. each time a user changes --- 413,419 ---- * 1 server = 1 connection, 1 user = 1 connection. * This should be at *least* 3: 1 listen port, 1 dns port + 1 client */ ! #define MAXCONNECTIONS 3000 /* * this defines the length of the nickname history. each time a user changes *************** *** 432,438 **** * resident and running - it hardly ever gets swapped to disk! You can * ignore these recommendations- they only are meant to serve as a guide */ ! #define NICKNAMEHISTORYLENGTH 300 /* * Time interval to wait and if no messages have been received, then check for --- 429,435 ---- * resident and running - it hardly ever gets swapped to disk! You can * ignore these recommendations- they only are meant to serve as a guide */ ! #define NICKNAMEHISTORYLENGTH 15000 /* * Time interval to wait and if no messages have been received, then check for *************** *** 463,470 **** * (HANGONRETRYDELAY). This latter has to be long enough that the * other end of the connection has time to notice it broke too. */ ! #define HANGONRETRYDELAY 10 /* Recommended value: 10 seconds */ ! #define HANGONGOODLINK 300 /* Recommended value: 5 minutes */ /* * Number of seconds to wait for write to complete if stuck. --- 460,467 ---- * (HANGONRETRYDELAY). This latter has to be long enough that the * other end of the connection has time to notice it broke too. */ ! #define HANGONRETRYDELAY 20 /* Recommended value: 20 seconds */ ! #define HANGONGOODLINK 1800 /* Recommended value: 30 minutes */ /* * Number of seconds to wait for write to complete if stuck. diff -c -r irc2.8.21+CSr25/include/dog3.h irc2.8.21+CSr27/include/dog3.h *** irc2.8.21+CSr25/include/dog3.h Thu Jul 25 19:37:23 1996 --- irc2.8.21+CSr27/include/dog3.h Wed Sep 18 15:51:25 1996 *************** *** 7,13 **** #define DEFAULT_LOADCFREQ 5 #define DEFAULT_LOADRECV 110 ! #define FDLISTCHKFREQ 2 #endif --- 7,13 ---- #define DEFAULT_LOADCFREQ 5 #define DEFAULT_LOADRECV 110 ! #define FDLISTCHKFREQ 3 #endif diff -c -r irc2.8.21+CSr25/include/h.h irc2.8.21+CSr27/include/h.h *** irc2.8.21+CSr25/include/h.h Sun Sep 15 15:53:20 1996 --- irc2.8.21+CSr27/include/h.h Mon Nov 11 20:16:48 1996 *************** *** 37,45 **** extern struct tm *motd_tm; #endif ! #ifdef NO_REDUNDANT_KLINES extern int test_kline_userhost PROTO((aClient *, aConfList *, char *, char *)); - #endif extern int idlelimit; extern int s_count, c_count, ch_count, u_count, i_count; --- 37,44 ---- extern struct tm *motd_tm; #endif ! extern int test_kline_userhost PROTO((aClient *, aConfList *, char *, char *)); extern int idlelimit; extern int s_count, c_count, ch_count, u_count, i_count; *************** *** 68,77 **** #ifdef DOG3 #include "fdlist.h" extern fdlist serv_fdlist; extern fdlist busycli_fdlist; /* high-priority clients */ extern fdlist default_fdlist; /* just the number of the entry */ - extern fdlist auth_fdlist; extern int lifesux; extern int dog3loadcfreq; extern int dog3loadrecv; --- 67,77 ---- #ifdef DOG3 #include "fdlist.h" + + extern float currentrate; extern fdlist serv_fdlist; extern fdlist busycli_fdlist; /* high-priority clients */ extern fdlist default_fdlist; /* just the number of the entry */ extern int lifesux; extern int dog3loadcfreq; extern int dog3loadrecv; *************** *** 97,102 **** --- 97,104 ---- extern struct stats *ircstp; extern int bootopt; + extern char *canonize PROTO((char *, int *)); + extern int read_packet PROTO((aClient *, int)); extern aChannel *find_channel PROTO((char *, aChannel *)); extern void remove_user_from_channel PROTO((aClient *, aChannel *)); extern void del_invite PROTO((aClient *, aChannel *)); *************** *** 129,135 **** extern aConfItem *find_conf_host PROTO((Link *, char *, int)); extern aConfItem *find_conf_ip PROTO((Link *, char *, char *, int)); extern aConfItem *find_conf_name PROTO((char *, int)); ! extern int find_kill PROTO((aClient *, int)); extern int find_restrict PROTO((aClient *)); extern int rehash PROTO((aClient *, aClient *, int)); extern int initconf PROTO((int, char *)); --- 131,137 ---- extern aConfItem *find_conf_host PROTO((Link *, char *, int)); extern aConfItem *find_conf_ip PROTO((Link *, char *, char *, int)); extern aConfItem *find_conf_name PROTO((char *, int)); ! extern int find_kill PROTO((aClient *, int, char **)); extern int find_restrict PROTO((aClient *)); extern int rehash PROTO((aClient *, aClient *, int)); extern int initconf PROTO((int, char *)); diff -c -r irc2.8.21+CSr25/include/msg.h irc2.8.21+CSr27/include/msg.h *** irc2.8.21+CSr25/include/msg.h Fri Aug 30 18:57:36 1996 --- irc2.8.21+CSr27/include/msg.h Tue Nov 5 20:06:42 1996 *************** *** 68,73 **** --- 68,74 ---- #ifdef DOG3 #define MSG_DOG3LOAD "DOG3LOAD" /* DOG3LOAD */ #define MSG_DOG3FREQ "DOG3FREQ" /* DOG3FREQ */ + #define MSG_HTM "HTM" /* HTM */ #endif #define MSG_NOTE "NOTE" /* NOTE */ #define MSG_SQUERY "SQUERY" /* SQUE */ *************** *** 84,92 **** --- 85,99 ---- #define MSG_DIE "DIE" #define MSG_HASH "HSAH" /* HASH */ #define MSG_DNS "DNS" /* DNS -> DNSS */ + #ifdef SEPARATE_QUOTE_KLINES_BY_DATE + #define MSG_REHASHADD "REHASHADD" /* REHASHADD */ + #endif #ifdef QUOTE_KLINE #define MSG_KLINE "KLINE" /* KLINE */ #endif + #ifdef SEPARATE_QUOTE_KLINES_BY_DATE + #define MSG_ADDKLINES "ADDKLINES" /* ADDKLINES */ + #endif #ifdef IDLE_CHECK #define MSG_IDLE "IDLE" /* IDLE */ #endif *************** *** 95,100 **** --- 102,108 ---- #ifdef DOG3 extern int m_dog3load(); extern int m_dog3freq(); + extern int m_htm(); #endif #ifdef QUOTE_KLINE extern int m_kline(); *************** *** 120,127 **** --- 128,139 ---- #ifdef TSDEBUG extern int m_ts(); #endif + #ifdef SEPARATE_QUOTE_KLINES_BY_DATE + extern int m_addklines(); + #endif #if defined(OPER_REHASH) || defined(LOCOP_REHASH) extern int m_rehash(); + extern int m_rehashadd(); #endif #if defined(OPER_RESTART) || defined(LOCOP_RESTART) extern int m_restart(); *************** *** 185,190 **** --- 197,203 ---- #ifdef DOG3 { MSG_DOG3LOAD, m_dog3load, 0, MAXPARA, 1 ,0L }, { MSG_DOG3FREQ, m_dog3freq, 0, MAXPARA, 1 ,0L }, + { MSG_HTM, m_htm, 0, MAXPARA, 1 ,0L }, #endif #ifdef QUOTE_KLINE { MSG_KLINE, m_kline, 0, MAXPARA, 1 ,0L }, *************** *** 206,212 **** --- 219,231 ---- { MSG_DNS, m_dns, 0, MAXPARA, 1 ,0L }, #if defined(OPER_REHASH) || defined(LOCOP_REHASH) { MSG_REHASH, m_rehash, 0, MAXPARA, 1 ,0L }, + #ifdef SEPARATE_QUOTE_KLINES_BY_DATE + { MSG_REHASHADD, m_rehashadd, 0, MAXPARA,1,0L}, #endif + #endif + #ifdef SEPARATE_QUOTE_KLINES_BY_DATE + { MSG_ADDKLINES, m_addklines, 0, MAXPARA, 1, 0L }, + #endif #if defined(OPER_RESTART) || defined(LOCOP_RESTART) { MSG_RESTART, m_restart, 0, MAXPARA, 1 ,0L }, #endif diff -c -r irc2.8.21+CSr25/include/numeric.h irc2.8.21+CSr27/include/numeric.h *** irc2.8.21+CSr25/include/numeric.h Thu Jul 25 19:37:22 1996 --- irc2.8.21+CSr27/include/numeric.h Tue Sep 17 14:06:42 1996 *************** *** 326,328 **** --- 326,330 ---- #define RPL_ADMINEMAIL 259 #define RPL_TRACELOG 261 + #define RPL_ENDOFTRACE 262 + diff -c -r irc2.8.21+CSr25/include/patchlevel.h irc2.8.21+CSr27/include/patchlevel.h *** irc2.8.21+CSr25/include/patchlevel.h Mon Sep 9 17:08:01 1996 --- irc2.8.21+CSr27/include/patchlevel.h Mon Nov 11 22:03:43 1996 *************** *** 17,21 **** */ #ifndef PATCHLEVEL ! #define PATCHLEVEL "2.8.21+CSr25" #endif --- 17,21 ---- */ #ifndef PATCHLEVEL ! #define PATCHLEVEL "2.8.21+CSr27" #endif diff -c -r irc2.8.21+CSr25/include/setup.h.bak irc2.8.21+CSr27/include/setup.h.bak *** irc2.8.21+CSr25/include/setup.h.bak Mon Sep 9 20:38:20 1996 --- irc2.8.21+CSr27/include/setup.h.bak Wed Sep 25 02:07:42 1996 *************** *** 7,27 **** #define STDLIBH #define STDDEFH #define SYSSYSLOGH ! #define NOINDEX ! #define NEED_STRERROR #define NEED_STRTOKEN #undef NEED_STRTOK #undef NEED_INET_ADDR #undef NEED_INET_NTOA #undef NEED_INET_NETOF ! #undef GETTIMEOFDAY #undef LRAND48 #define MALLOCH - #undef bzero(a,b) memset(a,0,b) - #undef bcopy(a,b,c) memcpy(b,a,c) - #define bcmp memcmp #define NBLOCK_POSIX #define POSIX_SIGNALS #undef TIMES_2 ! #undef GETRUSAGE_2 #endif --- 7,24 ---- #define STDLIBH #define STDDEFH #define SYSSYSLOGH ! #undef NOINDEX ! #undef NEED_STRERROR #define NEED_STRTOKEN #undef NEED_STRTOK #undef NEED_INET_ADDR #undef NEED_INET_NTOA #undef NEED_INET_NETOF ! #define GETTIMEOFDAY #undef LRAND48 #define MALLOCH #define NBLOCK_POSIX #define POSIX_SIGNALS #undef TIMES_2 ! #define GETRUSAGE_2 #endif diff -c -r irc2.8.21+CSr25/include/struct.h irc2.8.21+CSr27/include/struct.h *** irc2.8.21+CSr25/include/struct.h Mon Sep 9 15:15:23 1996 --- irc2.8.21+CSr27/include/struct.h Wed Sep 25 03:52:12 1996 *************** *** 30,35 **** --- 30,38 ---- #ifdef STDDEFH # include #endif + + #include + #ifdef ORATIMING #include #endif *************** *** 62,67 **** --- 65,82 ---- #include "dbuf.h" /* THIS REALLY SHOULDN'T BE HERE!!! --msa */ #endif + #ifdef MAJORLOGGING + typedef struct commandlog + { + char line[520]; + time_t thetime; + struct commandlog *next; + } aCommandlog; + + #endif + + + /* These set of defines are for sendto_flagops */ #define OPERS 1 #define CMODE 2 *************** *** 163,168 **** --- 178,192 ---- #define SetLog(x) ((x)->status = STAT_LOG) #define SetService(x) ((x)->status = STAT_SERVICE) + /* aConfItem->flags ... */ + + #define FLAGS_LIMIT_IP 0x0001 + #define FLAGS_NO_TILDE 0x0002 + #define FLAGS_NEED_IDENTD 0x0004 + #define FLAGS_PASS_IDENTD 0x0008 + + /* aClient->flags? ... */ + #define FLAGS_PINGSENT 0x0001 /* Unreplied ping sent */ #define FLAGS_DEADSOCKET 0x0002 /* Local socket is dead--Exiting soon */ #define FLAGS_KILLED 0x0004 /* Prevents "QUIT" from being sent for this */ *************** *** 181,187 **** #define FLAGS_WRAUTH 0x8000 /* set if we havent writen to ident server */ #define FLAGS_LOCAL 0x10000 /* set for local clients */ #define FLAGS_GOTID 0x20000 /* successful ident lookup achieved */ ! #define FLAGS_DOID 0x40000 /* I-lines say must use ident return */ #define FLAGS_NONL 0x80000 /* No \n in buffer */ #define FLAGS_FMODE 0x100000 /* +f usermode */ #define FLAGS_CMODE 0x200000 /* +c usermode */ --- 205,211 ---- #define FLAGS_WRAUTH 0x8000 /* set if we havent writen to ident server */ #define FLAGS_LOCAL 0x10000 /* set for local clients */ #define FLAGS_GOTID 0x20000 /* successful ident lookup achieved */ ! #define FLAGS_BLAHBLAH 0x40000 /* Not used */ #define FLAGS_NONL 0x80000 /* No \n in buffer */ #define FLAGS_FMODE 0x100000 /* +f usermode */ #define FLAGS_CMODE 0x200000 /* +c usermode */ *************** *** 193,199 **** #define SEND_UMODES (FLAGS_INVISIBLE|FLAGS_OPER|FLAGS_WALLOP) #define ALL_UMODES (SEND_UMODES|FLAGS_SERVNOTICE|FLAGS_CMODE|FLAGS_KMODE|FLAGS_FMODE|FLAGS_UMODE|FLAGS_LMODE|FLAGS_DMODE|FLAGS_BMODE) - #define FLAGS_ID (FLAGS_DOID|FLAGS_GOTID) /* * flags macros. --- 217,222 ---- *************** *** 287,292 **** --- 310,316 ---- char *passwd; char *name; int port; + int flags; /* Special flags... */ time_t hold; /* Hold action until this time (calendar time) */ #ifndef VMSP aClass *class; /* Class of connection */ *************** *** 561,566 **** --- 585,596 ---- #define MODE_ADD 0x80000000 */ + + #define IsLimitIp(x) ((x)->flags & FLAGS_LIMIT_IP) + #define IsNoTilde(x) ((x)->flags & FLAGS_NO_TILDE) + #define IsNeedIdentd(x) ((x)->flags & FLAGS_NEED_IDENTD) + #define IsPassIdentd(x) ((x)->flags & FLAGS_PASS_IDENTD) + #define HoldChannel(x) (!(x)) /* name invisible */ #define SecretChannel(x) ((x) && ((x)->mode.mode & MODE_SECRET)) diff -c -r irc2.8.21+CSr25/ircd/Makefile irc2.8.21+CSr27/ircd/Makefile *** irc2.8.21+CSr25/ircd/Makefile Mon Sep 9 14:50:52 1996 --- irc2.8.21+CSr27/ircd/Makefile Tue Oct 8 15:11:28 1996 *************** *** 27,33 **** # IRCDMODE given in top level Makefile, but added here to make sure # compilation works if started in ircd subdirectory ! IRCDMODE=711 INCLUDEDIR=../include # CFLAGS/IRCDLIBS used in ../Makefile should also be used here. The list --- 27,33 ---- # IRCDMODE given in top level Makefile, but added here to make sure # compilation works if started in ircd subdirectory ! IRCDMODE=771 INCLUDEDIR=../include # CFLAGS/IRCDLIBS used in ../Makefile should also be used here. The list diff -c -r irc2.8.21+CSr25/ircd/channel.c irc2.8.21+CSr27/ircd/channel.c *** irc2.8.21+CSr25/ircd/channel.c Mon Sep 9 13:54:28 1996 --- irc2.8.21+CSr27/ircd/channel.c Mon Nov 11 18:02:02 1996 *************** *** 109,119 **** if (who) return who; if (!(who = get_history(user, (long)KILLCHASETIMELIMIT))) ! { ! sendto_one(sptr, err_str(ERR_NOSUCHNICK), ! me.name, sptr->name, user); return NULL; ! } if (chasing) *chasing = 1; return who; --- 109,120 ---- if (who) return who; if (!(who = get_history(user, (long)KILLCHASETIMELIMIT))) ! { ! if (sptr != NULL) ! sendto_one(sptr, err_str(ERR_NOSUCHNICK), ! me.name, sptr->name, user); return NULL; ! } if (chasing) *chasing = 1; return who; *************** *** 135,144 **** for ( ;*s; s++) if (isspace(*s)) ! { *s = '\0'; break; ! } return (BadPtr(str)) ? star : str; } --- 136,145 ---- for ( ;*s; s++) if (isspace(*s)) ! { *s = '\0'; break; ! } return (BadPtr(str)) ? star : str; } *************** *** 1877,1882 **** --- 1878,1885 ---- return 0; } + parv[1] = canonize(parv[1], NULL); + for (; (name = strtoken(&p, parv[1], ",")); parv[1] = NULL) { if (parc > 1 && IsChannelName(name)) *************** *** 2041,2049 **** aClient *cptr, *sptr; int parc; char *parv[]; ! { aChannel *chptr; char *name, *p = NULL; #if defined(DOG3) && defined(RESTRICT) if (lifesux && !IsAnOper(sptr)) --- 2044,2053 ---- aClient *cptr, *sptr; int parc; char *parv[]; ! { aChannel *chptr; char *name, *p = NULL; + int sc; #if defined(DOG3) && defined(RESTRICT) if (lifesux && !IsAnOper(sptr)) *************** *** 2056,2090 **** sendto_one(sptr, rpl_str(RPL_LISTSTART), me.name, parv[0]); if (parc < 2 || BadPtr(parv[1])) ! { for (chptr = channel; chptr; chptr = chptr->nextch) ! { if (!sptr->user || (SecretChannel(chptr) && !IsMember(sptr, chptr))) continue; sendto_one(sptr, rpl_str(RPL_LIST), me.name, parv[0], ! ShowChannel(sptr, chptr)?chptr->chname:"*", ! chptr->users, ! ShowChannel(sptr, chptr)?chptr->topic:""); ! } sendto_one(sptr, rpl_str(RPL_LISTEND), me.name, parv[0]); return 0; ! } if (hunt_server(cptr, sptr, ":%s LIST %s %s", 2, parc, parv)) return 0; for (; (name = strtoken(&p, parv[1], ",")); parv[1] = NULL) ! { chptr = find_channel(name, NullChn); if (chptr && ShowChannel(sptr, chptr) && sptr->user) sendto_one(sptr, rpl_str(RPL_LIST), me.name, parv[0], ShowChannel(sptr,chptr) ? name : "*", chptr->users, chptr->topic); ! } sendto_one(sptr, rpl_str(RPL_LISTEND), me.name, parv[0]); return 0; ! } /************************************************************************ --- 2060,2096 ---- sendto_one(sptr, rpl_str(RPL_LISTSTART), me.name, parv[0]); if (parc < 2 || BadPtr(parv[1])) ! { for (chptr = channel; chptr; chptr = chptr->nextch) ! { if (!sptr->user || (SecretChannel(chptr) && !IsMember(sptr, chptr))) continue; + sc = ShowChannel(sptr, chptr); sendto_one(sptr, rpl_str(RPL_LIST), me.name, parv[0], ! sc ? chptr->chname : "*", chptr->users, ! sc ? chptr->topic : ""); ! } sendto_one(sptr, rpl_str(RPL_LISTEND), me.name, parv[0]); return 0; ! } if (hunt_server(cptr, sptr, ":%s LIST %s %s", 2, parc, parv)) return 0; + parv[1] = canonize(parv[1], NULL); + for (; (name = strtoken(&p, parv[1], ",")); parv[1] = NULL) ! { chptr = find_channel(name, NullChn); if (chptr && ShowChannel(sptr, chptr) && sptr->user) sendto_one(sptr, rpl_str(RPL_LIST), me.name, parv[0], ShowChannel(sptr,chptr) ? name : "*", chptr->users, chptr->topic); ! } sendto_one(sptr, rpl_str(RPL_LISTEND), me.name, parv[0]); return 0; ! } /************************************************************************ Common subdirectories: irc2.8.21+CSr25/ircd/crypt and irc2.8.21+CSr27/ircd/crypt diff -c -r irc2.8.21+CSr25/ircd/dich_conf.c irc2.8.21+CSr27/ircd/dich_conf.c *** irc2.8.21+CSr25/ircd/dich_conf.c Thu Jul 25 19:37:30 1996 --- irc2.8.21+CSr27/ircd/dich_conf.c Fri Sep 27 14:38:42 1996 *************** *** 58,68 **** * Thank you to Chris Behrens for this addition -Sol */ void ! report_conf_links(sptr, List, numeric, c) aClient *sptr; aConfList *List; int numeric; char *c; { register aConfItem *tmp; register int current; --- 58,71 ---- * Thank you to Chris Behrens for this addition -Sol */ void ! report_conf_links(sptr, List, numeric, c, muser, mhost, num) aClient *sptr; aConfList *List; int numeric; char *c; + char *muser; + char *mhost; + int *num; { register aConfItem *tmp; register int current; *************** *** 80,86 **** for(; ptr; ptr = ptr->next) { if (ptr->sub) ! report_conf_links(sptr, ptr->sub, numeric, c); if (!(tmp = ptr->conf)) continue; host = BadPtr(tmp->host) ? null : tmp->host; --- 83,90 ---- for(; ptr; ptr = ptr->next) { if (ptr->sub) ! report_conf_links(sptr, ptr->sub, numeric, c, ! muser, mhost, num); if (!(tmp = ptr->conf)) continue; host = BadPtr(tmp->host) ? null : tmp->host; *************** *** 87,92 **** --- 91,107 ---- pass = BadPtr(tmp->passwd) ? null : tmp->passwd; name = BadPtr(tmp->name) ? null : tmp->name; port = (int)tmp->port; + if (muser) + { + if ((!strcmp(muser, "*") || + !matches(name,muser)) && + !matches(host,mhost)) + ; + else + continue; + } + if (num) + (*num)++; if (tmp->status == CONF_KILL) sendto_one(sptr, rpl_str(numeric), me.name, sptr->name, c, host, pass, diff -c -r irc2.8.21+CSr25/ircd/ircd.c irc2.8.21+CSr27/ircd/ircd.c *** irc2.8.21+CSr25/ircd/ircd.c Mon Sep 9 14:21:15 1996 --- irc2.8.21+CSr27/ircd/ircd.c Mon Nov 11 20:15:50 1996 *************** *** 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 */ --- 37,42 ---- *************** *** 75,84 **** #include "dog3.h" #include "fdlist.h" fdlist serv_fdlist; fdlist busycli_fdlist; /* high-priority clients */ fdlist default_fdlist; /* just the number of the entry */ - fdlist auth_fdlist; int lifesux = 0; int dog3loadcfreq = DEFAULT_LOADCFREQ; int dog3loadrecv = DEFAULT_LOADRECV; --- 74,85 ---- #include "dog3.h" #include "fdlist.h" + time_t lastrecvtime=0; + long lastrecvK=0; + float currentrate=0; fdlist serv_fdlist; fdlist busycli_fdlist; /* high-priority clients */ fdlist default_fdlist; /* just the number of the entry */ int lifesux = 0; int dog3loadcfreq = DEFAULT_LOADCFREQ; int dog3loadrecv = DEFAULT_LOADRECV; *************** *** 325,336 **** time_t currenttime; { Reg1 aClient *cptr; ! Reg2 int killflag; ! 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 --- 326,337 ---- time_t currenttime; { Reg1 aClient *cptr; ! int ping = 0, i, checkit = 0; time_t oldest = 0, timeout; static time_t lastcheck = 0; + register int reg; #ifdef IDLE_CHECK ! register int checkit2 = 0; static time_t lastidlecheck = 0; #endif *************** *** 394,410 **** if (cptr->flags & FLAGS_DEADSOCKET) { (void)exit_client(cptr, cptr, &me, "Dead socket"); continue; } #ifdef IDLE_CHECK ! idleflag = (checkit2 && IsPerson(cptr)) ? (idlelimit && !IsAnOper(cptr) && #ifdef E_LINES (currenttime-cptr->user->last > idlelimit) && ! !find_eline(cptr)) : 0; #else ! (currenttime-cptr->user->last > idlelimit)) : 0; #endif /* E_LINES */ - if (idleflag) { if (!find_idle(cptr)) { --- 395,413 ---- if (cptr->flags & FLAGS_DEADSOCKET) { (void)exit_client(cptr, cptr, &me, "Dead socket"); + i=0; continue; } + #ifdef IDLE_CHECK ! if (checkit2 && IsPerson(cptr) && idlelimit && ! !IsAnOper(cptr) && #ifdef E_LINES (currenttime-cptr->user->last > idlelimit) && ! !find_eline(cptr)) #else ! (currenttime-cptr->user->last > idlelimit)) #endif /* E_LINES */ { if (!find_idle(cptr)) { *************** *** 417,519 **** strcpy(crap->username, temp); strcpy(crap->hostname, cptr->user->host); } } #endif ! killflag = (checkit && IsPerson(cptr)) ? ! find_kill(cptr, 0) : 0; ! #ifdef R_LINES_OFTEN ! rflag = (checkit && IsPerson(cptr)) ? find_restrict(cptr) : 0; #endif ! ping = IsRegistered(cptr) ? get_client_ping(cptr) : ! CONNECTTIMEOUT; ! Debug((DEBUG_DEBUG, "c(%s)=%d p %d k %d r %d a %d", ! cptr->name, cptr->status, ping, killflag, rflag, ! currenttime - cptr->lasttime)); /* - * Ok, so goto's are ugly and can be avoided here but this code - * 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; - /* * If the server hasnt talked to us in 2*ping seconds * and it has a ping time, then close its connection. * If the client is a user and a KILL line was found * 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) && ! (currenttime - cptr->firsttime) >= ping)) ! { ! if (!IsRegistered(cptr) && ! (DoingDNS(cptr) || DoingAuth(cptr))) ! { ! if (cptr->authfd >= 0) ! { ! (void)close(cptr->authfd); ! cptr->authfd = -1; ! cptr->count = 0; ! *cptr->buffer = '\0'; } - Debug((DEBUG_NOTICE, - "DNS/AUTH timeout %s", - get_client_name(cptr,TRUE))); - del_queries((char *)cptr); - ClearAuth(cptr); - ClearDNS(cptr); - SetAccess(cptr); - cptr->firsttime = currenttime; - cptr->lasttime = currenttime; - continue; - } if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr)) sendto_ops("No response from %s, closing link", get_client_name(cptr, FALSE)); ! /* ! * this is used for KILL lines with time restrictions ! * 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.", ! get_client_name(cptr,FALSE)); ! #endif ! 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; continue; ! } ! else if (IsRegistered(cptr) && ! (cptr->flags & FLAGS_PINGSENT) == 0) ! { /* * if we havent PINGed the connection and we havent * heard from it in a while, PING it to make sure --- 420,519 ---- strcpy(crap->username, temp); strcpy(crap->hostname, cptr->user->host); } + sendto_ops("Idle time limit exceeded for %s", + get_client_name(cptr, FALSE)); + (void)exit_client(cptr, cptr, &me, + "Idle time limit exceeded"); + i=0; + continue; } #endif ! if (checkit && IsPerson(cptr)) ! { ! char *reason; ! ! if (find_kill(cptr, 0, &reason)) ! { ! /* ! * this is used for KILL lines with time restrictions ! * on them - send a messgae to the user being killed ! * first. ! */ ! sendto_ops("Kill line active for %s", ! get_client_name(cptr, FALSE)); ! (void)exit_client(cptr, cptr, &me, reason); ! i=0; ! continue; ! } ! #if defined(R_LINES) && defined(R_LINES_OFTEN) ! if (find_restrict(cptr)) ! { ! sendto_ops("Restricting %s, closing link.", ! get_client_name(cptr,FALSE)); ! (void)exit_client(cptr, cptr, &me, "R-Lined"); ! i=0; ! continue; ! } #endif ! } ! reg = IsRegistered(cptr); ! if (reg) ! { ! /* ! * Ok, so goto's are ugly and can be avoided here but this code ! * is already indented enough so I think its justified. -avalon ! */ ! ping = get_client_ping(cptr); ! if (ping >= (currenttime - cptr->lasttime)) ! goto ping_timeout; ! } ! else ! ping = CONNECTTIMEOUT; ! /* * If the server hasnt talked to us in 2*ping seconds * and it has a ping time, then close its connection. * If the client is a user and a KILL line was found * to be active, close this connection too. */ ! if ( (((currenttime - cptr->lasttime) >= ping*2) && ! (cptr->flags & FLAGS_PINGSENT)) || ! ((IsUnknown(cptr) || !reg) && ! ((currenttime - cptr->firsttime) >= ping))) ! { ! if (!reg || (cptr->flags & FLAGS_PINGSENT)) ! { ! if (!reg && (DoingDNS(cptr) || DoingAuth(cptr))) ! { ! if (cptr->authfd >= 0) ! { ! (void)close(cptr->authfd); ! cptr->authfd = -1; ! cptr->count = 0; ! *cptr->buffer = '\0'; ! } ! Debug((DEBUG_NOTICE, ! "DNS/AUTH timeout %s", ! get_client_name(cptr,TRUE))); ! del_queries((char *)cptr); ! ClearAuth(cptr); ! ClearDNS(cptr); ! SetAccess(cptr); ! cptr->firsttime = currenttime; ! cptr->lasttime = currenttime; ! continue; } if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr)) sendto_ops("No response from %s, closing link", get_client_name(cptr, FALSE)); ! (void)exit_client(cptr, cptr, &me, "Ping timeout"); i = 0; continue; ! } ! } ! else if (reg && !(cptr->flags & FLAGS_PINGSENT)) ! { /* * if we havent PINGed the connection and we havent * heard from it in a while, PING it to make sure *************** *** 525,535 **** --- 525,537 ---- sendto_one(cptr, "PING :%s", me.name); } ping_timeout: + #ifdef blahblahblah timeout = cptr->lasttime + ping; while (timeout <= currenttime) timeout += ping; if (timeout < oldest || !oldest) oldest = timeout; + #endif #if defined(CLONE_CHECK) && defined(KILL_CLONES) if (*clonekillhost) { *************** *** 541,552 **** sendto_ops("Clonebot killed: %s [%s@%s]", cptr->name, cptr->user->username, cptr->user->host); - #ifdef REALLY_FUCK_EM_UP - sendto_serv_butone(NULL, - ":%s KILL %s :%s (CloneBot)", - me.name, cptr->name, me.name); - cptr->flags |= FLAGS_KILLED; - #endif /* REALLY_FUCK_EM_UP */ (void)exit_client(cptr, cptr, &me, "CloneBot"); i = 0; continue; --- 543,548 ---- *************** *** 557,567 **** --- 553,567 ---- #if defined(CLONE_CHECK) && defined(KILL_CLONES) *clonekillhost = (char) 0; #endif + #ifdef blahblahblah if (!oldest || oldest < currenttime) oldest = currenttime + PINGFREQUENCY; Debug((DEBUG_NOTICE,"Next check_ping() call at: %s, %d %d %d", myctime(oldest), ping, oldest, currenttime)); return (oldest); + #else + return currenttime+PINGFREQUENCY; + #endif } /* *************** *** 583,588 **** --- 583,602 ---- return (-1); } + void init_me() + { + me.port = portnum; + me.flags = FLAGS_LISTEN; + if (bootopt & BOOT_INETD) + { + me.fd = 0; + local[0] = &me; + me.flags = FLAGS_LISTEN; + } + else + me.fd = -1; + } + int main(argc, argv) int argc; char *argv[]; *************** *** 618,633 **** #ifdef CHROOTDIR if (chdir(dpath)) ! { perror("chdir"); exit(-1); ! } res_init(); if (chroot(DPATH)) ! { (void)fprintf(stderr,"ERROR: Cannot chdir/chroot\n"); exit(5); ! } #endif /*CHROOTDIR*/ myargv = argv; --- 632,647 ---- #ifdef CHROOTDIR if (chdir(dpath)) ! { perror("chdir"); exit(-1); ! } res_init(); if (chroot(DPATH)) ! { (void)fprintf(stderr,"ERROR: Cannot chdir/chroot\n"); exit(5); ! } #endif /*CHROOTDIR*/ myargv = argv; *************** *** 643,658 **** ** "-fxyz"), it would conflict with the form "-fstring". */ while (--argc > 0 && (*++argv)[0] == '-') ! { char *p = argv[0]+1; int flag = *p++; if (flag == '\0' || *p == '\0') if (argc > 1 && argv[1][0] != '-') ! { p = *++argv; argc -= 1; ! } else p = ""; --- 657,672 ---- ** "-fxyz"), it would conflict with the form "-fstring". */ while (--argc > 0 && (*++argv)[0] == '-') ! { char *p = argv[0]+1; int flag = *p++; if (flag == '\0' || *p == '\0') if (argc > 1 && argv[1][0] != '-') ! { p = *++argv; argc -= 1; ! } else p = ""; *************** *** 714,728 **** default: bad_command(); break; ! } ! } #ifndef CHROOT if (chdir(dpath)) ! { perror("chdir"); exit(-1); ! } #endif #ifdef BETTER_MOTD motd = NULL; --- 728,742 ---- default: bad_command(); break; ! } ! } #ifndef CHROOT if (chdir(dpath)) ! { perror("chdir"); exit(-1); ! } #endif #ifdef BETTER_MOTD motd = NULL; *************** *** 731,742 **** #endif #ifndef IRC_UID if ((uid != euid) && !euid) ! { (void)fprintf(stderr, "ERROR: do not run ircd setuid root. Make it setuid a\ normal user.\n"); exit(-1); ! } #endif #if !defined(CHROOTDIR) || (defined(IRC_UID) && defined(IRC_GID)) --- 745,756 ---- #endif #ifndef IRC_UID if ((uid != euid) && !euid) ! { (void)fprintf(stderr, "ERROR: do not run ircd setuid root. Make it setuid a\ normal user.\n"); exit(-1); ! } #endif #if !defined(CHROOTDIR) || (defined(IRC_UID) && defined(IRC_GID)) *************** *** 745,751 **** # endif if ((int)getuid() == 0) ! { # if defined(IRC_UID) && defined(IRC_GID) /* run as a specified user */ --- 759,765 ---- # endif if ((int)getuid() == 0) ! { # if defined(IRC_UID) && defined(IRC_GID) /* run as a specified user */ *************** *** 761,767 **** normal user.\n"); exit(-1); # endif ! } #endif /*CHROOTDIR/UID/GID*/ /* didn't set debuglevel */ --- 775,781 ---- normal user.\n"); exit(-1); # endif ! } #endif /*CHROOTDIR/UID/GID*/ /* didn't set debuglevel */ *************** *** 782,793 **** initclass(); initwhowas(); initstats(); open_debugfile(); #ifdef DOG3 init_fdlist(&serv_fdlist); init_fdlist(&busycli_fdlist); init_fdlist(&default_fdlist); - init_fdlist(&auth_fdlist); { register int i; for (i=MAXCONNECTIONS+1 ; i>0 ; i--) --- 796,808 ---- initclass(); initwhowas(); initstats(); + NOW = time(NULL); open_debugfile(); + NOW = time(NULL); #ifdef DOG3 init_fdlist(&serv_fdlist); init_fdlist(&busycli_fdlist); init_fdlist(&default_fdlist); { register int i; for (i=MAXCONNECTIONS+1 ; i>0 ; i--) *************** *** 796,827 **** #endif if (portnum < 0) portnum = PORTNUM; - me.port = portnum; (void)init_sys(); ! me.flags = FLAGS_LISTEN; ! if (bootopt & BOOT_INETD) ! { ! me.fd = 0; ! local[0] = &me; ! me.flags = FLAGS_LISTEN; ! } ! else ! me.fd = -1; #ifdef USE_SYSLOG openlog(myargv[0], LOG_PID|LOG_NDELAY, LOG_FACILITY); #endif if (initconf(bootopt,configfile) == -1) ! { Debug((DEBUG_FATAL, "Failed in reading configuration file %s", configfile)); (void)printf("Couldn't open configuration file %s\n", configfile); exit(-1); ! } initconf(bootopt,klinefile); if (!(bootopt & BOOT_INETD)) ! { static char star[] = "*"; aConfItem *aconf; --- 811,844 ---- #endif if (portnum < 0) portnum = PORTNUM; (void)init_sys(); ! init_me(); #ifdef USE_SYSLOG openlog(myargv[0], LOG_PID|LOG_NDELAY, LOG_FACILITY); #endif if (initconf(bootopt,configfile) == -1) ! { Debug((DEBUG_FATAL, "Failed in reading configuration file %s", configfile)); (void)printf("Couldn't open configuration file %s\n", configfile); exit(-1); ! } initconf(bootopt,klinefile); + #ifdef SEPARATE_QUOTE_KLINES_BY_DATE + { + struct tm *tmptr; + char timebuffer[20], filename[200]; + + tmptr = localtime(&NOW); + strftime(timebuffer, 20, "%y%m%d", tmptr); + sprintf(filename, "%s.%s", klinefile, timebuffer); + initconf(0,filename); + } + #endif if (!(bootopt & BOOT_INETD)) ! { static char star[] = "*"; aConfItem *aconf; *************** *** 829,836 **** portnum = aconf->port; Debug((DEBUG_ERROR, "Port = %d", portnum)); if (inetport(&me, star, portnum)) exit(1); ! } else if (inetport(&me, "*", 0)) exit(1); --- 846,857 ---- portnum = aconf->port; Debug((DEBUG_ERROR, "Port = %d", portnum)); if (inetport(&me, star, portnum)) + { + fprintf(stderr, "Couldn't bind to port %d\n", + portnum); exit(1); ! } ! } else if (inetport(&me, "*", 0)) exit(1); *************** *** 876,887 **** NOW = time(NULL); #ifdef DOG3 { - static time_t lasttime=0; - static long lastrecvK; static int init=0; static time_t loadcfreq=DEFAULT_LOADCFREQ; ! if (NOW-lasttime < loadcfreq) goto done_check; if (me.receiveK - dog3loadrecv > lastrecvK) { --- 897,906 ---- NOW = time(NULL); #ifdef DOG3 { static int init=0; static time_t loadcfreq=DEFAULT_LOADCFREQ; ! if (NOW-lastrecvtime < loadcfreq) goto done_check; if (me.receiveK - dog3loadrecv > lastrecvK) { *************** *** 888,895 **** if (!lifesux) { sendto_ops("Entering high-traffic mode - %uk/%us > %uk/%us", ! me.receiveK-lastrecvK, NOW-lasttime, ! dog3loadrecv, NOW-lasttime); loadcfreq *= 2; /* add hysteresis */ lifesux = TRUE; } --- 907,914 ---- if (!lifesux) { sendto_ops("Entering high-traffic mode - %uk/%us > %uk/%us", ! me.receiveK-lastrecvK, NOW-lastrecvtime, ! dog3loadrecv, NOW-lastrecvtime); loadcfreq *= 2; /* add hysteresis */ lifesux = TRUE; } *************** *** 901,914 **** { lifesux = 0; sendto_ops("Resuming standard operation - %uk/%us <= %uk/%us", ! me.receiveK-lastrecvK, NOW-lasttime, ! dog3loadrecv, NOW-lasttime); } } ! lasttime = NOW; lastrecvK = me.receiveK; done_check: ! ; } #endif /* DOG3 */ --- 920,934 ---- { lifesux = 0; sendto_ops("Resuming standard operation - %uk/%us <= %uk/%us", ! me.receiveK-lastrecvK, NOW-lastrecvtime, ! dog3loadrecv, NOW-lastrecvtime); } } ! lastrecvtime = NOW; lastrecvK = me.receiveK; done_check: ! if (lastrecvtime != NOW) ! currentrate = ((float)(me.receiveK-lastrecvK))/((float)(NOW-lastrecvtime)); } #endif /* DOG3 */ *************** *** 968,974 **** #endif { static time_t lasttime=0; ! if ((lasttime + (lifesux +1) * 2)< NOW) { read_message(delay,NULL); /* check everything! */ lasttime = NOW; --- 988,994 ---- #endif { static time_t lasttime=0; ! if ((lasttime + (lifesux ? 6 : 4))< NOW) { read_message(delay,NULL); /* check everything! */ lasttime = NOW; *************** *** 1002,1008 **** ** have data in them (or at least try to flush) ** -avalon */ ! flush_connections(me.fd); #ifdef DOG3 /* check which clients are active */ if (NOW > nextfdlistcheck) --- 1022,1036 ---- ** have data in them (or at least try to flush) ** -avalon */ ! { ! static time_t lastone = 0; ! ! if ((lastone+1) < NOW) ! { ! flush_connections(me.fd); ! lastone = NOW; ! } ! } #ifdef DOG3 /* check which clients are active */ if (NOW > nextfdlistcheck) *************** *** 1168,1174 **** cptr->lastrecvM = cptr->receiveM; cptr->priority = pri; ! if ((pri <10) || (!lifesux && (pri < 25))) busycli_fdlist.entry[++j] = i; } busycli_fdlist.last_entry=j; /* rest of the fdlist is garbage */ --- 1196,1202 ---- cptr->lastrecvM = cptr->receiveM; cptr->priority = pri; ! if ((pri < 10) || (!lifesux && (pri < 25))) busycli_fdlist.entry[++j] = i; } busycli_fdlist.last_entry=j; /* rest of the fdlist is garbage */ diff -c -r irc2.8.21+CSr25/ircd/list.c irc2.8.21+CSr27/ircd/list.c *** irc2.8.21+CSr25/ircd/list.c Thu Jul 25 19:37:25 1996 --- irc2.8.21+CSr27/ircd/list.c Wed Sep 25 01:27:37 1996 *************** *** 130,137 **** --- 130,139 ---- if (size == CLIENT_LOCAL_SIZE) { cptr->since = cptr->lasttime = cptr->firsttime = NOW; + #ifdef NO_NICK_FLOODS cptr->lastnick = 0; cptr->numnicks = 0; + #endif cptr->confs = NULL; cptr->sockhost[0] = '\0'; cptr->buffer[0] = '\0'; *************** *** 378,383 **** --- 380,386 ---- aconf->clients = 0; aconf->port = 0; aconf->hold = 0; + aconf->flags = 0; Class(aconf) = 0; return (aconf); } Only in irc2.8.21+CSr27/ircd: poll.c diff -c -r irc2.8.21+CSr25/ircd/res.c irc2.8.21+CSr27/ircd/res.c *** irc2.8.21+CSr25/ircd/res.c Thu Jul 25 19:37:25 1996 --- irc2.8.21+CSr27/ircd/res.c Tue Sep 17 16:16:44 1996 *************** *** 309,315 **** for (i = 0; i < max; i++) { _res.nsaddr_list[i].sin_family = AF_INET; ! if (sendto(resfd, msg, len, 0, &(_res.nsaddr_list[i]), sizeof(struct sockaddr)) == len) { reinfo.re_sent++; --- 309,315 ---- for (i = 0; i < max; i++) { _res.nsaddr_list[i].sin_family = AF_INET; ! if (sendto(resfd, msg, len, 0, (struct sockaddr *)&(_res.nsaddr_list[i]), sizeof(struct sockaddr)) == len) { reinfo.re_sent++; diff -c -r irc2.8.21+CSr25/ircd/s_auth.c irc2.8.21+CSr27/ircd/s_auth.c *** irc2.8.21+CSr25/ircd/s_auth.c Thu Jul 25 19:37:25 1996 --- irc2.8.21+CSr27/ircd/s_auth.c Mon Oct 7 13:02:02 1996 *************** *** 54,59 **** --- 54,60 ---- Reg1 aClient *cptr; { struct sockaddr_in sock; + int blah; Debug((DEBUG_NOTICE,"start_auth(%x) fd %d status %d", cptr, cptr->fd, cptr->status)); *************** *** 72,83 **** return; } if (cptr->authfd >= (MAXCONNECTIONS-2)) ! { sendto_ops("Can't allocate fd for auth on %s", get_client_name(cptr, TRUE)); (void)close(cptr->authfd); return; ! } set_non_blocking(cptr->authfd, cptr); --- 73,84 ---- return; } if (cptr->authfd >= (MAXCONNECTIONS-2)) ! { sendto_ops("Can't allocate fd for auth on %s", get_client_name(cptr, TRUE)); (void)close(cptr->authfd); return; ! } set_non_blocking(cptr->authfd, cptr); *************** *** 87,100 **** sock.sin_port = htons(113); sock.sin_family = AF_INET; ! if (connect(cptr->authfd, (struct sockaddr *)&sock, #ifdef DGUX ! sizeof(sock)) == -1 && (errno != EINPROGRESS) && ! (errno != EAGAIN)) #else ! sizeof(sock)) == -1 && errno != EINPROGRESS) #endif ! { ircstp->is_abad++; /* * No error report from this... --- 88,101 ---- sock.sin_port = htons(113); sock.sin_family = AF_INET; ! blah = connect(cptr->authfd, (struct sockaddr *)&sock, sizeof(sock)); ! if ((blah==-1) && #ifdef DGUX ! (errnno != EINPROGRESS) && (errno != EAGAIN)) #else ! (errno != EINPROGRESS)) #endif ! { ircstp->is_abad++; /* * No error report from this... *************** *** 104,110 **** if (!DoingDNS(cptr)) SetAccess(cptr); return; ! } cptr->flags |= (FLAGS_WRAUTH|FLAGS_AUTH); if (cptr->authfd > highest_fd) highest_fd = cptr->authfd; --- 105,111 ---- if (!DoingDNS(cptr)) SetAccess(cptr); return; ! } cptr->flags |= (FLAGS_WRAUTH|FLAGS_AUTH); if (cptr->authfd > highest_fd) highest_fd = cptr->authfd; diff -c -r irc2.8.21+CSr25/ircd/s_bsd.c irc2.8.21+CSr27/ircd/s_bsd.c *** irc2.8.21+CSr25/ircd/s_bsd.c Wed Sep 11 20:02:16 1996 --- irc2.8.21+CSr27/ircd/s_bsd.c Mon Nov 11 21:19:22 1996 *************** *** 87,95 **** #define IN_LOOPBACKNET 0x7f #endif - #if defined(MAXBUFFERS) && !defined(SEQUENT) int rcvbufmax = 0, sndbufmax = 0; - #endif aClient *local[MAXCONNECTIONS]; int highest_fd = 0, readcalls = 0, udpfd = -1, resfd = -1; --- 87,93 ---- *************** *** 106,124 **** static char unixpath[256]; #endif - #if defined(MAXBUFFERS) && !defined(SEQUENT) static char *readbuf; - #else ! #ifdef SEQUENT ! # ifdef READBUFSIZE ! # undef READBUFSIZE ! # endif #define READBUFSIZE 8192 #endif - static char readbuf[READBUFSIZE]; - #endif extern ts_val timedelta; --- 104,115 ---- static char unixpath[256]; #endif static char *readbuf; ! #ifndef READBUFSIZE #define READBUFSIZE 8192 #endif extern ts_val timedelta; *************** *** 140,145 **** --- 131,137 ---- # endif #endif + /* ** add_local_domain() ** Add the domain to hostname, if it is missing *************** *** 208,214 **** */ #ifdef SO_ERROR if (!IsMe(cptr) && cptr->fd >= 0) ! if (!getsockopt(cptr->fd, SOL_SOCKET, SO_ERROR, &err, &len)) if (err) errtmp = err; #endif --- 200,206 ---- */ #ifdef SO_ERROR if (!IsMe(cptr) && cptr->fd >= 0) ! if (!getsockopt(cptr->fd, SOL_SOCKET, SO_ERROR, (char *)&err, (int *)&len)) if (err) errtmp = err; #endif *************** *** 286,292 **** * This used to be the case. Now it no longer is. * Could cause the server to hang for too long - avalon */ ! if (bind(cptr->fd, &server, sizeof(server)) == -1) { report_error("binding stream socket %s:%s", cptr); (void)close(cptr->fd); --- 278,284 ---- * This used to be the case. Now it no longer is. * Could cause the server to hang for too long - avalon */ ! if (bind(cptr->fd, (struct sockaddr *)&server, sizeof(server)) == -1) { report_error("binding stream socket %s:%s", cptr); (void)close(cptr->fd); *************** *** 312,318 **** highest_fd = cptr->fd; cptr->ip.s_addr = inet_addr(ipname); cptr->port = (int)ntohs(server.sin_port); ! (void)listen(cptr->fd, 5); local[cptr->fd] = cptr; return 0; --- 304,310 ---- highest_fd = cptr->fd; cptr->ip.s_addr = inet_addr(ipname); cptr->port = (int)ntohs(server.sin_port); ! (void)listen(cptr->fd, 1024); local[cptr->fd] = cptr; return 0; *************** *** 404,410 **** } if (cptr->fd > highest_fd) highest_fd = cptr->fd; ! (void)listen(cptr->fd, 5); (void)chmod(path, 0755); (void)chmod(unixpath, 0777); cptr->flags |= FLAGS_UNIX; --- 396,402 ---- } if (cptr->fd > highest_fd) highest_fd = cptr->fd; ! (void)listen(cptr->fd, 1024); (void)chmod(path, 0755); (void)chmod(unixpath, 0777); cptr->flags |= FLAGS_UNIX; *************** *** 466,494 **** struct rlimit limit; if (!getrlimit(RLIMIT_FD_MAX, &limit)) ! { # ifdef pyr if (limit.rlim_cur < MAXCONNECTIONS) #else if (limit.rlim_max < MAXCONNECTIONS) # endif ! { (void)fprintf(stderr,"ircd fd table too big\n"); (void)fprintf(stderr,"Hard Limit: %d IRC max: %d\n", limit.rlim_max, MAXCONNECTIONS); (void)fprintf(stderr,"Fix MAXCONNECTIONS\n"); exit(-1); ! } # ifndef pyr limit.rlim_cur = limit.rlim_max; /* make soft limit the max */ if (setrlimit(RLIMIT_FD_MAX, &limit) == -1) ! { (void)fprintf(stderr,"error setting max fd's to %d\n", limit.rlim_cur); exit(-1); ! } # endif ! } #endif #ifdef sequent # ifndef DYNIXPTX --- 458,486 ---- struct rlimit limit; if (!getrlimit(RLIMIT_FD_MAX, &limit)) ! { # ifdef pyr if (limit.rlim_cur < MAXCONNECTIONS) #else if (limit.rlim_max < MAXCONNECTIONS) # endif ! { (void)fprintf(stderr,"ircd fd table too big\n"); (void)fprintf(stderr,"Hard Limit: %d IRC max: %d\n", limit.rlim_max, MAXCONNECTIONS); (void)fprintf(stderr,"Fix MAXCONNECTIONS\n"); exit(-1); ! } # ifndef pyr limit.rlim_cur = limit.rlim_max; /* make soft limit the max */ if (setrlimit(RLIMIT_FD_MAX, &limit) == -1) ! { (void)fprintf(stderr,"error setting max fd's to %d\n", limit.rlim_cur); exit(-1); ! } # endif ! } #endif #ifdef sequent # ifndef DYNIXPTX *************** *** 612,618 **** strncpyzt(sockn, me.sockhost, HOSTLEN); bzero((char *)&sk, sizeof(struct sockaddr_in)); } ! else if (getpeername(cptr->fd, &sk, &len) == -1) { report_error("connect failure: %s %s", cptr); return -1; --- 604,610 ---- strncpyzt(sockn, me.sockhost, HOSTLEN); bzero((char *)&sk, sizeof(struct sockaddr_in)); } ! else if (getpeername(cptr->fd, (struct sockaddr *)&sk, &len) == -1) { report_error("connect failure: %s %s", cptr); return -1; *************** *** 1045,1050 **** --- 1037,1046 ---- { flush_connections(cptr->fd); local[cptr->fd] = NULL; + #ifdef DOG3 + delfrom_fdlist(cptr->fd,&busycli_fdlist); + delfrom_fdlist(cptr->fd,&serv_fdlist); + #endif (void)close(cptr->fd); cptr->fd = -2; DBufClear(&cptr->sendQ); *************** *** 1077,1082 **** --- 1073,1081 ---- if ((j = highest_fd) > (i = empty) && (local[j]->status != STAT_LOG)) { + /* We do not dup listening fds!!!! -- Comstud */ + if (IsListening(local[j])) + return; if (dup2(j,i) == -1) return; local[i] = local[j]; *************** *** 1099,1104 **** --- 1098,1137 ---- return; } + void find_max_buffers(fd) + int fd; + { + int optlen; + + #ifdef _SEQUENT_ + rcvbufmax = sndbufmax = 8192; + readbuf = (char *)MyMalloc(8192 * sizeof(char)); + return; + #endif + + #ifdef MAXBUFFERS + optlen = sizeof(rcvbufmax); + getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&rcvbufmax, &optlen); + while((rcvbufmax < 64500) && + (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, + (char *)&rcvbufmax, optlen) >= 0)) + rcvbufmax += 1024; + getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&rcvbufmax, &optlen); + readbuf = (char *)MyMalloc(rcvbufmax * sizeof(char)); + #ifdef SOL20 + sndbufmax = rcvbufmax; + if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, + (char *)&rcvbufmax, optlen) != 0) + #endif + sndbufmax = (rcvbufmax < 8192) ? rcvbufmax : 8192; + return; + #endif + + rcvbufmax = READBUFSIZE; + sndbufmax = rcvbufmax > 8192 ? 8192 : rcvbufmax; + readbuf = (char *)MyMalloc(rcvbufmax * sizeof(char)); + } + /* ** set_sock_opts */ *************** *** 1106,1115 **** int fd; aClient *cptr; { ! int opt; #ifdef SO_REUSEADDR opt = 1; ! if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) report_error("setsockopt(SO_REUSEADDR) %s:%s", cptr); #endif #if defined(SO_DEBUG) && defined(DEBUGMODE) && 0 --- 1139,1149 ---- int fd; aClient *cptr; { ! int opt; ! #ifdef SO_REUSEADDR opt = 1; ! if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)) < 0) report_error("setsockopt(SO_REUSEADDR) %s:%s", cptr); #endif #if defined(SO_DEBUG) && defined(DEBUGMODE) && 0 *************** *** 1116,1191 **** /* Solaris with SO_DEBUG writes to syslog by default */ #if !defined(SOL20) || defined(USE_SYSLOG) opt = 1; ! if (setsockopt(fd, SOL_SOCKET, SO_DEBUG, &opt, sizeof(opt)) < 0) report_error("setsockopt(SO_DEBUG) %s:%s", cptr); #endif /* SOL20 */ #endif #ifdef SO_USELOOPBACK opt = 1; ! if (setsockopt(fd, SOL_SOCKET, SO_USELOOPBACK, &opt, sizeof(opt)) < 0) report_error("setsockopt(SO_USELOOPBACK) %s:%s", cptr); #endif #ifdef SO_RCVBUF ! #ifdef MAXBUFFERS ! if (rcvbufmax==0) { ! int optlen; ! optlen = sizeof(rcvbufmax); ! getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *) &rcvbufmax, ! &optlen); ! while((rcvbufmax < 65535) && (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, ! (char *) &rcvbufmax, optlen) >= 0)) ! rcvbufmax++; ! getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *) &rcvbufmax, ! &optlen); ! readbuf = (char *)MyMalloc(rcvbufmax * sizeof(char)); ! } ! opt = rcvbufmax; ! #else ! opt = READBUFSIZE; ! #endif ! if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(opt)) < 0) report_error("setsockopt(SO_RCVBUF) %s:%s", cptr); #endif #ifdef SO_SNDBUF ! # ifdef _SEQUENT_ ! /* seems that Sequent freezes up if the receving buffer is a different size ! * to the sending buffer (maybe a tcp window problem too). ! */ ! opt = 8192; ! # else ! #ifdef MAXBUFFERS ! opt = rcvbufmax >= 8192 ? 8192 : rcvbufmax; ! #else ! opt = READBUFSIZE >= 8192 ? 8192 : READBUFSIZE; ! #endif ! # endif ! if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)) < 0) report_error("setsockopt(SO_SNDBUF) %s:%s", cptr); #endif ! #if defined(IP_OPTIONS) && defined(IPPROTO_IP) ! { ! char *s = readbuf, *t; ! #ifndef MAXBUFFERS ! t = readbuf + sizeof(readbuf) / 2; ! opt = sizeof(readbuf) / 8; ! #else ! t = readbuf + (rcvbufmax*sizeof(char))/2; ! opt = (rcvbufmax*sizeof(char))/8; ! #endif ! if (getsockopt(fd, IPPROTO_IP, IP_OPTIONS, t, &opt) < 0) report_error("getsockopt(IP_OPTIONS) %s:%s", cptr); else if (opt > 0) ! { for (*readbuf = '\0'; opt > 0; opt--, s+= 3) (void)irc_sprintf(s, "%02.2x:", *t++); *s = '\0'; sendto_ops("Connection %s using IP opts: (%s)", ! get_client_name(cptr, TRUE), readbuf); ! } if (setsockopt(fd, IPPROTO_IP, IP_OPTIONS, (char *)NULL, 0) < 0) report_error("setsockopt(IP_OPTIONS) %s:%s", cptr); ! } #endif } --- 1150,1196 ---- /* Solaris with SO_DEBUG writes to syslog by default */ #if !defined(SOL20) || defined(USE_SYSLOG) opt = 1; ! if (setsockopt(fd, SOL_SOCKET, SO_DEBUG, (char *)&opt, sizeof(opt)) < 0) report_error("setsockopt(SO_DEBUG) %s:%s", cptr); #endif /* SOL20 */ #endif #ifdef SO_USELOOPBACK opt = 1; ! if (setsockopt(fd, SOL_SOCKET, SO_USELOOPBACK, (char *)&opt, sizeof(opt)) < 0) report_error("setsockopt(SO_USELOOPBACK) %s:%s", cptr); #endif + if (!rcvbufmax) + find_max_buffers(fd); #ifdef SO_RCVBUF ! if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF,(char *)&rcvbufmax, ! sizeof(rcvbufmax)) < 0) report_error("setsockopt(SO_RCVBUF) %s:%s", cptr); #endif #ifdef SO_SNDBUF ! if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF,(char *)&sndbufmax, ! sizeof(sndbufmax)) < 0) report_error("setsockopt(SO_SNDBUF) %s:%s", cptr); #endif ! #if defined(IP_OPTIONS) && defined(IPPROTO_IP) && !defined(AIX) ! { ! char opbuf[256], *t = opbuf; ! char *s = readbuf; ! opt = sizeof(opbuf); ! ! if (getsockopt(fd, IPPROTO_IP, IP_OPTIONS, t, (int *)&opt) < 0) report_error("getsockopt(IP_OPTIONS) %s:%s", cptr); else if (opt > 0) ! { for (*readbuf = '\0'; opt > 0; opt--, s+= 3) (void)irc_sprintf(s, "%02.2x:", *t++); *s = '\0'; sendto_ops("Connection %s using IP opts: (%s)", ! get_client_name(cptr, TRUE), readbuf); ! } if (setsockopt(fd, IPPROTO_IP, IP_OPTIONS, (char *)NULL, 0) < 0) report_error("setsockopt(IP_OPTIONS) %s:%s", cptr); ! } #endif } *************** *** 1196,1202 **** int errtmp = errno, err = 0, len = sizeof(err); #ifdef SO_ERROR if (cptr->fd >= 0) ! if (!getsockopt(cptr->fd, SOL_SOCKET, SO_ERROR, &err, &len)) if (err) errtmp = err; #endif --- 1201,1207 ---- int errtmp = errno, err = 0, len = sizeof(err); #ifdef SO_ERROR if (cptr->fd >= 0) ! if (!getsockopt(cptr->fd, SOL_SOCKET, SO_ERROR, (char *)&err, (int *)&len)) if (err) errtmp = err; #endif *************** *** 1387,1393 **** ** 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; { --- 1392,1398 ---- ** Do some tricky stuff for client connections to make sure they don't do ** any flooding >:-) -avalon */ ! int read_packet(cptr, msg_ready) Reg1 aClient *cptr; int msg_ready; { *************** *** 1397,1407 **** !(IsPerson(cptr) && DBufLength(&cptr->recvQ) > 6090)) { errno = 0; - #ifndef MAXBUFFERS - length = recv(cptr->fd, readbuf, sizeof(readbuf), 0); - #else length = recv(cptr->fd, readbuf, rcvbufmax*sizeof(char), 0); - #endif cptr->lasttime = NOW; if (cptr->lasttime > cptr->since) --- 1402,1408 ---- *************** *** 1453,1463 **** if (IsService(cptr) || IsServer(cptr)) { dolen = dbuf_get(&cptr->recvQ, readbuf, - #ifndef MAXBUFFERS - sizeof(readbuf)); - #else rcvbufmax*sizeof(char)); - #endif if (dolen <= 0) break; if ((done = dopacket(cptr, readbuf, dolen))) --- 1454,1460 ---- *************** *** 1465,1475 **** break; } dolen = dbuf_getmsg(&cptr->recvQ, readbuf, - #ifndef MAXBUFFERS - sizeof(readbuf)); - #else rcvbufmax*sizeof(char)); - #endif /* ** Devious looking...whats it do ? well..if a client ** sends a *long* message without any CR or LF, then --- 1462,1468 ---- *************** *** 1532,1538 **** time_t delay2 = delay; u_long usec = 0; int res, length, fd; ! int auth = 0; register int i; #ifdef DOG3 register int j; --- 1525,1531 ---- time_t delay2 = delay; u_long usec = 0; int res, length, fd; ! int auth; register int i; #ifdef DOG3 register int j; *************** *** 1555,1564 **** #endif for (res = 0;;) ! { FD_ZERO(&read_set); FD_ZERO(&write_set); ! #ifdef DOG3 for (i=listp->entry[j=1];j<=listp->last_entry; i=listp->entry[++j]) --- 1548,1557 ---- #endif for (res = 0;;) ! { FD_ZERO(&read_set); FD_ZERO(&write_set); ! auth = 0; #ifdef DOG3 for (i=listp->entry[j=1];j<=listp->last_entry; i=listp->entry[++j]) *************** *** 1565,1588 **** #else for (i = highest_fd; i >= 0; i--) #endif ! { if (!(cptr = local[i])) continue; if (IsLog(cptr)) continue; if (DoingAuth(cptr)) ! { auth++; Debug((DEBUG_NOTICE,"auth on %x %d", cptr, i)); FD_SET(cptr->authfd, &read_set); if (cptr->flags & FLAGS_WRAUTH) FD_SET(cptr->authfd, &write_set); ! } if (DoingDNS(cptr) || DoingAuth(cptr)) continue; if (IsMe(cptr) && IsListening(cptr)) ! { #define CONNECTFAST #ifdef CONNECTFAST /* next line was 2, changing to 1 */ /* if we dont have many clients just let em on */ --- 1558,1584 ---- #else for (i = highest_fd; i >= 0; i--) #endif ! { if (!(cptr = local[i])) continue; if (IsLog(cptr)) continue; if (DoingAuth(cptr)) ! { auth++; Debug((DEBUG_NOTICE,"auth on %x %d", cptr, i)); FD_SET(cptr->authfd, &read_set); if (cptr->flags & FLAGS_WRAUTH) FD_SET(cptr->authfd, &write_set); ! } if (DoingDNS(cptr) || DoingAuth(cptr)) continue; if (IsMe(cptr) && IsListening(cptr)) ! { ! #ifdef SOL20 #define CONNECTFAST + #endif + #ifdef CONNECTFAST /* next line was 2, changing to 1 */ /* if we dont have many clients just let em on */ *************** *** 1589,1596 **** /* This is VERY bad if someone tries to send a lot of clones to the server though, as mbuf's can't be allocated quickly enough... - Comstud */ ! if ((highest_fd < MAXCONNECTIONS /2 ) || ! (NOW > cptr->lasttime + 1)) #else if (NOW > (cptr->lasttime + 2)) #endif --- 1585,1591 ---- /* This is VERY bad if someone tries to send a lot of clones to the server though, as mbuf's can't be allocated quickly enough... - Comstud */ ! if (1==1) #else if (NOW > (cptr->lasttime + 2)) #endif *************** *** 1597,1621 **** FD_SET(i, &read_set); else if (delay2 > 2) delay2 = 2; ! } else if (!IsMe(cptr)) ! { if (DBufLength(&cptr->recvQ) && delay2 > 2) delay2 = 1; if (DBufLength(&cptr->recvQ) < 4088) FD_SET(i, &read_set); ! } if (DBufLength(&cptr->sendQ) || IsConnecting(cptr)) #ifndef pyr FD_SET(i, &write_set); #else ! { if (!(cptr->flags & FLAGS_BLOCKED)) FD_SET(i, &write_set); else delay2 = 0, usec = 500000; ! } if (now - cptr->lw.tv_sec && nowt.tv_usec - cptr->lw.tv_usec < 0) us = 1000000; --- 1592,1616 ---- FD_SET(i, &read_set); else if (delay2 > 2) delay2 = 2; ! } else if (!IsMe(cptr)) ! { if (DBufLength(&cptr->recvQ) && delay2 > 2) delay2 = 1; if (DBufLength(&cptr->recvQ) < 4088) FD_SET(i, &read_set); ! } if (DBufLength(&cptr->sendQ) || IsConnecting(cptr)) #ifndef pyr FD_SET(i, &write_set); #else ! { if (!(cptr->flags & FLAGS_BLOCKED)) FD_SET(i, &write_set); else delay2 = 0, usec = 500000; ! } if (now - cptr->lw.tv_sec && nowt.tv_usec - cptr->lw.tv_usec < 0) us = 1000000; *************** *** 1625,1631 **** if (us - cptr->lw.tv_usec > 500000) cptr->flags &= ~FLAGS_BLOCKED; #endif ! } if (udpfd >= 0) FD_SET(udpfd, &read_set); --- 1620,1626 ---- if (us - cptr->lw.tv_usec > 500000) cptr->flags &= ~FLAGS_BLOCKED; #endif ! } /* for(res=0;;) */ if (udpfd >= 0) FD_SET(udpfd, &read_set); *************** *** 1644,1693 **** return -1; else if (nfds >= 0) break; ! report_error("select %s:%s", &me); res++; ! if (res > 5) restart("too many select errors"); sleep(10); } - if (udpfd >= 0 && FD_ISSET(udpfd, &read_set)) ! { polludp(); nfds--; FD_CLR(udpfd, &read_set); ! } if (resfd >= 0 && FD_ISSET(resfd, &read_set)) ! { do_dns_async(); nfds--; FD_CLR(resfd, &read_set); ! } ! /* ! * Check fd sets for the auth fd's (if set and valid!) first ! * because these can not be processed using the normal loops below. ! * -avalon ! */ ! ! for (i = highest_fd; (auth > 0) && (i >= 0); i--) ! { ! if (!(cptr = local[i])) ! continue; ! if (cptr->authfd < 0) ! continue; ! auth--; ! if ((nfds > 0) && FD_ISSET(cptr->authfd, &write_set)) ! { ! nfds--; ! send_authports(cptr); ! } ! else if ((nfds > 0) && FD_ISSET(cptr->authfd, &read_set)) ! { ! nfds--; ! read_authports(cptr); ! } ! } #ifdef DOG3 for (i=listp->entry[j=1];j <= listp->last_entry; i=listp->entry[++j]) --- 1639,1668 ---- return -1; else if (nfds >= 0) break; ! if (res < 3) ! report_error("select %s:%s", &me); ! else if (res == 3) ! report_error("select %s:%s (last one being reported)", ! &me); res++; ! if (res > 20) restart("too many select errors"); sleep(10); } if (udpfd >= 0 && FD_ISSET(udpfd, &read_set)) ! { polludp(); nfds--; FD_CLR(udpfd, &read_set); ! } if (resfd >= 0 && FD_ISSET(resfd, &read_set)) ! { do_dns_async(); nfds--; FD_CLR(resfd, &read_set); ! } ! if (nfds) #ifdef DOG3 for (i=listp->entry[j=1];j <= listp->last_entry; i=listp->entry[++j]) *************** *** 1694,1704 **** #else for (i = highest_fd; i >= 0; i--) #endif ! if ((cptr = local[i]) && FD_ISSET(i, &read_set) && ! IsListening(cptr)) ! { FD_CLR(i, &read_set); - nfds--; cptr->lasttime = NOW; /* ** There may be many reasons for error return, but --- 1669,1689 ---- #else for (i = highest_fd; i >= 0; i--) #endif ! { ! if (!(cptr=local[i])) ! continue; ! if ((auth>0) && DoingAuth(cptr)) ! { ! auth--; ! if (FD_ISSET(cptr->authfd, &read_set)) ! read_authports(cptr); ! else if (FD_ISSET(cptr->authfd, &write_set)) ! send_authports(cptr); ! continue; ! } ! if (FD_ISSET(i, &read_set) && IsListening(cptr)) ! { FD_CLR(i, &read_set); cptr->lasttime = NOW; /* ** There may be many reasons for error return, but *************** *** 1712,1725 **** ** be accepted until some old is closed first. */ if ((fd = accept(i, NULL, NULL)) < 0) ! { report_error("Cannot accept connections %s:%s", cptr); ! break; ! } ircstp->is_ac++; if (fd >= MAXCLIENTS) ! { ircstp->is_ref++; sendto_ops("All connections in use. (%s)", get_client_name(cptr, TRUE)); --- 1697,1715 ---- ** be accepted until some old is closed first. */ if ((fd = accept(i, NULL, NULL)) < 0) ! { ! #ifdef SOL20 ! /* If a connection is closed before the accept(), it ! returns EPROTO on Solaris. */ ! if (errno != EPROTO) ! #endif report_error("Cannot accept connections %s:%s", cptr); ! continue; ! } ircstp->is_ac++; if (fd >= MAXCLIENTS) ! { ircstp->is_ref++; sendto_ops("All connections in use. (%s)", get_client_name(cptr, TRUE)); *************** *** 1727,1734 **** "ERROR :All connections in use\r\n", 32, 0); (void)close(fd); ! break; ! } /* * Use of add_connection (which never fails :) meLazy */ --- 1717,1724 ---- "ERROR :All connections in use\r\n", 32, 0); (void)close(fd); ! continue; ! } /* * Use of add_connection (which never fails :) meLazy */ *************** *** 1741,1761 **** nextping = NOW; if (!cptr->acpt) cptr->acpt = &me; - } - - #ifdef DOG3 - for (i=listp->entry[j=1];j<=listp->last_entry; - i=listp->entry[++j]) - #else - for (i = highest_fd; i >= 0; i--) - #endif - { - if (!(cptr = local[i]) || IsMe(cptr)) continue; if (FD_ISSET(i, &write_set)) ! { int write_err = 0; - nfds--; /* ** ...room for writing, empty some queue then... */ --- 1731,1743 ---- nextping = NOW; if (!cptr->acpt) cptr->acpt = &me; continue; + } + if (IsMe(cptr)) + continue; if (FD_ISSET(i, &write_set)) ! { int write_err = 0; /* ** ...room for writing, empty some queue then... */ *************** *** 1764,1796 **** if (!write_err) (void)send_queued(cptr); if (IsDead(cptr) || write_err) ! { deadsocket: if (FD_ISSET(i, &read_set)) - { - nfds--; FD_CLR(i, &read_set); - } (void)exit_client(cptr, cptr, &me, strerror(get_sockerr(cptr))); continue; ! } ! } 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); ! #endif ! if ((length != FLUSH_BUFFER) && IsDead(cptr)) ! goto deadsocket; ! if (!FD_ISSET(i, &read_set) && length > 0) ! continue; ! nfds--; ! readcalls++; ! if (length > 0) ! continue; /* ** ...hmm, with non-blocking sockets we might get --- 1746,1770 ---- if (!write_err) (void)send_queued(cptr); if (IsDead(cptr) || write_err) ! { deadsocket: if (FD_ISSET(i, &read_set)) FD_CLR(i, &read_set); (void)exit_client(cptr, cptr, &me, strerror(get_sockerr(cptr))); continue; ! } ! } length = 1; /* for fall through case */ if (!NoNewLine(cptr) || FD_ISSET(i, &read_set)) length = read_packet(cptr, FD_ISSET(i, &read_set)); ! readcalls++; ! if (length == FLUSH_BUFFER) ! continue; ! if (IsDead(cptr)) ! goto deadsocket; ! if (length > 0) ! continue; /* ** ...hmm, with non-blocking sockets we might get *************** *** 1807,1814 **** /* ** NOTE: if length == -2 then cptr has already been freed! */ ! if (length != -2 && (IsServer(cptr) || IsHandshake(cptr))) ! { if (length == 0) sendto_ops("Server %s closed the connection", get_client_name(cptr,FALSE)); --- 1781,1790 ---- /* ** NOTE: if length == -2 then cptr has already been freed! */ ! if (IsServer(cptr) || IsHandshake(cptr)) ! { ! int connected = NOW - cptr->firsttime; ! if (length == 0) sendto_ops("Server %s closed the connection", get_client_name(cptr,FALSE)); *************** *** 1815,1857 **** else report_error("Lost connection to %s:%s", cptr); ! } ! if (length != FLUSH_BUFFER) ! (void)exit_client(cptr, cptr, &me, length >= 0 ? ! "EOF From client" : ! strerror(get_sockerr(cptr))); ! } 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 ) { \ --- 1791,1817 ---- else report_error("Lost connection to %s:%s", cptr); ! sendto_ops("%s had been connected for %d day%s, %2d:%02d:%02d", ! cptr->name, ! connected/86400, ! (connected/86400 == 1) ? "" : "s", ! (connected % 86400) / 3600, ! (connected % 3600) / 60, ! connected % 60); ! } ! (void)exit_client(cptr, cptr, &me, length >= 0 ? ! "EOF From client" : strerror(get_sockerr(cptr))); ! } return 0; } #else /* USE_POLL */ ! #define POLLREADFLAGS POLLRDNORM ! #define POLLWRITEFLAGS POLLWRNORM ! #define PFD_SETR( thisfd ){ CHECK_PFD( thisfd );\ pfd->events |= POLLREADFLAGS;} ! #define PFD_SETW( thisfd ){ CHECK_PFD( thisfd );\ pfd->events |= POLLWRITEFLAGS;} #define CHECK_PFD( thisfd ) \ if ( pfd->fd != thisfd ) { \ *************** *** 1860,1883 **** 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; --- 1820,1858 ---- pfd->events = 0; \ } + #ifdef DOG3 + + int read_message(delay, listp) + time_t delay; + fdlist *listp; + #else + int read_message(delay) + 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 + */ + #endif + { + Reg1 aClient *cptr; + Reg2 int nfds; + struct timeval wait; #ifdef pyr struct timeval nowt; u_long us; + time_t now; #endif pollfd_t poll_fdarray[MAXCONNECTIONS]; pollfd_t * pfd = poll_fdarray; pollfd_t * res_pfd = NULL; pollfd_t * udp_pfd = NULL; ! int nbr_pfds = 0; ! fd_set read_set, write_set; ! time_t delay2 = delay; ! u_long usec = 0; ! int res, length, fd, newfd; ! int auth, rr, rw; ! register int i; ! aClient *authclnts[MAXCONNECTIONS]; #ifdef DOG3 register int j; *************** *** 1885,1967 **** 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 --- 1860,1952 ---- if (!listp) { listp = &default_fdlist; ! listp->last_entry = highest_fd+1; /* remember the 0th entry isnt used */ } #endif #ifdef NPATH ! check_command(&delay, NULL); #endif #ifdef pyr (void) gettimeofday(&nowt, NULL); ! now = nowt.tv_sec; #endif for (res = 0;;) ! { nbr_pfds = 0; pfd = poll_fdarray; pfd->fd = -1; res_pfd = NULL; udp_pfd = NULL; + auth = 0; ! #ifdef DOG3 ! for (i=listp->entry[j=1];j<=listp->last_entry; i=listp->entry[++j]) + #else + for (i = highest_fd; i >= 0; i--) #endif ! { ! if (!(cptr = local[i])) continue; ! if (IsLog(cptr)) ! continue; if (DoingAuth(cptr)) ! { ! if (auth == 0) bzero( (char *)&authclnts, ! sizeof(authclnts) ); auth++; ! Debug((DEBUG_NOTICE,"auth on %x %d", cptr, i)); ! PFD_SETR(cptr->authfd); if (cptr->flags & FLAGS_WRAUTH) ! PFD_SETW(cptr->authfd); authclnts[cptr->authfd] = cptr; ! } if (DoingDNS(cptr) || DoingAuth(cptr)) continue; ! if (IsMe(cptr) && IsListening(cptr)) ! { ! #ifdef SOL20 ! #define CONNECTFAST ! #endif ! #ifdef CONNECTFAST ! /* next line was 2, changing to 1 */ ! /* if we dont have many clients just let em on */ ! /* This is VERY bad if someone tries to send a lot ! of clones to the server though, as mbuf's can't ! be allocated quickly enough... - Comstud */ ! if (1==1) ! #else ! if (NOW > (cptr->lasttime + 2)) ! #endif ! { ! PFD_SETR(i); ! } else if (delay2 > 2) delay2 = 2; ! } ! else if (!IsMe(cptr)) ! { if (DBufLength(&cptr->recvQ) && delay2 > 2) delay2 = 1; if (DBufLength(&cptr->recvQ) < 4088) ! PFD_SETR(i); ! } if (DBufLength(&cptr->sendQ) || IsConnecting(cptr)) #ifndef pyr ! PFD_SETW(i); #else ! { if (!(cptr->flags & FLAGS_BLOCKED)) ! PFD_SETW(i); else delay2 = 0, usec = 500000; ! } ! if (now - cptr->lw.tv_sec && nowt.tv_usec - cptr->lw.tv_usec < 0) us = 1000000; else *************** *** 1970,1997 **** 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) --- 1955,1976 ---- if (us - cptr->lw.tv_usec > 500000) cptr->flags &= ~FLAGS_BLOCKED; #endif ! } if (udpfd >= 0) ! { ! PFD_SETR(udpfd); ! udp_pfd = pfd; ! } if (resfd >= 0) ! { ! PFD_SETR(resfd); ! res_pfd = pfd; ! } wait.tv_sec = MIN(delay2, delay); wait.tv_usec = usec; ! 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) *************** *** 2000,2065 **** res++; if (res > 5) restart("too many poll errors"); ! usleep(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 --- 1979,2031 ---- res++; if (res > 5) restart("too many poll errors"); ! sleep(10); } ! #define POLLREADORERRFLAGS (POLLREADFLAGS|POLLERR|POLLHUP) ! #define POLLWRITEORERRFLAGS (POLLWRITEFLAGS|POLLERR|POLLHUP) ! if (udp_pfd && (udp_pfd->revents & POLLREADORERRFLAGS)) ! { polludp(); nfds--; ! } ! if (res_pfd && (res_pfd->revents & POLLREADORERRFLAGS)) ! { ! do_dns_async(); ! nfds--; ! } ! for (pfd = poll_fdarray, i = 0;(nfds > 0) && (i < nbr_pfds); ! i++, pfd++) ! { ! if (!pfd->revents) ! continue; ! if ((pfd == udp_pfd) || (pfd == res_pfd)) ! continue; ! nfds--; ! fd = pfd->fd; ! rr = pfd->revents & POLLREADFLAGS; ! rw = pfd->revents & POLLWRITEFLAGS; ! if (pfd->revents & (POLLERR|POLLHUP)) ! { ! if (pfd->events & POLLREADFLAGS) ! rr++; ! if (pfd->events & POLLWRITEFLAGS) ! rw++; ! } ! if ((auth>0) && ((cptr=authclnts[fd]) != NULL) && ! (cptr->authfd == fd)) ! { auth--; ! if (rr) read_authports(cptr); + if (rw) + send_authports(cptr); continue; } ! if (!(cptr = local[fd])) continue; ! if (rr && IsListening(cptr)) ! { ! rr = 0; cptr->lasttime = NOW; /* ** There may be many reasons for error return, but *************** *** 2072,2094 **** ** 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 --- 2038,2065 ---- ** point, just assume that connections cannot ** be accepted until some old is closed first. */ ! if ((newfd = accept(fd, NULL, NULL)) < 0) { + #ifdef SOL20 + /* If a connection is closed before the accept(), it + returns EPROTO on Solaris. */ + if (errno != EPROTO) + #endif report_error("Cannot accept connections %s:%s", cptr); ! break; } ircstp->is_ac++; ! if (newfd >= MAXCLIENTS) { ircstp->is_ref++; sendto_ops("All connections in use. (%s)", get_client_name(cptr, TRUE)); ! (void)send(newfd, "ERROR :All connections in use\r\n", 32, 0); ! (void)close(newfd); ! break; } /* * Use of add_connection (which never fails :) meLazy *************** *** 2095,2115 **** */ #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... --- 2066,2084 ---- */ #ifdef UNIXPORT if (IsUnixSocket(cptr)) ! add_unixconnection(cptr, newfd); else #endif ! (void)add_connection(cptr, newfd); nextping = NOW; + if (!cptr->acpt) + cptr->acpt = &me; + continue; + } + if (IsMe(cptr)) continue; ! if (rw) ! { int write_err = 0; /* ** ...room for writing, empty some queue then... *************** *** 2119,2158 **** 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 --- 2088,2112 ---- 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) || rr) ! length = read_packet(cptr, rr); ! readcalls++; ! if (length == FLUSH_BUFFER) ! continue; ! if (IsDead(cptr)) ! goto deadsocket; ! if (length > 0) ! continue; /* ** ...hmm, with non-blocking sockets we might get ** here from quite valid reasons, although.. why ** would select report "data available" when there *************** *** 2162,2194 **** ** 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; } --- 2116,2144 ---- ** for reading even though it ends up being an EOF. -avalon */ Debug((DEBUG_ERROR, "READ ERROR: fd = %d %d %d", ! fd, errno, length)); if (IsServer(cptr) || IsHandshake(cptr)) ! { ! int connected = NOW - cptr->firsttime; if (length == 0) ! sendto_ops("Server %s closed the connection", ! get_client_name(cptr,FALSE)); ! else ! report_error("Lost connection to %s:%s", ! cptr); ! sendto_ops("%s had been connected for %d day%s, %2d:%02d:%02d", ! cptr->name, ! connected/86400, ! (connected/86400 == 1) ? "" : "s", ! (connected % 86400) / 3600, ! (connected % 3600) / 60, ! connected % 60); ! } (void)exit_client(cptr, cptr, &me, length >= 0 ? ! "EOF From client" : ! strerror(get_sockerr(cptr))); } return 0; } *************** *** 2196,2201 **** --- 2146,2153 ---- #endif /* USE_POLL */ + + /* * connect_server */ *************** *** 2736,2746 **** */ if (!mlen) { - #ifndef MAXBUFFERS - mlen = sizeof(readbuf) - strlen(me.name) - strlen(PATCHLEVEL); - #else mlen = rcvbufmax*sizeof(char) - strlen(me.name) - strlen(PATCHLEVEL); - #endif mlen -= 6; if (mlen < 0) mlen = 0; --- 2688,2694 ---- *************** *** 2747,2753 **** } Debug((DEBUG_DEBUG,"udp poll")); ! n = recvfrom(udpfd, readbuf, mlen, 0, &from, &fromlen); if (NOW == last) if (++cnt > 14) return; --- 2695,2701 ---- } Debug((DEBUG_DEBUG,"udp poll")); ! n = recvfrom(udpfd, readbuf, mlen, 0, (struct sockaddr *)&from, &fromlen); if (NOW == last) if (++cnt > 14) return; *************** *** 2777,2783 **** s += strlen(s)+1; (void)strcpy(s, PATCHLEVEL); s += strlen(s); ! (void)sendto(udpfd, readbuf, s-readbuf, 0, &from ,sizeof(from)); return; } --- 2725,2731 ---- s += strlen(s)+1; (void)strcpy(s, PATCHLEVEL); s += strlen(s); ! (void)sendto(udpfd, readbuf, s-readbuf, 0, (struct sockaddr *)&from ,sizeof(from)); return; } diff -c -r irc2.8.21+CSr25/ircd/s_conf.c irc2.8.21+CSr27/ircd/s_conf.c *** irc2.8.21+CSr25/ircd/s_conf.c Mon Sep 9 18:42:09 1996 --- irc2.8.21+CSr27/ircd/s_conf.c Wed Oct 9 15:08:19 1996 *************** *** 158,165 **** goto attach_iline; continue; attach_iline: - if (index(uhost, '@')) - cptr->flags |= FLAGS_DOID; get_sockhost(cptr, uhost); return attach_conf(cptr, aconf); } --- 158,163 ---- *************** *** 716,723 **** --- 714,748 ---- return open(filename, O_RDONLY); #endif } + extern char *getfield(); + char *set_conf_flags(aconf, tmp) + aConfItem *aconf; + char *tmp; + { + while(strchr("!-+#", *tmp)) + { + switch(*tmp) + { + case '!': + aconf->flags |= FLAGS_LIMIT_IP; + break; + case '-': + aconf->flags |= FLAGS_NO_TILDE; + break; + case '+': + aconf->flags |= FLAGS_NEED_IDENTD; + break; + case '#': + aconf->flags |= FLAGS_PASS_IDENTD; + break; + } + tmp++; + } + return tmp; + } + /* ** initconf() ** Read configuration file. *************** *** 900,905 **** --- 925,932 ---- { if ((tmp = getfield(NULL)) == NULL) break; + if (aconf->status & CONF_CLIENT) + tmp = set_conf_flags(aconf, tmp); DupString(aconf->host, tmp); if ((tmp = getfield(NULL)) == NULL) break; *************** *** 906,911 **** --- 933,940 ---- DupString(aconf->passwd, tmp); if ((tmp = getfield(NULL)) == NULL) break; + if (aconf->status & CONF_CLIENT) + tmp = set_conf_flags(aconf, tmp); DupString(aconf->name, tmp); if ((tmp = getfield(NULL)) == NULL) break; *************** *** 950,955 **** --- 979,985 ---- bconf->class->links -= bconf->clients; bconf->class = aconf->class; bconf->class->links += bconf->clients; + bconf->flags = aconf->flags; } free_conf(aconf); aconf = bconf; *************** *** 1181,1188 **** if (tmp->status == CONF_KILL) if (!match(name,kuser) && !match(host,khost)) { sendto_one(sptr, ":%s NOTICE %s :K: line not added. %s@%s already matched by %s@%s", me.name, sptr->name, kuser, khost, name, host ); ! return 1; } } } --- 1211,1219 ---- if (tmp->status == CONF_KILL) if (!match(name,kuser) && !match(host,khost)) { + if (MyClient(sptr)) sendto_one(sptr, ":%s NOTICE %s :K: line not added. %s@%s already matched by %s@%s", me.name, sptr->name, kuser, khost, name, host ); ! return 1; } } } *************** *** 1191,1205 **** #endif ! int find_kill(cptr, checkuh) aClient *cptr; int checkuh; { char reply[256], *host, *name; aConfItem *tmp; char *rev; aConfList *list; #ifdef E_LINES if (find_eline(cptr)) return 0; --- 1222,1241 ---- #endif ! int find_kill(cptr, checkuh, reason) aClient *cptr; int checkuh; + char **reason; { char reply[256], *host, *name; aConfItem *tmp; char *rev; aConfList *list; + static char toomany[100] = "Over the limit of number of clients allowed"; + static char klined[20] = "K-lined"; + if (reason) + *reason = klined; #ifdef E_LINES if (find_eline(cptr)) return 0; *************** *** 1294,1302 **** register int i; int num = 0, tot; int cc = get_client_class(cptr); aClass *cs; ! cs = find_class(cc); tot = get_con_freq(cs); if (tot) for (i = highest_fd; i >= 0; i--) --- 1330,1340 ---- register int i; int num = 0, tot; int cc = get_client_class(cptr); + aConfItem *aconf; aClass *cs; ! aconf = cptr->confs->value.aconf; ! cs = aconf->class; tot = get_con_freq(cs); if (tot) for (i = highest_fd; i >= 0; i--) *************** *** 1303,1312 **** { if (!(sptr=local[i]) || !IsPerson(sptr)) continue; ! if (cc != get_client_class(sptr)) continue; ! if (!strcmp(sptr->user->username, name) && ! !strcmp(sptr->sockhost, host)) if (++num >= tot) { sendto_one(cptr, ":%s NOTICE %s :This server is currently limited to %i client%s per user in your class", --- 1341,1351 ---- { if (!(sptr=local[i]) || !IsPerson(sptr)) continue; ! if (cs != sptr->confs->value.aconf->class) continue; ! if ((IsLimitIp(aconf) || ! !strcmp(sptr->user->username, name)) && ! sptr->ip.s_addr == cptr->ip.s_addr) if (++num >= tot) { sendto_one(cptr, ":%s NOTICE %s :This server is currently limited to %i client%s per user in your class", *************** *** 1313,1327 **** me.name, cptr->name, tot, tot==1?"":"s"); sendto_flagops(LMODE, "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); - } - int find_conf_match(cptr, List1, List2, List3) aClient *cptr; aConfList *List1; --- 1352,1373 ---- me.name, cptr->name, tot, tot==1?"":"s"); sendto_flagops(LMODE, "Rejecting for too many clients: %s [%s@%s]", cptr->name, cptr->user->username, cptr->user->host); + if (reason) + *reason = toomany; return 1; } } } #endif /* LIMIT_UH */ + if (tmp) + { + if (reason) + *reason = tmp->passwd ? tmp->passwd : klined; + return -1; + } + return 0; + } int find_conf_match(cptr, List1, List2, List3) aClient *cptr; aConfList *List1; diff -c -r irc2.8.21+CSr25/ircd/s_err.c irc2.8.21+CSr27/ircd/s_err.c *** irc2.8.21+CSr25/ircd/s_err.c Mon Sep 9 15:14:37 1996 --- irc2.8.21+CSr27/ircd/s_err.c Wed Sep 25 20:12:36 1996 *************** *** 246,252 **** /* 212 */ RPL_STATSCOMMANDS, "%s %u %u", /* 213 */ RPL_STATSCLINE, "%c %s * %s %d %d", /* 214 */ RPL_STATSNLINE, "%c %s * %s %d %d", ! /* 215 */ RPL_STATSILINE, "%c %s * %s %d %d", /* 216 */ RPL_STATSKLINE, "%c %s %s %s %d %d", /* 217 */ RPL_STATSQLINE, "%c %s * %s %d %d", /* 218 */ RPL_STATSYLINE, "%c %d %d %d %d %ld", --- 246,252 ---- /* 212 */ RPL_STATSCOMMANDS, "%s %u %u", /* 213 */ RPL_STATSCLINE, "%c %s * %s %d %d", /* 214 */ RPL_STATSNLINE, "%c %s * %s %d %d", ! /* 215 */ RPL_STATSILINE, "%c %s * %s%s %d %d", /* 216 */ RPL_STATSKLINE, "%c %s %s %s %d %d", /* 217 */ RPL_STATSQLINE, "%c %s * %s %d %d", /* 218 */ RPL_STATSYLINE, "%c %d %d %d %d %ld", *************** *** 290,296 **** /* 259 */ RPL_ADMINEMAIL, ":%s", 0, (char *)NULL, /* 261 */ RPL_TRACELOG, "File %s %d", ! 0, (char *)NULL, #ifdef DOG3 /* 263 */ RPL_LOAD2HI, ":Server load too high, try again in a while" #else --- 290,296 ---- /* 259 */ RPL_ADMINEMAIL, ":%s", 0, (char *)NULL, /* 261 */ RPL_TRACELOG, "File %s %d", ! /* 262 */ RPL_ENDOFTRACE, "%s :End of /TRACE list.", #ifdef DOG3 /* 263 */ RPL_LOAD2HI, ":Server load too high, try again in a while" #else diff -c -r irc2.8.21+CSr25/ircd/s_misc.c irc2.8.21+CSr27/ircd/s_misc.c *** irc2.8.21+CSr25/ircd/s_misc.c Sun Sep 15 15:25:33 1996 --- irc2.8.21+CSr27/ircd/s_misc.c Mon Nov 11 20:16:16 1996 *************** *** 211,222 **** else { if (showip) ! (void)irc_sprintf(nbuf, "%s[%s@%s.%u]", sptr->name, (!(sptr->flags & FLAGS_GOTID)) ? "" : sptr->username, ! inetntoa((char *)&sptr->ip), ! (unsigned int)sptr->port); else { if (mycmp(sptr->name, sptr->sockhost)) --- 211,221 ---- else { if (showip) ! (void)irc_sprintf(nbuf, "%s[%s@%s]", sptr->name, (!(sptr->flags & FLAGS_GOTID)) ? "" : sptr->username, ! inetntoa((char *)&sptr->ip)); else { if (mycmp(sptr->name, sptr->sockhost)) diff -c -r irc2.8.21+CSr25/ircd/s_serv.c irc2.8.21+CSr27/ircd/s_serv.c *** irc2.8.21+CSr25/ircd/s_serv.c Wed Sep 11 20:00:56 1996 --- irc2.8.21+CSr27/ircd/s_serv.c Mon Nov 11 20:16:33 1996 *************** *** 184,189 **** --- 184,199 ---- #ifdef DOG3 + int m_htm(cptr, sptr, parc, parv) + aClient *cptr, *sptr; + int parc; + char *parv[]; + { + sendto_one(sptr, ":%s NOTICE %s :The incoming rate is %0.2f kb/s", + me.name, parv[0], currentrate); + return 0; + } + int m_dog3freq(cptr, sptr, parc, parv) aClient *cptr, *sptr; int parc; *************** *** 1284,1289 **** --- 1294,1300 ---- aConfItem *tmp; int *p, port; char c, *host, *pass, *name; + char string[10]; for (tmp = conf; tmp; tmp = tmp->next) if (tmp->status & mask) *************** *** 1298,1303 **** --- 1309,1323 ---- pass = BadPtr(tmp->passwd) ? null : tmp->passwd; name = BadPtr(tmp->name) ? null : tmp->name; port = (int)tmp->port; + *string = (char) 0; + if (IsNoTilde(tmp)) + strcat(string, "-"); + if (IsLimitIp(tmp)) + strcat(string, "!"); + if (IsNeedIdentd(tmp)) + strcat(string, "+"); + if (IsPassIdentd(tmp)) + strcat(string, "#"); /* * On K line the passwd contents can be /* displayed on STATS reply. -Vesa *************** *** 1306,1315 **** sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, pass, name, port, get_conf_class(tmp)); else sendto_one(sptr, rpl_str(p[1]), me.name, ! sptr->name, c, host, name, port, ! get_conf_class(tmp)); } return; } --- 1326,1340 ---- sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, pass, name, port, get_conf_class(tmp)); + else if (mask == CONF_CLIENT) + sendto_one(sptr, rpl_str(p[1]), me.name, + sptr->name, c, host, string, + name, port, + get_conf_class(tmp)); else sendto_one(sptr, rpl_str(p[1]), me.name, ! sptr->name, c, host, name, port, ! get_conf_class(tmp)); } return; } *************** *** 1322,1332 **** static char Lformat[] = ":%s %d %s %s %u %u %u %u %u :%u"; static char CSformat[] = ":%s %d %s %s %u %u %u %u %u %u :%s"; struct Message *mptr; ! 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)) return 0; --- 1347,1358 ---- static char Lformat[] = ":%s %d %s %s %u %u %u %u %u :%u"; static char CSformat[] = ":%s %d %s %s %u %u %u %u %u %u :%s"; struct Message *mptr; ! aClient *acptr, *tmpptr; char stat = parc > 1 ? parv[1][0] : '\0'; Reg1 int i; ! int doall = 0, wilds = 0, j, num = 0; ! char *name, *user, *host; ! char buffer[512]; if (check_registered(sptr)) return 0; *************** *** 1333,1342 **** if (hunt_server(cptr,sptr,":%s STATS %s :%s",2,parc,parv)!=HUNTED_ISME) return 0; ! ! if (parc > 2) ! { ! name = parv[2]; if (!mycmp(name, me.name)) doall = 2; else if (matches(name, me.name) == 0) --- 1359,1373 ---- if (hunt_server(cptr,sptr,":%s STATS %s :%s",2,parc,parv)!=HUNTED_ISME) return 0; ! if (parc < 2) ! { ! sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), ! me.name, parv[0], "TOPIC"); ! return 0; ! } ! if (parc > 3) ! { ! name = parv[3]; if (!mycmp(name, me.name)) doall = 2; else if (matches(name, me.name) == 0) *************** *** 1343,1359 **** doall = 1; if (index(name, '*') || index(name, '?')) wilds = 1; ! } else name = me.name; #ifdef STATS_NOTICE ! if (stat != (char) 0) sendto_flagops(OPERS,"STATS %c requested by %s (%s@%s)", stat, sptr->name, sptr->user->username, sptr->user->host); #endif switch (stat) { case '?': #ifndef DOG3 for(i=0;i<=highest_fd;i++) { --- 1374,1414 ---- doall = 1; if (index(name, '*') || index(name, '?')) wilds = 1; ! } else + { name = me.name; + if (parc > 2) + doall = 2; + } #ifdef STATS_NOTICE ! if ((stat != (char) 0) && sptr->user) sendto_flagops(OPERS,"STATS %c requested by %s (%s@%s)", stat, sptr->name, sptr->user->username, sptr->user->host); #endif + + #define Meg 1024 + #define Gig (Meg*1024) + #define Tera (Gig*1024) + #define IsMeg(x) (x>Meg) + #define IsGig(x) (x>Gig) + #define IsTera(x) (x>Tera) + #define ByteString(x) (IsTera(x) ? "terabytes" : \ + IsGig(x) ? "gigabytes" : \ + IsMeg(x) ? "megabytes" : \ + "Kilobytes") + #define ByteConvert(x) (IsTera(x) ? (float)((float)x/(float)Tera) : \ + IsGig(x) ? (float)((float)x/(float)Gig) : \ + IsMeg(x) ? (float)((float)x/(float)Meg) : \ + (float)x) + switch (stat) { case '?': + { + int tottime = 0; + long int totsent = 0, totrecv = 0, totsentb = 0, totrecvb = 0; + int uptime = NOW - me.firsttime; #ifndef DOG3 for(i=0;i<=highest_fd;i++) { *************** *** 1374,1381 **** --- 1429,1478 ---- (int)acptr->receiveM, (int)acptr->receiveK, NOW - acptr->firsttime, DoesTS(acptr) ? "TS" : "NoTS"); + tottime += (NOW - acptr->firsttime); + totsent += acptr->sendK; + totrecv += acptr->receiveK; + totsentb += acptr->sendB; + totrecvb += acptr->receiveB; + if (totsentb > 1023) + { + totsent += (totsentb >> 10); + totsentb &= 0x3ff; + } + if (totrecvb > 1023) + { + totrecv += (totrecvb >> 10); + totrecvb &= 0x3ff; + } } + if (uptime) + { + sendto_one(sptr, ":%s %d %s :Since startup, I've:", + me.name, RPL_STATSDEBUG, parv[0]); + sendto_one(sptr, ":%s %d %s :Sent a total of %0.3f %s at a rate of %0.2f kilobytes per second.", + me.name, RPL_STATSDEBUG, parv[0], + ByteConvert(me.sendK), ByteString(me.sendK), + (float)((float)me.sendK/(float)uptime)); + sendto_one(sptr, ":%s %d %s :Received a total of %0.3f %s at a rate of %0.2f kilobytes per second.", + me.name, RPL_STATSDEBUG, parv[0], + ByteConvert(me.receiveK), ByteString(me.receiveK), + (float)((float)me.receiveK/(float)uptime)); + } + if (tottime) + { + sendto_one(sptr, ":%s %d %s :The current averages for servers:", + me.name, RPL_STATSDEBUG, parv[0]); + sendto_one(sptr, ":%s %d %s :Sent a total of %0.3f %s at a rate of %0.2f kilobytes per second.", + me.name, RPL_STATSDEBUG, parv[0], + ByteConvert(totsent), ByteString(totsent), + (float)((float)totsent/(float)tottime)); + sendto_one(sptr, ":%s %d %s :Received a total of %0.3f %s at a rate of %0.2f kilobytes per second.", + me.name, RPL_STATSDEBUG, parv[0], + ByteConvert(totrecv), ByteString(totrecv), + (float)((float)totrecv/(float)tottime)); + } break; + } case 'L' : case 'l' : /* * send info about connections which match, or all if the *************** *** 1383,1388 **** --- 1480,1505 ---- * are invisible not being visible to 'foreigners' who use * a wild card based search to list it. */ + acptr = NULL; + if (parc > 2) + acptr = find_chasing(NULL, parv[2], NULL); + if (acptr && IsPerson(acptr)) + { + gohere: + if (MyConnect(acptr)) + sendto_one(sptr, Lformat, me.name, RPL_STATSLINKINFO, + parv[0], isupper(stat) ? + get_client_name(acptr, TRUE) : + get_client_name(acptr, FALSE), + (int)DBufLength(&cptr->sendQ), + (int)acptr->sendM, (int)acptr->sendK, + (int)acptr->receiveM, (int)acptr->receiveK, + NOW - acptr->firsttime); + break; + } + acptr = find_chasing(NULL, me.name, NULL); + if (acptr && IsPerson(acptr)) + goto gohere; for (i = 0; i <= highest_fd; i++) { if (!(acptr = local[i])) *************** *** 1408,1417 **** break; #ifdef B_LINES case 'B' : case 'b' : ! report_conf_links(sptr, &BList1, RPL_STATSBLINE, 'B'); ! report_conf_links(sptr, &BList2, RPL_STATSBLINE, 'B'); ! report_conf_links(sptr, &BList3, RPL_STATSBLINE, 'B'); ! break; #endif case 'C' : case 'c' : report_configured_links(sptr, CONF_CONNECT_SERVER| --- 1525,1537 ---- break; #ifdef B_LINES case 'B' : case 'b' : ! report_conf_links(sptr, &BList1, RPL_STATSBLINE, 'B', ! NULL, NULL, NULL); ! report_conf_links(sptr, &BList2, RPL_STATSBLINE, 'B', ! NULL, NULL, NULL); ! report_conf_links(sptr, &BList3, RPL_STATSBLINE, 'B', ! NULL, NULL, NULL); ! break; #endif case 'C' : case 'c' : report_configured_links(sptr, CONF_CONNECT_SERVER| *************** *** 1419,1428 **** break; #ifdef E_LINES case 'E' : case 'e' : ! report_conf_links(sptr, &EList1, RPL_STATSELINE, 'E'); ! report_conf_links(sptr, &EList2, RPL_STATSELINE, 'E'); ! report_conf_links(sptr, &EList3, RPL_STATSELINE, 'E'); ! break; #endif case 'H' : case 'h' : report_configured_links(sptr, CONF_HUB|CONF_LEAF); --- 1539,1551 ---- break; #ifdef E_LINES case 'E' : case 'e' : ! report_conf_links(sptr, &EList1, RPL_STATSELINE, 'E', ! NULL, NULL, NULL); ! report_conf_links(sptr, &EList2, RPL_STATSELINE, 'E', ! NULL, NULL, NULL); ! report_conf_links(sptr, &EList3, RPL_STATSELINE, 'E', ! NULL, NULL, NULL); ! break; #endif case 'H' : case 'h' : report_configured_links(sptr, CONF_HUB|CONF_LEAF); *************** *** 1431,1439 **** report_configured_links(sptr, CONF_CLIENT); break; case 'K' : case 'k' : ! report_conf_links(sptr, &KList1, RPL_STATSKLINE, 'K'); ! report_conf_links(sptr, &KList2, RPL_STATSKLINE, 'K'); ! report_conf_links(sptr, &KList3, RPL_STATSKLINE, 'K'); break; case 'M' : case 'm' : for (mptr = msgtab; mptr->cmd; mptr++) --- 1554,1613 ---- report_configured_links(sptr, CONF_CLIENT); break; case 'K' : case 'k' : ! tmpptr = NULL; ! user = host = NULL; ! #ifdef RESTRICT_STATSK ! if (name == me.name) ! { ! if (!IsAnOper(sptr)) ! tmpptr = sptr; ! ! else ! tmpptr = NULL; ! } ! else if (!strchr(name, '@') && !strchr(name, '.')) ! { ! if (!(tmpptr = find_chasing(sptr, name, NULL))) ! return 0; ! } ! if (!tmpptr && (me.name != name)) ! { ! char *ptr; ! ! strcpy(buffer, name); ! ptr = strchr(buffer, '@'); ! if (!ptr) ! { ! user = "*"; ! host = buffer; ! } ! else ! { ! *ptr = (char) 0; ! user = buffer; ! host = ptr+1; ! } ! } ! if (tmpptr && tmpptr->user) ! { ! user = tmpptr->user->username; ! host = tmpptr->user->host; ! } ! if (user) ! sendto_one(sptr, ":%s NOTICE %s :Finding bans matching %s@%s", ! me.name, parv[0], user, host); ! #endif ! report_conf_links(sptr, &KList1, RPL_STATSKLINE, 'K', ! user, host, &num); ! report_conf_links(sptr, &KList2, RPL_STATSKLINE, 'K', ! user, host, &num); ! report_conf_links(sptr, &KList3, RPL_STATSKLINE, 'K', ! user, host, &num); ! #ifdef RESTRICT_STATSK ! if (!num && user) ! sendto_one(sptr,":%s NOTICE %s :No bans for %s@%s found.", ! me.name, parv[0], user, host); ! #endif break; case 'M' : case 'm' : for (mptr = msgtab; mptr->cmd; mptr++) *************** *** 1612,1618 **** if(hunt_server(cptr, sptr, ":%s LUSERS %s :%s", 2, parc, parv) != HUNTED_ISME) return 0; ! if (parc > 1) { (void)collapse(parv[1]); compute_lusers(parv[1]); --- 1786,1792 ---- if(hunt_server(cptr, sptr, ":%s LUSERS %s :%s", 2, parc, parv) != HUNTED_ISME) return 0; ! if (parc > 3) { (void)collapse(parv[1]); compute_lusers(parv[1]); *************** *** 1983,1988 **** --- 2157,2191 ---- return result; } + #ifdef ALLOW_KLINES_FROM_SERVERS + int rmatches(string, specs) + char *string; + char *specs; + { + char buffer[1024]; + char *ptr, *ptr2; + int ok=1; + + if (!specs || !*specs) + return 1; + strcpy(buffer, specs); + ptr = buffer; + do + { + ptr2 = strchr(ptr, ' '); + if (ptr2) + { + *ptr2 = (char) 0; + ptr2++; + } + ok = matches(ptr, string); + ptr = ptr2; + } while (ok && ptr); + return ok; + } + + #endif /* ALLOW_KLINES_FROM_SERVERS */ + int m_kline(cptr, sptr, parc, parv) aClient *cptr, *sptr; int parc; *************** *** 1990,1996 **** { int out; char buffer[1024]; ! char *user, *host; aClient *acptr; char tempuser[30]; char temphost[512]; --- 2193,2199 ---- { int out; char buffer[1024]; ! char *user, *host, *reason; aClient *acptr; char tempuser[30]; char temphost[512]; *************** *** 2000,2021 **** char *filename; struct tm *tmptr; - if (!MyClient(sptr) || #ifdef NO_LOCAL_KLINE ! !IsOper(sptr)) #else ! !IsAnOper(sptr)) #endif ! { sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); return 0; ! } ! if (!parv[1] || !*parv[1]) { ! sendto_one(sptr, ":%s NOTICE %s :Not enough parameters", ! me.name, parv[0]); return 0; } if (strchr(parv[1], '@') || *parv[1] == '*') { if (strchr(parv[1], '@')) --- 2203,2226 ---- char *filename; struct tm *tmptr; #ifdef NO_LOCAL_KLINE ! if (!IsOper(sptr)) #else ! if (!IsAnOper(sptr)) #endif ! { sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); return 0; ! } ! if (!parv[1] || (!MyClient(sptr) && (!parv[2] || !parv[3]))) { ! if (MyClient(sptr)) ! sendto_one(sptr, ":%s NOTICE %s :Not enough parameters", ! me.name, parv[0]); return 0; } + if (MyClient(sptr)) + { if (strchr(parv[1], '@') || *parv[1] == '*') { if (strchr(parv[1], '@')) *************** *** 2036,2042 **** user = tempuser; host = temphost; } ! else { if (!(acptr = find_chasing(sptr, parv[1], NULL))) return 0; --- 2241,2247 ---- user = tempuser; host = temphost; } ! else /* strchr(...) || ... */ { if (!(acptr = find_chasing(sptr, parv[1], NULL))) return 0; *************** *** 2054,2078 **** user = tempuser; host = cluster(acptr->user->host); } ! #ifdef NO_REDUNDANT_KLINES ! if (test_kline_userhost(sptr, &KList1, user, host) || ! test_kline_userhost(sptr, &KList2, user, host) || ! test_kline_userhost(sptr, &KList3, user, host)) ! return 0; ! #endif if (!matches(user, "akjhfkahfasfjd") && ! !matches(host, "ldksjfl.ksskdjfd.jfklsjf")) { sendto_one(sptr, ":%s NOTICE %s :Can't K-Line *@*", me.name, parv[0]); return 0; } aconf = make_conf(); aconf->status = CONF_KILL; DupString(aconf->host, host); ! if (parv[2]) ! sprintf(buffer, "%s", parv[2]); ! DupString(aconf->passwd, parv[2] ? buffer : ""); DupString(aconf->name, user); aconf->port = 0; Class(aconf) = find_class(0); --- 2259,2307 ---- user = tempuser; host = cluster(acptr->user->host); } ! reason = parv[2]; ! } /* if (MyClient(sptr)) */ ! else ! { ! user = parv[1]; ! host = parv[2]; ! reason = parv[3]; ! } ! reason = (reason && *reason) ? reason : "No reason"; if (!matches(user, "akjhfkahfasfjd") && ! !matches(host, "ldksjfl.kss...kdjfd.jfklsjf")) { sendto_one(sptr, ":%s NOTICE %s :Can't K-Line *@*", me.name, parv[0]); return 0; } + #ifdef PASS_KLINES + sendto_serv_butone(MyClient(sptr) ? NULL : cptr, + ":%s KLINE %s %s :%s", parv[0], user, host, reason); + #endif + #ifdef ALLOW_KLINES_FROM_SERVERS + if (!MyClient(sptr)) + { + if (IsPerson(sptr) && IsOper(sptr) && parv[1] && + *parv[1] && parv[2] && *parv[2] && + !rmatches(sptr->user->server, ALLOWED_KLINES)) + ; + else + return 0; + } + #endif + #ifdef NO_REDUNDANT_KLINES + if (test_kline_userhost(sptr, &KList1, user, host) || + test_kline_userhost(sptr, &KList2, user, host) || + test_kline_userhost(sptr, &KList3, user, host)) + return 0; + #endif aconf = make_conf(); aconf->status = CONF_KILL; DupString(aconf->host, host); ! if (reason) ! sprintf(buffer, "%s", reason); ! DupString(aconf->passwd, reason ? buffer : ""); DupString(aconf->name, user); aconf->port = 0; Class(aconf) = find_class(0); *************** *** 2095,2102 **** MyFree(host); } rehashed = 1; /* Forces looping thru clients to check k-lines */ ! sendto_flagops(OPERS,"%s added K-Line for [%s@%s]: %s", parv[0], user, host, ! parv[2] && *parv[2] ? parv[2] : "No reason"); #ifdef PUT_KLINES_IN_IRCD_CONF filename = configfile; #elif defined(SEPARATE_QUOTE_KLINES_BY_DATE) --- 2324,2336 ---- MyFree(host); } rehashed = 1; /* Forces looping thru clients to check k-lines */ ! if (MyClient(sptr)) ! sendto_flagops(OPERS,"%s added K-Line for [%s@%s]: %s", parv[0], user, ! host, reason && *reason ? reason : "No reason"); ! else ! sendto_flagops(OPERS,"%s from %s added K-Line for [%s@%s]: %s", ! parv[0], sptr->user->server, user, host, ! reason && *reason ? reason:"No reason"); #ifdef PUT_KLINES_IN_IRCD_CONF filename = configfile; #elif defined(SEPARATE_QUOTE_KLINES_BY_DATE) *************** *** 2118,2124 **** irc_sprintf(buffer, "#%s!%s@%s K'd: %s@%s: %s\n", sptr->name, sptr->user->username, sptr->user->host, user, host, ! (parv[2] && *parv[2]) ? parv[2] : "No reason"); if (write(out, buffer, strlen(buffer)) <= 0) { sendto_one(sptr, ":%s NOTICE %s :Problem writing to the configfile", me.name, parv[0]); --- 2352,2358 ---- irc_sprintf(buffer, "#%s!%s@%s K'd: %s@%s: %s\n", sptr->name, sptr->user->username, sptr->user->host, user, host, ! (reason && *reason) ? reason : "No reason"); if (write(out, buffer, strlen(buffer)) <= 0) { sendto_one(sptr, ":%s NOTICE %s :Problem writing to the configfile", me.name, parv[0]); *************** *** 2126,2133 **** return 0; } irc_sprintf(buffer, "K:%s:%s%s:%s\n", host, ! (parv[2] && *parv[2]) ? "" : "", ! (parv[2] && *parv[2]) ? parv[2] : "", user); if (write(out, buffer, strlen(buffer)) <= 0) sendto_one(sptr, ":%s NOTICE %s :Problem writing to the configfile", me.name, parv[0]); close(out); --- 2360,2367 ---- return 0; } irc_sprintf(buffer, "K:%s:%s%s:%s\n", host, ! (reason && *reason) ? "" : "", ! (reason && *reason) ? reason : "", user); if (write(out, buffer, strlen(buffer)) <= 0) sendto_one(sptr, ":%s NOTICE %s :Problem writing to the configfile", me.name, parv[0]); close(out); *************** *** 2138,2143 **** --- 2372,2467 ---- #endif /* QUOTE_KLINE */ + #ifdef SEPARATE_QUOTE_KLINES_BY_DATE + + /* + ** m_rehashadd + ** + */ + int m_rehashadd(cptr, sptr, parc, parv) + aClient *cptr, *sptr; + int parc; + char *parv[]; + { + struct tm *tmptr; + char timebuffer[25]; + char filename[1024]; + + #ifndef LOCOP_REHASH + if (!MyClient(sptr) || !IsOper(sptr)) + #else + # ifdef OPER_REHASH + if (!MyClient(sptr) || !IsAnOper(sptr)) + # else + if (!MyClient(sptr) || !IsLocOp(sptr)) + # endif + #endif + { + sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); + return 0; + } + sendto_one(sptr, rpl_str(RPL_REHASHING), me.name, parv[0], configfile); + sendto_ops("%s is rehashing Server config file", parv[0]); + #ifdef USE_SYSLOG + syslog(LOG_INFO, "REHASHADD From %s\n", get_client_name(sptr, FALSE)); + #endif + (void)rehash(cptr, sptr, (parc > 1) ? ((*parv[1] == 'q')?2:0) : 0); + tmptr = localtime(&NOW); + strftime(timebuffer, 20, "%y%m%d", tmptr); + sprintf(filename, "%s.%s", klinefile, timebuffer); + if (initconf(0,filename)) + sendto_one(sptr,":%s NOTICE %s :There was a problem opening %s", + me.name, parv[0], filename); + else + { + sendto_one(sptr, ":%s NOTICE %s :K-lines were loaded from %s", + me.name, parv[0], filename); + sendto_flagops(OPERS, "%s loaded K-lines from %s", + parv[0], filename); + } + rehashed = 1; + return 0; + } + + /* + ** m_addklines + ** + */ + int m_addklines(cptr, sptr, parc, parv) + aClient *cptr, *sptr; + int parc; + char *parv[]; + { + char buffer[1024]; + + if (!MyClient(sptr) || !IsAnOper(sptr)) + { + sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); + return 0; + } + if (parc < 2 || (!parv[1] || !*parv[1])) + { + sendto_one(sptr, ":%s NOTICE %s :No date given to load", + me.name, parv[0]); + return 0; + } + sprintf(buffer, "%s.%s", KLINEFILE, parv[1]); + sendto_one(sptr, ":%s NOTICE %s :Loading K-lines from %s", me.name, parv[0], buffer); + if (initconf(0,buffer)) + sendto_one(sptr, ":%s NOTICE %s :There was a problem opening the file", me.name, parv[0]); + else + { + sendto_flagops(OPERS, "%s loaded K-lines from %s", + parv[0], buffer); + sendto_one(sptr, ":%s NOTICE %s :K-lines have been loaded", + me.name, parv[0]); + } + rehashed = 1; + return 0; + } + + #endif /* SEPARATE_QUOTE_KLINES_BY_DATE */ + #if defined(OPER_REHASH) || defined(LOCOP_REHASH) /* ** m_rehash *************** *** 2161,2166 **** --- 2485,2493 ---- sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); return 0; } + #ifdef SEPARATE_QUOTE_KLINES_BY_DATE + return m_rehashadd(cptr, sptr, parc, parv); + #else sendto_one(sptr, rpl_str(RPL_REHASHING), me.name, parv[0], configfile); sendto_ops("%s is rehashing Server config file", parv[0]); #ifdef USE_SYSLOG *************** *** 2167,2172 **** --- 2494,2500 ---- syslog(LOG_INFO, "REHASH From %s\n", get_client_name(sptr, FALSE)); #endif return rehash(cptr, sptr, (parc > 1) ? ((*parv[1] == 'q')?2:0) : 0); + #endif } #endif *************** *** 2286,2292 **** if (!(acptr = local[i])) /* Local Connection? */ continue; if (IsInvisible(acptr) && dow && ! !(MyConnect(sptr) && IsOper(sptr)) && !IsAnOper(acptr) && (acptr != sptr)) continue; if (!doall && wilds && matches(tname, acptr->name)) --- 2614,2620 ---- if (!(acptr = local[i])) /* Local Connection? */ continue; if (IsInvisible(acptr) && dow && ! !(MyConnect(sptr) && IsAnOper(sptr)) && !IsAnOper(acptr) && (acptr != sptr)) continue; if (!doall && wilds && matches(tname, acptr->name)) *************** *** 2379,2385 **** --- 2707,2717 ---- if (!IsAnOper(sptr) || !cnt) { if (cnt) + { + sendto_one(sptr,rpl_str(RPL_ENDOFTRACE),me.name,parv[0], + tname); return 0; + } /* let the user have some idea that its at the end of the * trace */ *************** *** 2386,2391 **** --- 2718,2725 ---- sendto_one(sptr, rpl_str(RPL_TRACESERVER), me.name, parv[0], 0, link_s[me.fd], link_u[me.fd], me.name, "*", "*", me.name); + sendto_one(sptr, rpl_str(RPL_ENDOFTRACE), me.name, parv[0], + tname); return 0; } for (cltmp = FirstClass(); doall && cltmp; cltmp = NextClass(cltmp)) *************** *** 2392,2397 **** --- 2726,2732 ---- if (Links(cltmp) > 0) sendto_one(sptr, rpl_str(RPL_TRACECLASS), me.name, parv[0], Class(cltmp), Links(cltmp)); + sendto_one(sptr, rpl_str(RPL_ENDOFTRACE), me.name, parv[0], tname); return 0; } diff -c -r irc2.8.21+CSr25/ircd/s_user.c irc2.8.21+CSr27/ircd/s_user.c *** irc2.8.21+CSr25/ircd/s_user.c Thu Sep 12 15:47:28 1996 --- irc2.8.21+CSr27/ircd/s_user.c Mon Nov 11 18:03:23 1996 *************** *** 313,328 **** ** reduce a string of duplicate list entries to contain only the unique ** items. Unavoidably O(n^2). */ ! char *canonize(buffer) char *buffer; { static char cbuf[BUFSIZ]; register char *s, *t, *cp = cbuf; register int l = 0; char *p = NULL, *p2; ! *cp = '\0'; ! for (s = strtoken(&p, buffer, ","); s; s = strtoken(&p, NULL, ",")) { if (l) --- 313,330 ---- ** reduce a string of duplicate list entries to contain only the unique ** items. Unavoidably O(n^2). */ ! char *canonize(buffer, num) char *buffer; + int *num; { static char cbuf[BUFSIZ]; register char *s, *t, *cp = cbuf; register int l = 0; char *p = NULL, *p2; ! *cp = '\0'; ! if (num) ! *num = 0; for (s = strtoken(&p, buffer, ","); s; s = strtoken(&p, NULL, ",")) { if (l) *************** *** 343,348 **** --- 345,352 ---- else l = 1; (void)strcpy(cp, s); + if (num) + (*num)++; if (p) cp += (p - s); } *************** *** 384,401 **** { Reg1 aConfItem *aconf; char *parv[3]; ! char *temp; static char ubuf[12]; short oldstatus = sptr->status; anUser *user = sptr->user; ! int i; ! int reject = 0; ! char *bottype = ""; ! char origuser[USERLEN+1]; parv[0] = sptr->name; parv[1] = parv[2] = NULL; - if (MyConnect(sptr)) { --- 388,402 ---- { Reg1 aConfItem *aconf; char *parv[3]; ! char *temp, *reason, *bottype = ""; static char ubuf[12]; + char origuser[USERLEN+1]; short oldstatus = sptr->status; anUser *user = sptr->user; ! int i, reject = 0; parv[0] = sptr->name; parv[1] = parv[2] = NULL; if (MyConnect(sptr)) { *************** *** 431,481 **** else strncpyzt(user->host, sptr->sockhost, HOSTLEN+1); 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++; ! sendto_one(sptr, ":%s NOTICE %s :This server will not allow connections from sites that don't run RFC1413 (pidentd).", me.name, parv[0]); ! sendto_one(sptr, ":%s NOTICE %s :Have your system administrator install it if you wish to connect here.", me.name, parv[0]); ! return exit_client(cptr, sptr, &me, "Install identd"); ! #endif ! } ! else if (sptr->flags & FLAGS_GOTID) strncpyzt(user->username, sptr->username, USERLEN+1); else { ! #ifdef IDENTD_ONLY ! *user->username = '~'; ! (void)strncpy(&user->username[1], origuser, USERLEN); user->username[USERLEN] = '\0'; #else ! strncpyzt(user->username, origuser, USERLEN+1); #endif } if (!BadPtr(aconf->passwd) && !StrEq(sptr->passwd, aconf->passwd)) ! { ircstp->is_ref++; sendto_one(sptr, err_str(ERR_PASSWDMISMATCH), me.name, parv[0]); return exit_client(cptr, sptr, &me, "Bad Password"); ! } bzero(sptr->passwd, sizeof(sptr->passwd)); ! if (find_kill(sptr, 1)) ! { ircstp->is_ref++; ! return exit_client(cptr, sptr, &me, "K-lined"); ! } #ifdef R_LINES if (find_restrict(sptr)) ! { ircstp->is_ref++; return exit_client(cptr, sptr, &me , "R-lined"); ! } #endif if (oldstatus == STAT_MASTER && MyConnect(sptr)) (void)m_oper(&me, sptr, 1, parv); --- 432,483 ---- else strncpyzt(user->host, sptr->sockhost, HOSTLEN+1); aconf = sptr->confs->value.aconf; ! if (sptr->flags & FLAGS_GOTID) strncpyzt(user->username, sptr->username, USERLEN+1); else { ! if (IsNoTilde(aconf)) ! (void)strncpy(user->username, origuser, USERLEN); ! else ! { ! *user->username = '~'; ! (void)strncpy(&user->username[1], origuser, USERLEN); ! } user->username[USERLEN] = '\0'; + #ifndef IDENTD_ONLY + if (IsNeedIdentd(aconf)) #else ! if (!IsPassIdentd(aconf)) #endif + { + ircstp->is_ref++; + sendto_one(sptr, ":%s NOTICE %s :This server doesn't allow connections from your site, unless it runs identd. (RFC1413)", me.name, parv[0]); + sendto_one(sptr, ":%s NOTICE %s :Have your system administrator install it if you wish to connect here.", me.name, parv[0]); + return exit_client(cptr, sptr, &me, "Install identd"); + } } + if (!BadPtr(aconf->passwd) && !StrEq(sptr->passwd, aconf->passwd)) ! { ircstp->is_ref++; sendto_one(sptr, err_str(ERR_PASSWDMISMATCH), me.name, parv[0]); return exit_client(cptr, sptr, &me, "Bad Password"); ! } bzero(sptr->passwd, sizeof(sptr->passwd)); ! if (find_kill(sptr, 1, &reason)) ! { ircstp->is_ref++; ! return exit_client(cptr, sptr, &me, reason); ! } #ifdef R_LINES if (find_restrict(sptr)) ! { ircstp->is_ref++; return exit_client(cptr, sptr, &me , "R-lined"); ! } #endif if (oldstatus == STAT_MASTER && MyConnect(sptr)) (void)m_oper(&me, sptr, 1, parv); *************** *** 485,490 **** --- 487,493 ---- register char *tmpstr, c; register int lower, upper, special; char *Myptr, *Myptr2; + char *username = user->username; lower = upper = special = 0; #ifdef IGNORE_FIRST_CHAR *************** *** 499,505 **** lower++; if (isupper(c)) upper++; ! if (!isalnum(c) && !strchr("-_.", c)) special++; } #endif /* NO_MIXED_CASE || NO_SPECIAL */ --- 502,508 ---- lower++; if (isupper(c)) upper++; ! if (strchr("[]().;",c)||(!isalnum(c) && !strchr("-_.", c))) special++; } #endif /* NO_MIXED_CASE || NO_SPECIAL */ *************** *** 509,514 **** --- 512,519 ---- sendto_flagops(BMODE, "Invalid username: %s [%s@%s]", nick, username, user->host); ircstp->is_ref++; + sendto_one(sptr, ":%s NOTICE %s :Sorry, your userid contains a mix of lower and upper case characters.", me.name, parv[0]); + sendto_one(sptr, ":%s NOTICE %s :Only all lower or all upper case is allowed.", me.name, parv[0]); return exit_client(cptr, sptr, &me, "Invalid username"); } #endif /* NO_MIXED_CASE */ *************** *** 518,523 **** --- 523,530 ---- sendto_flagops(BMODE,"Invalid username: %s [%s@%s]", nick, user->username, user->host); ircstp->is_ref++; + sendto_one(sptr, ":%s NOTICE %s :Sorry, your userid contains invalid characters.", me.name, parv[0]); + sendto_one(sptr, ":%s NOTICE %s :Only alphanumeric characters are allowed.", me.name, parv[0]); return exit_client(cptr, sptr, &me, "Invalid username"); } #endif /* NO_SPECIAL */ *************** *** 534,539 **** --- 541,551 ---- if (!find_bline(cptr)) { #endif + + #define bot_msg sendto_one(sptr, ":%s NOTICE %s :Sorry, certain bots currently aren't allowed.", me.name, parv[0]); \ + sendto_one(sptr, ":%s NOTICE %s :If you are not a bot, your client is probably outdated, and you should contact the author.", \ + me.name, parv[0]); + #if defined(BOTS_NOTICE) || defined(REJECT_BOTS) if (reject == 1) { *************** *** 542,547 **** --- 554,560 ---- user->host); #ifdef REJECT_BOTS ircstp->is_ref++; + bot_msg; return exit_client(cptr, sptr, &me, "No bots allowed"); #endif } *************** *** 552,557 **** --- 565,571 ---- nick, user->username, user->host); #ifdef REJECT_BOTS ircstp->is_ref++; + bot_msg; return exit_client(cptr, sptr, &me, "No bots allowed"); #endif } *************** *** 562,567 **** --- 576,582 ---- nick, user->username, user->host); #ifdef REJECT_BOTS ircstp->is_ref++; + bot_msg; return exit_client(cptr, sptr, &me, "No bots allowed"); #endif } *************** *** 572,582 **** 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(BMODE,"%s bot: %s [%s@%s]", bottype, --- 587,598 ---- nick, user->username, user->host); #ifdef REJECT_BOTS ircstp->is_ref++; + bot_msg; return exit_client(cptr, sptr, &me, "No bots allowed"); #endif } ! if (my_stristr(nick, "bot")||my_stristr(nick, "Serv")|| ! my_stristr(nick, "help")) { sendto_flagops(BMODE,"%s bot: %s [%s@%s]", bottype, *************** *** 658,664 **** nick, user->username, user->host); #endif /* CLIENT_NOTICES */ if (sptr->flags & FLAGS_GOTID) ! if (strcmp(origuser, sptr->username)) sendto_flagops(DMODE,"Identd response differs: %s [%s]", nick, origuser); } else --- 674,680 ---- nick, user->username, user->host); #endif /* CLIENT_NOTICES */ if (sptr->flags & FLAGS_GOTID) ! if (mycmp(origuser, sptr->username)) sendto_flagops(DMODE,"Identd response differs: %s [%s]", nick, origuser); } else *************** *** 756,761 **** --- 772,780 ---- ts_val newts = 0; int doests, sameuser = 0; int fromts; + #ifdef NO_NICK_FLOODS + int dontcheck = 0; + #endif if (parc < 2) { *************** *** 828,860 **** BadPtr(parv[0]) ? "*" : parv[0], nick); return 0; /* NICK message ignored */ } - #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(OPERS,"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 - /* ** acptr already has result from previous find_server() */ --- 847,852 ---- *************** *** 892,901 **** --- 884,898 ---- */ if (acptr == sptr) if (strcmp(acptr->name, nick) != 0) + { /* ** Allows change of case in his/her nick */ + #ifdef NO_NICK_FLOODS + dontcheck = 1; + #endif goto nickkilldone; /* -- go and process change */ + } else /* ** This is just ':old NICK old' type thing. *************** *** 934,939 **** --- 931,937 ---- me.name, BadPtr(parv[0]) ? "*" : parv[0], nick); return 0; /* NICK message ignored */ } + /* ** NICK was coming from a server connection. Means that the same ** nick is registerd for different users by different server. *************** *** 1092,1097 **** --- 1090,1121 ---- } nickkilldone: + #ifdef NO_NICK_FLOODS + if (!dontcheck && MyClient(sptr) && IsPerson(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(OPERS,"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 /* NO_NICK_FLOODS */ if (IsServer(sptr)) { /* A server introducing a new client, change source */ *************** *** 1211,1216 **** --- 1235,1241 ---- Reg2 char *s; aChannel *chptr; char *nick, *server, *p, *cmd, *host; + int num = 0; int resetidle = 0; if (notice) *************** *** 1237,1243 **** } if (MyConnect(sptr)) ! parv[1] = canonize(parv[1]); for (p = NULL, nick = strtoken(&p, parv[1], ","); nick; nick = strtoken(&p, NULL, ",")) { --- 1262,1281 ---- } if (MyConnect(sptr)) ! { ! parv[1] = canonize(parv[1], &num); ! if (IsPerson(sptr) && (num>10)) ! { ! sendto_one(sptr, ":%s NOTICE %s :Too many recipients", ! me.name, parv[0]); ! if (num>=20) ! sendto_flagops(OPERS, ! "%s (%s@%s) tried %i recipients", ! sptr->name, sptr->user->username, ! sptr->user->host, num); ! goto here; ! } ! } for (p = NULL, nick = strtoken(&p, parv[1], ","); nick; nick = strtoken(&p, NULL, ",")) { *************** *** 1378,1386 **** sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, parv[0], nick); } ! if (resetidle && MyConnect(sptr) && sptr->user) ! sptr->user->last = NOW; ! return 0; } /* --- 1416,1425 ---- sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, parv[0], nick); } ! here: ! if (resetidle && MyConnect(sptr) && sptr->user) ! sptr->user->last = NOW; ! return 0; } /* *************** *** 1619,1624 **** --- 1658,1665 ---- parv[1] = parv[2]; } + parv[1] = canonize(parv[1], NULL); + for (tmp = parv[1]; (nick = strtoken(&p, tmp, ",")); tmp = NULL) { int invis, showperson, member, wilds; *************** *** 1931,1953 **** path[TOPICLEN] = '\0'; } ! if (!(acptr = find_client(user, NULL))) ! { ! /* ! ** If the user has recently changed nick, we automaticly ! ** rewrite the KILL for this new nickname--this keeps ! ** servers in synch when nick change and kill collide ! */ ! if (!(acptr = get_history(user, (long)KILLCHASETIMELIMIT))) ! { ! sendto_one(sptr, err_str(ERR_NOSUCHNICK), ! me.name, parv[0], user); ! return 0; ! } sendto_one(sptr,":%s NOTICE %s :KILL changed from %s to %s", me.name, parv[0], user, acptr->name); - chasing = 1; - } if (!MyConnect(acptr) && IsLocOp(cptr)) { sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); --- 1972,1982 ---- path[TOPICLEN] = '\0'; } ! if (!(acptr = find_chasing(sptr, user, &chasing))) ! return 0; ! if (chasing) sendto_one(sptr,":%s NOTICE %s :KILL changed from %s to %s", me.name, parv[0], user, acptr->name); if (!MyConnect(acptr) && IsLocOp(cptr)) { sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); diff -c -r irc2.8.21+CSr25/ircd/whowas.c irc2.8.21+CSr27/ircd/whowas.c *** irc2.8.21+CSr25/ircd/whowas.c Thu Jul 25 19:37:29 1996 --- irc2.8.21+CSr27/ircd/whowas.c Mon Nov 11 18:02:51 1996 *************** *** 141,146 **** --- 141,149 ---- if (hunt_server(cptr,sptr,":%s WHOWAS %s %s :%s", 3,parc,parv)) return 0; + parv[1] = canonize(parv[1], NULL); + if (!MyConnect(sptr) && (max > 20)) + max = 20; for (s = parv[1]; (nick = strtoken(&p, s, ",")); s = NULL) { wp = wp2 = &was[ww_index - 1]; *************** *** 171,177 **** if (up == NULL) sendto_one(sptr, err_str(ERR_WASNOSUCHNICK), ! me.name, parv[0], parv[1]); if (p) p[-1] = ','; --- 174,180 ---- if (up == NULL) sendto_one(sptr, err_str(ERR_WASNOSUCHNICK), ! me.name, parv[0], nick); if (p) p[-1] = ','; Only in irc2.8.21+CSr27/ircd/crypt: exec