2 * IRC - Internet Relay Chat, ircd/m_squit.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
6 * See file AUTHORS in IRC package for additional names of
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 1, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #include "ircd_chattr.h"
31 #include "ircd_reply.h"
32 #include "ircd_string.h"
49 * parv[0] = sender prefix
50 * parv[1] = server name
52 * parv[parc-1] = comment
54 * No longer supports wildcards from servers.
55 * No longer squits a server that gave us an malformed squit message.
59 int ms_squit(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
61 const char* server = parv[1];
67 return need_more_params(sptr, "SQUIT");
69 comment = parv[parc-1];
71 if (BadPtr(parv[parc - 1]))
72 comment = cli_name(sptr);
74 acptr = FindServer(server);
77 acptr = FindNServer(server);
80 protocol_violation(sptr, "Issued SQUIT for unknown server %s (ignored)",
82 Debug((DEBUG_NOTICE, "Ignoring SQUIT to an unknown server"));
86 /* If they are squitting me, we reverse it */
88 acptr = cptr; /* Bugfix by Prefect */
91 timestamp = atoi(parv[2]);
93 protocol_violation(cptr, "SQUIT with no timestamp/reason");
95 /* If atoi(parv[2]) == 0 we must indeed squit !
96 * It will be our neighbour.
98 if ( timestamp != 0 && timestamp != cli_serv(acptr)->timestamp)
100 protocol_violation(sptr, "Issued SQUIT for %C with wrong timestamp %Tu "
101 "(%Tu) (ignored)", acptr, timestamp,
102 cli_serv(acptr)->timestamp);
103 Debug((DEBUG_NOTICE, "Ignoring SQUIT with the wrong timestamp"));
107 return exit_client(cptr, acptr, sptr, comment);
113 * parv[0] = sender prefix
114 * parv[1] = server name
115 * parv[2] = comment (optional)
118 int mo_squit(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
121 struct Client *acptr;
122 struct Client *acptr2;
126 return need_more_params(sptr, "SQUIT");
128 if (parc < 3 || BadPtr(parv[2]))
129 comment = cli_name(sptr);
135 * The following allows wild cards in SQUIT. Only usefull
136 * when the command is issued by an oper.
138 for (acptr = GlobalClientList; (acptr = next_client(acptr, server));
139 acptr = cli_next(acptr)) {
140 if (IsServer(acptr) || IsMe(acptr))
144 /* Not found? Bugger. */
145 if (!acptr || IsMe(acptr))
146 return send_reply(sptr, ERR_NOSUCHSERVER, server);
149 * Look for a matching server that is closer,
150 * that way we won't accidently squit two close
151 * servers like davis.* and davis-r.* when typing
154 for (acptr2 = cli_serv(acptr)->up; acptr2 != &me;
155 acptr2 = cli_serv(acptr2)->up)
156 if (!match(server, cli_name(acptr2)))
159 /* Disallow local opers to squit remote servers */
160 if (IsLocOp(sptr) && !MyConnect(acptr))
161 return send_reply(sptr, ERR_NOPRIVILEGES);
163 return exit_client(cptr, acptr, sptr, comment);