*** common/send.c Fri Mar 28 19:19:15 1997 --- ../irc2.8.21+CSr29+TS3/common/send.c Sat Jun 7 00:51:13 1997 *************** *** 491,496 **** --- 491,499 ---- return; } + + #ifndef TS_ONLY + /* * sendto_TS_server_butone * *************** *** 563,568 **** --- 566,573 ---- return; } + #endif /* TS_ONLY */ + /* * sendto_common_channels() * *************** *** 778,783 **** --- 783,790 ---- #endif } + #ifndef TS_ONLY + /* * sendto_match_TS_servs * *************** *** 871,876 **** --- 878,886 ---- #endif } + #endif /* TS_ONLY */ + + /* * sendto_match_butone * *************** *** 1116,1121 **** --- 1126,1183 ---- sendto_one(cptr, nbuf, p1, p2, p3, p4, p5, p6, p7, p8); } # endif + #endif + return; + } + + /* + ** ts_warn + ** Call sendto_ops, with some flood checking (at most 5 warnings + ** every 5 seconds) + */ + + #ifndef USE_VARARGS + /*VARARGS*/ + void ts_warn(pattern, p1, p2, p3, p4, p5, p6, p7, p8) + char *pattern, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8; + { + #else + void ts_warn(pattern, va_alist) + char *pattern; + va_dcl + { + va_list vl; + #endif + static ts_val last = 0; + static warnings = 0; + register ts_val now; + + #ifdef USE_VARARGS + va_start(vl); + #endif + + /* + ** if we're runnign with TS_WARNINGS enabled and someone does + ** something silly like (remotely) connecting a nonTS server, + ** we'll get a ton of warnings, so we make sure we don't send + ** more than 5 every 5 seconds. -orabidoo + */ + now = time(NULL); + if (now - last < 5) + { + if (++warnings > 5) + return; + } + else + { + last = now; + warnings = 0; + } + + #ifdef USE_VARARGS + sendto_ops(pattern, va_alist); + #else + sendto_ops(pattern, p1, p2, p3, p4, p5, p6, p7, p8); #endif return; } *** include/config.h Sat Jun 7 01:52:52 1997 --- ../irc2.8.21+CSr29+TS3/include/config.h Sat Jun 7 01:51:58 1997 *************** *** 171,176 **** --- 171,195 ---- */ #define NO_DEFAULT_INVISIBLE + /* TS_ONLY + * + * When defined, the server will refuse to directly link to non-TS servers. + * Remote servers can still be non-TS, although that basically keeps channel + * TS's to 0 so it's not a good idea. Defining TS_ONLY speeds the server + * up by removing some compatibility code. + */ + #define TS_ONLY + + /* TS_WARNINGS + * + * When defined, +s users are warned of some things that should never + * happen on an all-TS net. Currently these are: server-generated MODE +o, + * new nicks without a TS, and remote JOINs for non-existing channels. + * This is useful to track down anomalies; undefine it on a mixed TS/nonTS + * net or you'll get a lot of warnings! + */ + #define TS_WARNINGS + /* OPER_KILL * * If you dont believe operators should be allowed to use the /KILL command *** include/config.h.dist Sun Sep 15 20:35:36 1996 --- ../irc2.8.21+CSr29+TS3/include/config.h.dist Sat Jun 7 01:42:22 1997 *************** *** 152,157 **** --- 152,178 ---- */ #undef NO_DEFAULT_INVISIBLE + /* TS_ONLY + * + * When defined, the server will refuse to directly link to non-TS servers. + * Remote servers can still be non-TS, although that basically keeps channel + * TS's to 0 so it's not a good idea. Defining TS_ONLY speeds the server + * up by removing some compatibility code. + */ + #define TS_ONLY + + /* TS_WARNINGS + * + * When defined, +s users are warned of some things that should never + * happen on an all-TS net. Currently these are: server-generated MODE +o, + * new nicks without a TS, and remote JOINs for non-existing channels. + * This is useful to track down anomalies; undefine it on a mixed TS/nonTS + * net or you'll get a lot of warnings! + */ + #define TS_WARNINGS + + + /* OPER_KILL * * If you dont believe operators should be allowed to use the /KILL command *** include/config.h.r25 Sun Sep 15 20:35:36 1996 --- ../irc2.8.21+CSr29+TS3/include/config.h.r25 Sat Jun 7 01:42:50 1997 *************** *** 171,176 **** --- 171,195 ---- */ #define NO_DEFAULT_INVISIBLE + /* TS_ONLY + * + * When defined, the server will refuse to directly link to non-TS servers. + * Remote servers can still be non-TS, although that basically keeps channel + * TS's to 0 so it's not a good idea. Defining TS_ONLY speeds the server + * up by removing some compatibility code. + */ + #define TS_ONLY + + /* TS_WARNINGS + * + * When defined, +s users are warned of some things that should never + * happen on an all-TS net. Currently these are: server-generated MODE +o, + * new nicks without a TS, and remote JOINs for non-existing channels. + * This is useful to track down anomalies; undefine it on a mixed TS/nonTS + * net or you'll get a lot of warnings! + */ + #define TS_WARNINGS + /* OPER_KILL * * If you dont believe operators should be allowed to use the /KILL command *** include/config.h.save Sun Sep 15 20:35:36 1996 --- ../irc2.8.21+CSr29+TS3/include/config.h.save Sat Jun 7 01:43:24 1997 *************** *** 171,176 **** --- 171,196 ---- */ #define NO_DEFAULT_INVISIBLE + /* TS_ONLY + * + * When defined, the server will refuse to directly link to non-TS servers. + * Remote servers can still be non-TS, although that basically keeps channel + * TS's to 0 so it's not a good idea. Defining TS_ONLY speeds the server + * up by removing some compatibility code. + */ + #define TS_ONLY + + /* TS_WARNINGS + * + * When defined, +s users are warned of some things that should never + * happen on an all-TS net. Currently these are: server-generated MODE +o, + * new nicks without a TS, and remote JOINs for non-existing channels. + * This is useful to track down anomalies; undefine it on a mixed TS/nonTS + * net or you'll get a lot of warnings! + */ + #define TS_WARNINGS + + /* OPER_KILL * * If you dont believe operators should be allowed to use the /KILL command *** include/h.h Tue Mar 18 23:50:25 1997 --- ../irc2.8.21+CSr29+TS3/include/h.h Sat Jun 7 01:41:11 1997 *************** *** 204,211 **** --- 204,217 ---- extern void sendto_channel_butone(); /*VARARGS2*/ extern void sendto_serv_butone(); + + #ifndef TS_ONLY /*VARARGS2*/ extern void sendto_TS_serv_butone(); + /*VARARGS3*/ + extern void sendto_match_TS_servs(); + #endif + /*VARARGS2*/ extern void sendto_common_channels(); /*VARARGS3*/ *************** *** 212,219 **** extern void sendto_channel_butserv(); /*VARARGS3*/ extern void sendto_match_servs(); - /*VARARGS3*/ - extern void sendto_match_TS_servs(); /*VARARGS5*/ extern void sendto_match_butone(); /*VARARGS3*/ --- 218,223 ---- *************** *** 222,227 **** --- 226,233 ---- extern void sento_flagops(); /*VARARGS1*/ extern void sendto_ops(); + /*VARARGS1*/ + extern void ts_warn(); /*VARARGS3*/ extern void sendto_ops_butone(); /*VARARGS3*/ *** include/numeric.h Thu Dec 19 00:33:22 1996 --- ../irc2.8.21+CSr29+TS3/include/numeric.h Sat Jun 7 01:41:24 1997 *************** *** 235,240 **** --- 235,242 ---- #define RPL_LISTEND 323 #define RPL_CHANNELMODEIS 324 + #define RPL_CREATIONTIME 329 + #define RPL_NOTOPIC 331 #define RPL_TOPIC 332 *** include/struct.h Fri Mar 28 19:19:15 1997 --- ../irc2.8.21+CSr29+TS3/include/struct.h Sat Jun 7 01:41:41 1997 *************** *** 567,573 **** char chname[1]; }; ! #define TS_CURRENT 1 /* current TS protocol version */ #define TS_MIN 1 /* minimum supported TS protocol version */ #define TS_DOESTS 0x20000000 #define DoesTS(x) ((x)->tsinfo == TS_DOESTS) --- 567,573 ---- char chname[1]; }; ! #define TS_CURRENT 3 /* current TS protocol version */ #define TS_MIN 1 /* minimum supported TS protocol version */ #define TS_DOESTS 0x20000000 #define DoesTS(x) ((x)->tsinfo == TS_DOESTS) *** ircd/channel.c Tue Nov 12 00:02:02 1996 --- ../irc2.8.21+CSr29+TS3/ircd/channel.c Sat Jun 7 02:00:57 1997 *************** *** 736,741 **** --- 736,743 ---- channel_modes(sptr, modebuf, parabuf, chptr); sendto_one(sptr, rpl_str(RPL_CHANNELMODEIS), me.name, parv[0], chptr->chname, modebuf, parabuf); + sendto_one(sptr, rpl_str(RPL_CREATIONTIME), me.name, parv[0], + chptr->chname, chptr->channelts); return 0; } mcount = set_mode(cptr, sptr, chptr, parc - 2, parv + 2, *************** *** 1235,1241 **** --- 1237,1250 ---- */ if (IsServer(sptr) && c == 'o' && whatt == MODE_ADD) + { chptr->channelts = 0; + #ifdef TS_WARNINGS + ts_warn("Server %s setting +o and blasting TS on %s", sptr->name, + chptr->chname); + #endif + } + if (c == 'o' && whatt == MODE_ADD && isdeop && !is_chan_op(lp->value.cptr, chptr)) set_deopped(lp, chptr); *************** *** 1595,1600 **** --- 1604,1621 ---- return 0; } } + else + { + #ifdef TS_WARNINGS + /* + ** complain for remote JOINs to existing channels + ** (they should be SJOINs) -orabidoo + */ + if (!ChannelExists(name) && sptr->user) + ts_warn("User on %s remotely JOINing new channel", + sptr->user->server); + #endif + } chptr = get_channel(sptr, name, CREATE); *************** *** 1616,1634 **** /* ** Set timestamp if appropriate, and propagate */ ! if (MyClient(sptr) && flags) { chptr->channelts = NOW + timedelta; ! sendto_match_TS_servs(0, chptr, cptr, ":%s JOIN :%s", ! parv[0], name); ! sendto_match_TS_servs(1, chptr, cptr, ! ":%s SJOIN %ld %s + :@%s", ! me.name, chptr->channelts, name, ! parv[0]); } ! else ! sendto_match_servs(chptr, cptr, ":%s JOIN :%s", parv[0], ! name); /* ** notify all other users on the new channel */ --- 1637,1674 ---- /* ** Set timestamp if appropriate, and propagate */ ! if (MyClient(sptr) && flags == CHFL_CHANOP) { chptr->channelts = NOW + timedelta; ! #ifdef TS_ONLY ! sendto_match_servs(chptr, cptr, ! ":%s SJOIN %ld %s + :@%s", me.name, ! chptr->channelts, name, parv[0]); ! #else ! sendto_match_TS_servs(0, chptr, cptr, ":%s JOIN :%s", ! parv[0], name); ! sendto_match_TS_servs(1, chptr, cptr, ! ":%s SJOIN %ld %s + :@%s", me.name, ! chptr->channelts, name, parv[0]); ! #endif } ! else if (MyClient(sptr)) ! { ! #ifdef TS_ONLY ! sendto_match_servs(chptr, cptr, ! ":%s SJOIN %ld %s + :%s", me.name, ! chptr->channelts, name, parv[0]); ! #else ! sendto_match_TS_servs(0, chptr, cptr, ":%s JOIN :%s", ! parv[0], name); ! sendto_match_TS_servs(1, chptr, cptr, ! ":%s SJOIN %ld %s + :%s", me.name, ! chptr->channelts, name, parv[0]); ! #endif ! } ! else ! sendto_match_servs(chptr, cptr, ":%s JOIN :%s", parv[0], ! name); /* ** notify all other users on the new channel */ *************** *** 1638,1647 **** --- 1678,1689 ---- if (MyClient(sptr)) { del_invite(sptr, chptr); + #ifndef TS_ONLY if (flags == CHFL_CHANOP) sendto_match_TS_servs(0, chptr, cptr, ":%s MODE %s +o %s", me.name, name, parv[0]); + #endif if (chptr->topic[0] != '\0') { sendto_one(sptr, rpl_str(RPL_TOPIC), me.name, *************** *** 2314,2322 **** { sendto_channel_butserv(chptr, sptr, ":%s MODE %s %s %s", from, chptr->chname, modebuf, parabuf); ! sendto_match_TS_servs(0, chptr, cptr, ":%s MODE %s %s %s", from, chptr->chname, modebuf, parabuf); } /* --- 2356,2365 ---- { sendto_channel_butserv(chptr, sptr, ":%s MODE %s %s %s", from, chptr->chname, modebuf, parabuf); ! #ifndef TS_ONLY sendto_match_TS_servs(0, chptr, cptr, ":%s MODE %s %s %s", from, chptr->chname, modebuf, parabuf); + #endif } /* *************** *** 2482,2488 **** { chptr->channelts = tstosend = newts; if (MyConnect(sptr)) ! sendto_ops("Hacked ops on opless channel: %s", chptr->chname); } else --- 2525,2531 ---- { chptr->channelts = tstosend = newts; if (MyConnect(sptr)) ! ts_warn("Hacked ops on opless channel: %s", chptr->chname); } else *************** *** 2681,2688 **** --- 2724,2733 ---- add_user_to_channel(chptr, acptr, fl); sendto_channel_butserv(chptr, acptr, ":%s JOIN :%s", s, parv[2]); + #ifndef TS_ONLY sendto_match_TS_servs(0, chptr, cptr, ":%s JOIN :%s", s, parv[2]); + #endif } if (keepnewmodes) strcpy(t, s0); *************** *** 2735,2741 **** --- 2780,2790 ---- t[-1] = '\0'; else *t = '\0'; + #ifdef TS_ONLY + sendto_match_servs(chptr, cptr, "%s", sjbuf); + #else sendto_match_TS_servs(1, chptr, cptr, "%s", sjbuf); + #endif } } *** ircd/s_debug.c Fri Feb 14 22:46:51 1997 --- ../irc2.8.21+CSr29+TS3/ircd/s_debug.c Sat Jun 7 01:16:01 1997 *************** *** 194,201 **** --- 194,210 ---- ' ', 'T', 'S', + #ifdef TS_CURRENT + '0' + TS_CURRENT, + #endif #ifdef TSDEBUG 'd', + #endif + #ifdef TS_ONLY + 'o', + #endif + #ifdef TS_WARNINGS + 'w', #endif '\0'}; *** ircd/s_err.c Thu Dec 19 00:33:11 1996 --- ../irc2.8.21+CSr29+TS3/ircd/s_err.c Sat Jun 7 01:17:41 1997 *************** *** 166,174 **** /* 321 */ RPL_LISTSTART, "Channel :Users Name", /* 322 */ RPL_LIST, "%s %d :%s", /* 323 */ RPL_LISTEND, ":End of /LIST", ! /* 324 */ RPL_CHANNELMODEIS, "%s %s %s", ! 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, ! 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 331 */ RPL_NOTOPIC, "%s :No topic is set.", /* 332 */ RPL_TOPIC, "%s :%s", #ifdef TOPIC_INFO --- 166,176 ---- /* 321 */ RPL_LISTSTART, "Channel :Users Name", /* 322 */ RPL_LIST, "%s %d :%s", /* 323 */ RPL_LISTEND, ":End of /LIST", ! /* 324 */ RPL_CHANNELMODEIS, "%s %s %s", ! 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, ! 0, (char *)NULL, ! /* 329 */ RPL_CREATIONTIME, "%s %lu", ! 0, (char *)NULL, /* 331 */ RPL_NOTOPIC, "%s :No topic is set.", /* 332 */ RPL_TOPIC, "%s :%s", #ifdef TOPIC_INFO *** ircd/s_serv.c Fri Mar 28 19:29:06 1997 --- ../irc2.8.21+CSr29+TS3/ircd/s_serv.c Sat Jun 7 01:23:14 1997 *************** *** 473,482 **** { Reg1 ts_val v; ! if (!IsServer(sptr) || !MyConnect(sptr) || !DoesTS(sptr) || parc < 5 || ! TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN) ! return 0; if (atoi(parv[3])) v = (atol(parv[4]) - (ts_val)NOW - timedelta) / 2; else --- 473,498 ---- { Reg1 ts_val v; ! if (!IsServer(sptr) || !MyConnect(sptr) || !DoesTS(sptr) || parc < 5) ! return 0; + if (TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN) + { + #ifdef TS_ONLY + /* + ** a server with the wrong TS version connected; since we're + ** TS_ONLY we can't fall back to the non-TS protocol so + ** we drop the link -orabidoo + */ + sendto_ops("Link %s dropped, wrong TS protocol version (%s,%s)", + get_client_name(sptr, TRUE), parv[1], parv[2]); + return exit_client(sptr, sptr, sptr, "Incompatible TS version"); + #else + sptr->tsinfo = 0; + return 0; + #endif + } + if (atoi(parv[3])) v = (atol(parv[4]) - (ts_val)NOW - timedelta) / 2; else *************** *** 714,719 **** --- 730,748 ---- ** to be a SERVER. Check if this is allowed and change ** status accordingly... */ + + #ifdef TS_ONLY + /* + ** Reject a direct nonTS server connection if we're TS_ONLY -orabidoo + */ + if (!DoesTS(cptr)) + { + sendto_ops("Link %s dropped, non-TS server", + get_client_name(cptr, TRUE)); + return exit_client(cptr, cptr, cptr, "Non-TS server"); + } + #endif + strncpyzt(cptr->name, host, sizeof(cptr->name)); strncpyzt(cptr->info, info[0] ? info:me.name, sizeof(cptr->info)); cptr->hopcount = hop; *** ircd/s_user.c Fri Mar 28 19:21:12 1997 --- ../irc2.8.21+CSr29+TS3/ircd/s_user.c Sat Jun 7 02:09:43 1997 *************** *** 764,769 **** --- 764,775 ---- if (!*ubuf) strcpy(ubuf, "+"); + #ifdef TS_ONLY + sendto_serv_butone(cptr, "NICK %s %d %ld %s %s %s %s :%s", + nick, sptr->hopcount+1, sptr->tsinfo, ubuf, + user->username, user->host, user->server, + sptr->info); + #else sendto_TS_serv_butone(0, cptr, "NICK %s :%d", nick, sptr->hopcount+1); sendto_TS_serv_butone(0, cptr, ":%s USER %s %s %s :%s", nick, user->username, user->host, *************** *** 772,777 **** --- 778,784 ---- nick, sptr->hopcount+1, sptr->tsinfo, ubuf, user->username, user->host, user->server, sptr->info); + #endif if (ubuf[1]) send_umode_out(cptr, sptr, 0, 0); #ifdef USE_SERVICES *************** *** 1162,1168 **** --- 1169,1180 ---- if (newts) sptr->tsinfo = newts; else + { newts = sptr->tsinfo = (ts_val)NOW + timedelta; + #ifdef TS_WARNINGS + ts_warn("Remote nick %s introduced without a TS", nick); + #endif + } /* copy the nick in place */ (void)strcpy(sptr->name, nick); (void)add_to_client_hash_table(nick, sptr); *************** *** 1206,1216 **** timedelta; sendto_common_channels(sptr, ":%s NICK :%s", parv[0], nick); if (sptr->user) add_history(sptr, 1); ! sendto_TS_serv_butone(1, cptr, ":%s NICK %s :%ld", ! parv[0], nick, sptr->tsinfo); ! sendto_TS_serv_butone(0, cptr, ":%s NICK :%s", parv[0], ! nick); #ifdef USE_SERVICES check_services_butone(SERVICE_WANT_NICK, sptr, ":%s NICK :%s", parv[0], nick); --- 1218,1236 ---- timedelta; sendto_common_channels(sptr, ":%s NICK :%s", parv[0], nick); if (sptr->user) + { add_history(sptr, 1); ! #ifdef TS_ONLY ! sendto_serv_butone(cptr, ":%s NICK %s :%ld", ! parv[0], nick, sptr->tsinfo); ! #else ! sendto_TS_serv_butone(1, cptr, ":%s NICK %s :%ld", ! parv[0], nick, sptr->tsinfo); ! sendto_TS_serv_butone(0, cptr, ":%s NICK :%s", parv[0], ! nick); ! #endif ! } ! #ifdef USE_SERVICES check_services_butone(SERVICE_WANT_NICK, sptr, ":%s NICK :%s", parv[0], nick); *** ircd/s_user.c Fri Mar 28 19:21:12 1997 --- ../irc2.8.21+CSr29+TS3/ircd/s_user.c Wed Jun 25 01:13:36 1997 *************** *** 1051,1059 **** ** must be killed from the incoming connection, and "old" must ** be purged from all outgoing connections. */ ! if (acptr->user) sameuser = mycmp(acptr->user->username, sptr->user->username) == 0 && ! mycmp(acptr->user->host, acptr->user->host) == 0; else newts = 0; if (!doests || !newts || !acptr->tsinfo || (newts == acptr->tsinfo)) --- 1051,1059 ---- ** must be killed from the incoming connection, and "old" must ** be purged from all outgoing connections. */ ! if (acptr->user && sptr->user) sameuser = mycmp(acptr->user->username, sptr->user->username) == 0 && ! mycmp(acptr->user->host, sptr->user->host) == 0; else newts = 0; if (!doests || !newts || !acptr->tsinfo || (newts == acptr->tsinfo))