*** ../irc2.8.21+TSora-beforeTS0patch/common/send.c Fri Jul 5 01:46:03 1996 --- common/send.c Sun May 18 23:30:41 1997 *************** *** 428,433 **** --- 428,436 ---- return; } + + #ifndef TS_ONLY + /* * sendto_TS_server_butone * *************** *** 478,483 **** --- 481,488 ---- return; } + #endif /* TS_ONLY */ + /* * sendto_common_channels() *************** *** 664,669 **** --- 669,677 ---- #endif } + + #ifndef TS_ONLY + /* * sendto_match_TS_servs * *************** *** 731,736 **** --- 739,746 ---- #endif } + #endif /* TS_ONLY */ + /* * sendto_match_butone *************** *** 889,894 **** --- 899,956 ---- 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; } *** ../irc2.8.21+TSora-beforeTS0patch/ircd/channel.c Fri Jul 5 01:46:04 1996 --- ircd/channel.c Sun May 18 23:30:41 1997 *************** *** 648,653 **** --- 648,655 ---- 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, *************** *** 1140,1146 **** --- 1142,1154 ---- change_chan_flag(lp, chptr); 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); *************** *** 1484,1489 **** --- 1492,1509 ---- 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); *************** *** 1505,1523 **** /* ** Set timestamp if appropriate, and propagate */ ! if (MyClient(sptr) && flags) { chptr->channelts = time(NULL) + 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 */ --- 1525,1564 ---- /* ** Set timestamp if appropriate, and propagate */ ! if (MyClient(sptr) && flags == CHFL_CHANOP) { chptr->channelts = time(NULL) + 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 */ *************** *** 1527,1536 **** --- 1568,1579 ---- 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, parv[0], name, chptr->topic); *************** *** 2171,2179 **** { 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); } /* --- 2214,2223 ---- { 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 } /* *************** *** 2316,2322 **** { chptr->channelts = tstosend = newts; if (MyConnect(sptr)) ! sendto_ops("Hacked ops on opless channel: %s", chptr->chname); } else --- 2360,2366 ---- { chptr->channelts = tstosend = newts; if (MyConnect(sptr)) ! ts_warn("Hacked ops on opless channel: %s", chptr->chname); } else *************** *** 2505,2512 **** --- 2549,2558 ---- 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); *************** *** 2557,2563 **** --- 2603,2613 ---- 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 } } *** ../irc2.8.21+TSora-beforeTS0patch/ircd/s_debug.c Fri Jul 5 01:46:05 1996 --- ircd/s_debug.c Sun May 18 23:30:43 1997 *************** *** 119,126 **** --- 119,135 ---- ' ', 'T', 'S', + #ifdef TS_CURRENT + '0' + TS_CURRENT, + #endif #ifdef TSDEBUG 'd', + #endif + #ifdef TS_ONLY + 'o', + #endif + #ifdef TS_WARNINGS + 'w', #endif '\0'}; *** ../irc2.8.21+TSora-beforeTS0patch/ircd/s_err.c Fri Jul 5 01:46:05 1996 --- ircd/s_err.c Sun May 18 23:30:43 1997 *************** *** 153,159 **** /* 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", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, --- 153,161 ---- /* 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", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, *** ../irc2.8.21+TSora-beforeTS0patch/ircd/s_serv.c Fri Jul 5 01:46:06 1996 --- ircd/s_serv.c Sun May 18 23:30:43 1997 *************** *** 275,284 **** { 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)time(NULL) - timedelta) / 2; else --- 275,300 ---- { 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)time(NULL) - timedelta) / 2; else *************** *** 516,521 **** --- 532,550 ---- ** 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; *** ../irc2.8.21+TSora-beforeTS0patch/ircd/s_user.c Fri Jul 5 01:46:06 1996 --- ircd/s_user.c Sun May 18 23:30:44 1997 *************** *** 450,455 **** --- 450,461 ---- 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, *************** *** 458,463 **** --- 464,470 ---- 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 *************** *** 813,819 **** --- 820,831 ---- if (newts) sptr->tsinfo = newts; else + { newts = sptr->tsinfo = (ts_val)time(NULL) + 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); *************** *** 855,864 **** --- 867,881 ---- if (sptr->user) { add_history(sptr); + #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", *** ../irc2.8.21+TSora-beforeTS0patch/include/config.h Wed Dec 6 04:41:54 1995 --- include/config.h Sun May 18 23:32:56 1997 *************** *** 152,157 **** --- 152,176 ---- */ #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! + */ + #undef TS_WARNINGS + /* OPER_KILL * * If you dont believe operators should be allowed to use the /KILL command *** ../irc2.8.21+TSora-beforeTS0patch/include/h.h Fri Jul 5 01:46:07 1996 --- include/h.h Sun May 18 23:30:44 1997 *************** *** 118,139 **** extern void sendto_channel_butone(); /*VARARGS2*/ extern void sendto_serv_butone(); /*VARARGS2*/ extern void sendto_TS_serv_butone(); /*VARARGS2*/ extern void sendto_common_channels(); /*VARARGS3*/ 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*/ extern void sendto_all_butone(); /*VARARGS1*/ extern void sendto_ops(); /*VARARGS3*/ extern void sendto_ops_butone(); /*VARARGS3*/ --- 118,145 ---- 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*/ extern void sendto_channel_butserv(); /*VARARGS3*/ extern void sendto_match_servs(); /*VARARGS5*/ extern void sendto_match_butone(); /*VARARGS3*/ extern void sendto_all_butone(); /*VARARGS1*/ extern void sendto_ops(); + /*VARARGS1*/ + extern void ts_warn(); /*VARARGS3*/ extern void sendto_ops_butone(); /*VARARGS3*/ *** ../irc2.8.21+TSora-beforeTS0patch/include/numeric.h Fri Jul 5 01:46:07 1996 --- include/numeric.h Sun May 18 23:30:44 1997 *************** *** 220,225 **** --- 220,227 ---- #define RPL_LISTEND 323 #define RPL_CHANNELMODEIS 324 + #define RPL_CREATIONTIME 329 + #define RPL_NOTOPIC 331 #define RPL_TOPIC 332 *** ../irc2.8.21+TSora-beforeTS0patch/include/struct.h Fri Jul 5 01:46:07 1996 --- include/struct.h Sun May 18 23:30:45 1997 *************** *** 441,447 **** 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) --- 441,447 ---- 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) *** ../irc2.8.21+TSora-beforeTS0patch/include/config.h.dist Wed Nov 16 09:07:33 1994 --- include/config.h.dist Sun May 18 20:55:30 1997 *************** *** 152,157 **** --- 152,176 ---- */ #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 *** old/ircd/s_user.c Sun May 18 22:18:34 1997 --- ircd/s_user.c Wed Jun 25 00:48:24 1997 *************** *** 733,742 **** ** 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; /* force both kills */ --- 733,742 ---- ** 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; /* force both kills */