/************************************************************************ * IRC - Internet Relay Chat, modules/m_svinfo.c * * Copyright (C) 2000-2003 TR-IRCD Development * * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Co Center * * See file AUTHORS in IRC package for additional names of * the programmers. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * $Id: m_svinfo.c,v 1.5 2004/02/24 19:03:32 tr-ircd Exp $ */ #include "struct.h" #include "common.h" #include "sys.h" #include "numeric.h" #include "msg.h" #include "channel.h" #include "s_conf.h" #include "zlink.h" #include "h.h" static char *token = TOK1_SVINFO; static struct Message _msgtab[] = { {MSG_SVINFO, 0, MAXPARA, M_SLOW, 0L, m_svinfo, m_ignore, m_ignore, m_svinfo, m_ignore} }; #ifndef STATIC_MODULES char *_version = "$Revision: 1.5 $"; void _modinit(void) { mod_add_cmd(_msgtab); tok1_msgtab[(u_char) *token].msg = _msgtab; } void _moddeinit(void) { mod_del_cmd(_msgtab); tok1_msgtab[(u_char) *token].msg = NULL; } #else void m_svinfo_init(void) { mod_add_cmd(_msgtab); tok1_msgtab[(u_char) *token].msg = _msgtab; } #endif /* * * m_svinfo * parv[0] = sender prefix * parv[1] = TS_CURRENT for the server * parv[2] = TS_MIN for the server * parv[3] = server is standalone or connected to non-TS only * parv[4] = server's idea of UTC time */ int m_svinfo(aClient *cptr, aClient *sptr, int parc, char *parv[]) { time_t deltat, tmptime, theirtime; if (!IsServer(sptr) || !MyConnect(sptr)) return 0; if (!DoesTS(sptr)) { sendto_one_server(cptr, NULL, TOK1_ERROR, ":No Access (Your side uses too old TS Protocol)"); sendto_gnotice("Access denied to %s (Version mismatch - TS Protocol too old)", sptr->name); return exit_client(cptr, cptr, "Protocol mismatch"); } if (!IsTS7(sptr)) { sendto_one_server(cptr, NULL, TOK1_ERROR, ":No Access (Your side uses too incompatible TS Protocol)"); sendto_gnotice("Access denied to %s (Version mismatch - TS Protocol incompatible)", sptr->name); return exit_client(cptr, cptr, "Protocol mismatch"); } if (parc == 2) { if (irc_strcmp(parv[1], "ZIP") == 0) { SetZipIn(sptr); sptr->serv->zin = input_unzipstream(); sendto_gnotice("from %C: Input from %s is now compressed", &me, get_client_name(sptr, HIDEME)); sendto_serv_butone(sptr, &me, TOK1_GNOTICE, ":Input from %s is now compressed", get_client_name(sptr, HIDEME)); return ZIP_NEXT_BUFFER; } } if (parc == 5) { if (TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN) { /* * 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_gnotice("Link %s dropped, wrong TS protocol version (%s,%s)", get_client_name(sptr, HIDEME), parv[1], parv[2]); return exit_client(sptr, sptr, "Incompatible TS version"); } tmptime = time(NULL); theirtime = atol(parv[4]); deltat = abs(theirtime - tmptime); if (deltat > ServerOpts.ts_max_delta) { sendto_gnotice ("Link %s dropped, excessive TS delta (my TS=%ld, their TS=%ld, delta=%ld)", get_client_name(sptr, HIDEME), tmptime, theirtime, deltat); sendto_serv_butone(sptr, &me, TOK1_GNOTICE, ":Link %s dropped, excessive TS delta (delta=%ld)", get_client_name(sptr, HIDEME), deltat); return exit_client(sptr, sptr, "Excessive TS delta"); } if (deltat > ServerOpts.ts_warn_delta) { sendto_gnotice ("Link %s notable TS delta (my TS=%ld, their TS=%ld, delta=%ld)", get_client_name(sptr, HIDEME), tmptime, theirtime, deltat); } } return 0; }