irc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. * ngIRCd -- The Next Generation IRC Daemon
  3. * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. * Please read the file COPYING, README and AUTHORS for more information.
  10. */
  11. #include "portab.h"
  12. /**
  13. * @file
  14. * IRC commands
  15. */
  16. #include "imp.h"
  17. #include <assert.h>
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include "ngircd.h"
  21. #include "conn-func.h"
  22. #include "conf.h"
  23. #include "channel.h"
  24. #include "conn-encoding.h"
  25. #include "defines.h"
  26. #include "irc-write.h"
  27. #include "log.h"
  28. #include "match.h"
  29. #include "messages.h"
  30. #include "parse.h"
  31. #include "tool.h"
  32. #include "exp.h"
  33. #include "irc.h"
  34. static char *Option_String PARAMS((CONN_ID Idx));
  35. static bool Send_Message PARAMS((CLIENT *Client, REQUEST *Req, int ForceType,
  36. bool SendErrors));
  37. static bool Send_Message_Mask PARAMS((CLIENT *from, char *command,
  38. char *targetMask, char *message,
  39. bool SendErrors));
  40. /**
  41. * Check if a list limit is reached and inform client accordingly.
  42. *
  43. * @param From The client.
  44. * @param Count Reply item count.
  45. * @param Limit Reply limit.
  46. * @param Name Name of the list.
  47. * @return true if list limit has been reached; false otherwise.
  48. */
  49. GLOBAL bool
  50. IRC_CheckListTooBig(CLIENT *From, const int Count, const int Limit,
  51. const char *Name)
  52. {
  53. assert(From != NULL);
  54. assert(Count >= 0);
  55. assert(Limit > 0);
  56. assert(Name != NULL);
  57. if (Count < Limit)
  58. return false;
  59. (void)IRC_WriteStrClient(From,
  60. "NOTICE %s :%s list limit (%d) reached!",
  61. Client_ID(From), Name, Limit);
  62. IRC_SetPenalty(From, 2);
  63. return true;
  64. }
  65. GLOBAL bool
  66. IRC_ERROR( CLIENT *Client, REQUEST *Req )
  67. {
  68. assert( Client != NULL );
  69. assert( Req != NULL );
  70. if (Req->argc < 1)
  71. Log(LOG_NOTICE, "Got ERROR from \"%s\"!",
  72. Client_Mask(Client));
  73. else
  74. Log(LOG_NOTICE, "Got ERROR from \"%s\": \"%s\"!",
  75. Client_Mask(Client), Req->argv[0]);
  76. return CONNECTED;
  77. } /* IRC_ERROR */
  78. /**
  79. * Handler for the IRC "KILL" command.
  80. *
  81. * This function implements the IRC command "KILL" wich is used to selectively
  82. * disconnect clients. It can be used by IRC operators and servers, for example
  83. * to "solve" nick collisions after netsplits. See RFC 2812 section 3.7.1.
  84. *
  85. * Please note that this function is also called internally, without a real
  86. * KILL command being received over the network! Client is Client_ThisServer()
  87. * in this case, and the prefix in Req is NULL.
  88. *
  89. * @param Client The client from which this command has been received
  90. * or Client_ThisServer() when generated interanlly.
  91. * @param Req Request structure with prefix and all parameters.
  92. * @returns CONNECTED or DISCONNECTED.
  93. */
  94. GLOBAL bool
  95. IRC_KILL( CLIENT *Client, REQUEST *Req )
  96. {
  97. CLIENT *prefix, *c;
  98. char reason[COMMAND_LEN], *msg;
  99. CONN_ID my_conn, conn;
  100. assert (Client != NULL);
  101. assert (Req != NULL);
  102. if (Client_Type(Client) != CLIENT_SERVER && !Client_OperByMe(Client))
  103. return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
  104. Client_ID(Client));
  105. if (Req->argc != 2)
  106. return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
  107. Client_ID(Client), Req->command);
  108. /* Get prefix (origin); use the client if no prefix is given. */
  109. if (Req->prefix)
  110. prefix = Client_Search(Req->prefix);
  111. else
  112. prefix = Client;
  113. /* Log a warning message and use this server as origin when the
  114. * prefix (origin) is invalid. */
  115. if (!prefix) {
  116. Log(LOG_WARNING, "Got KILL with invalid prefix: \"%s\"!",
  117. Req->prefix );
  118. prefix = Client_ThisServer();
  119. }
  120. if (Client != Client_ThisServer())
  121. Log(LOG_NOTICE|LOG_snotice,
  122. "Got KILL command from \"%s\" for \"%s\": %s",
  123. Client_Mask(prefix), Req->argv[0], Req->argv[1]);
  124. /* Build reason string: Prefix the "reason" if the originator is a
  125. * regular user, so users can't spoof KILLs of servers. */
  126. if (Client_Type(Client) == CLIENT_USER)
  127. snprintf(reason, sizeof(reason), "KILLed by %s: %s",
  128. Client_ID(Client), Req->argv[1]);
  129. else
  130. strlcpy(reason, Req->argv[1], sizeof(reason));
  131. /* Inform other servers */
  132. IRC_WriteStrServersPrefix(Client, prefix, "KILL %s :%s",
  133. Req->argv[0], reason);
  134. /* Save ID of this connection */
  135. my_conn = Client_Conn( Client );
  136. /* Do we host such a client? */
  137. c = Client_Search( Req->argv[0] );
  138. if( c )
  139. {
  140. if(( Client_Type( c ) != CLIENT_USER ) &&
  141. ( Client_Type( c ) != CLIENT_GOTNICK ))
  142. {
  143. /* Target of this KILL is not a regular user, this is
  144. * invalid! So we ignore this case if we received a
  145. * regular KILL from the network and try to kill the
  146. * client/connection anyway (but log an error!) if the
  147. * origin is the local server. */
  148. if( Client != Client_ThisServer( ))
  149. {
  150. /* Invalid KILL received from remote */
  151. if( Client_Type( c ) == CLIENT_SERVER )
  152. msg = ERR_CANTKILLSERVER_MSG;
  153. else
  154. msg = ERR_NOPRIVILEGES_MSG;
  155. return IRC_WriteStrClient( Client, msg,
  156. Client_ID( Client ));
  157. }
  158. Log( LOG_ERR, "Got KILL for invalid client type: %d, \"%s\"!",
  159. Client_Type( c ), Req->argv[0] );
  160. }
  161. /* Kill the client NOW:
  162. * - Close the local connection (if there is one),
  163. * - Destroy the CLIENT structure for remote clients.
  164. * Note: Conn_Close() removes the CLIENT structure as well. */
  165. conn = Client_Conn( c );
  166. if(conn > NONE)
  167. Conn_Close(conn, NULL, reason, true);
  168. else
  169. Client_Destroy(c, NULL, reason, false);
  170. }
  171. else
  172. Log( LOG_NOTICE, "Client with nick \"%s\" is unknown here.", Req->argv[0] );
  173. /* Are we still connected or were we killed, too? */
  174. if(( my_conn > NONE ) && ( Conn_GetClient( my_conn )))
  175. return CONNECTED;
  176. else
  177. return DISCONNECTED;
  178. } /* IRC_KILL */
  179. /**
  180. * Handler for the IRC command NOTICE.
  181. */
  182. GLOBAL bool
  183. IRC_NOTICE(CLIENT *Client, REQUEST *Req)
  184. {
  185. return Send_Message(Client, Req, CLIENT_USER, false);
  186. } /* IRC_NOTICE */
  187. /**
  188. * Handler for the IRC command PRIVMSG.
  189. */
  190. GLOBAL bool
  191. IRC_PRIVMSG(CLIENT *Client, REQUEST *Req)
  192. {
  193. return Send_Message(Client, Req, CLIENT_USER, true);
  194. } /* IRC_PRIVMSG */
  195. /**
  196. * Handler for the IRC command SQUERY.
  197. */
  198. GLOBAL bool
  199. IRC_SQUERY(CLIENT *Client, REQUEST *Req)
  200. {
  201. return Send_Message(Client, Req, CLIENT_SERVICE, true);
  202. } /* IRC_SQUERY */
  203. GLOBAL bool
  204. IRC_TRACE( CLIENT *Client, REQUEST *Req )
  205. {
  206. CLIENT *from, *target, *c;
  207. CONN_ID idx, idx2;
  208. char user[CLIENT_USER_LEN];
  209. assert( Client != NULL );
  210. assert( Req != NULL );
  211. /* Bad number of arguments? */
  212. if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NORECIPIENT_MSG, Client_ID( Client ), Req->command );
  213. /* Search sender */
  214. if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
  215. else from = Client;
  216. if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
  217. /* Search target */
  218. if( Req->argc == 1 ) target = Client_Search( Req->argv[0] );
  219. else target = Client_ThisServer( );
  220. /* Forward command to other server? */
  221. if( target != Client_ThisServer( ))
  222. {
  223. if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
  224. /* Send RPL_TRACELINK back to initiator */
  225. idx = Client_Conn( Client ); assert( idx > NONE );
  226. idx2 = Client_Conn( Client_NextHop( target )); assert( idx2 > NONE );
  227. if( ! IRC_WriteStrClient( from, RPL_TRACELINK_MSG, Client_ID( from ), PACKAGE_NAME, PACKAGE_VERSION, Client_ID( target ), Client_ID( Client_NextHop( target )), Option_String( idx2 ), time( NULL ) - Conn_StartTime( idx2 ), Conn_SendQ( idx ), Conn_SendQ( idx2 ))) return DISCONNECTED;
  228. /* Forward command */
  229. IRC_WriteStrClientPrefix( target, from, "TRACE %s", Req->argv[0] );
  230. return CONNECTED;
  231. }
  232. /* Infos about all connected servers */
  233. c = Client_First( );
  234. while( c )
  235. {
  236. if( Client_Conn( c ) > NONE )
  237. {
  238. /* Local client */
  239. if( Client_Type( c ) == CLIENT_SERVER )
  240. {
  241. /* Server link */
  242. strlcpy( user, Client_User( c ), sizeof( user ));
  243. if( user[0] == '~' ) strlcpy( user, "unknown", sizeof( user ));
  244. if( ! IRC_WriteStrClient( from, RPL_TRACESERVER_MSG, Client_ID( from ), Client_ID( c ), user, Client_Hostname( c ), Client_Mask( Client_ThisServer( )), Option_String( Client_Conn( c )))) return DISCONNECTED;
  245. }
  246. if(( Client_Type( c ) == CLIENT_USER ) && ( strchr( Client_Modes( c ), 'o' )))
  247. {
  248. /* IRC Operator */
  249. if( ! IRC_WriteStrClient( from, RPL_TRACEOPERATOR_MSG, Client_ID( from ), Client_ID( c ))) return DISCONNECTED;
  250. }
  251. }
  252. c = Client_Next( c );
  253. }
  254. IRC_SetPenalty( Client, 3 );
  255. return IRC_WriteStrClient( from, RPL_TRACEEND_MSG, Client_ID( from ), Conf_ServerName, PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_DebugLevel );
  256. } /* IRC_TRACE */
  257. GLOBAL bool
  258. IRC_HELP( CLIENT *Client, REQUEST *Req )
  259. {
  260. COMMAND *cmd;
  261. assert( Client != NULL );
  262. assert( Req != NULL );
  263. /* Bad number of arguments? */
  264. if( Req->argc > 0 ) return IRC_WriteStrClient( Client, ERR_NORECIPIENT_MSG, Client_ID( Client ), Req->command );
  265. cmd = Parse_GetCommandStruct( );
  266. while( cmd->name )
  267. {
  268. if( ! IRC_WriteStrClient( Client, "NOTICE %s :%s", Client_ID( Client ), cmd->name )) return DISCONNECTED;
  269. cmd++;
  270. }
  271. IRC_SetPenalty( Client, 2 );
  272. return CONNECTED;
  273. } /* IRC_HELP */
  274. static char *
  275. #ifdef ZLIB
  276. Option_String(CONN_ID Idx)
  277. #else
  278. Option_String(UNUSED CONN_ID Idx)
  279. #endif
  280. {
  281. static char option_txt[8];
  282. #ifdef ZLIB
  283. UINT16 options;
  284. options = Conn_Options(Idx);
  285. #endif
  286. strcpy(option_txt, "F"); /* No idea what this means, but the
  287. * original ircd sends it ... */
  288. #ifdef ZLIB
  289. if(options & CONN_ZIP) /* zlib compression supported. */
  290. strcat(option_txt, "z");
  291. #endif
  292. return option_txt;
  293. } /* Option_String */
  294. static bool
  295. Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
  296. {
  297. CLIENT *cl, *from;
  298. CL2CHAN *cl2chan;
  299. CHANNEL *chan;
  300. char *currentTarget = Req->argv[0];
  301. char *lastCurrentTarget = NULL;
  302. char *message = NULL;
  303. assert(Client != NULL);
  304. assert(Req != NULL);
  305. if (Req->argc == 0) {
  306. if (!SendErrors)
  307. return CONNECTED;
  308. return IRC_WriteStrClient(Client, ERR_NORECIPIENT_MSG,
  309. Client_ID(Client), Req->command);
  310. }
  311. if (Req->argc == 1) {
  312. if (!SendErrors)
  313. return CONNECTED;
  314. return IRC_WriteStrClient(Client, ERR_NOTEXTTOSEND_MSG,
  315. Client_ID(Client));
  316. }
  317. if (Req->argc > 2) {
  318. if (!SendErrors)
  319. return CONNECTED;
  320. return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
  321. Client_ID(Client), Req->command);
  322. }
  323. if (Client_Type(Client) == CLIENT_SERVER)
  324. from = Client_Search(Req->prefix);
  325. else
  326. from = Client;
  327. if (!from)
  328. return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
  329. Client_ID(Client), Req->prefix);
  330. #ifdef ICONV
  331. if (Client_Conn(Client) > NONE)
  332. message = Conn_EncodingFrom(Client_Conn(Client), Req->argv[1]);
  333. else
  334. #endif
  335. message = Req->argv[1];
  336. /* handle msgtarget = msgto *("," msgto) */
  337. currentTarget = strtok_r(currentTarget, ",", &lastCurrentTarget);
  338. ngt_UpperStr(Req->command);
  339. while (currentTarget) {
  340. /* Check for and handle valid <msgto> of form:
  341. * RFC 2812 2.3.1:
  342. * msgto = channel / ( user [ "%" host ] "@" servername )
  343. * msgto =/ ( user "%" host ) / targetmask
  344. * msgto =/ nickname / ( nickname "!" user "@" host )
  345. */
  346. if (strchr(currentTarget, '!') == NULL)
  347. /* nickname */
  348. cl = Client_Search(currentTarget);
  349. else
  350. cl = NULL;
  351. if (cl == NULL) {
  352. /* If currentTarget isn't a nickname check for:
  353. * user ["%" host] "@" servername
  354. * user "%" host
  355. * nickname "!" user "@" host
  356. */
  357. char target[COMMAND_LEN];
  358. char * nick = NULL;
  359. char * user = NULL;
  360. char * host = NULL;
  361. char * server = NULL;
  362. strlcpy(target, currentTarget, COMMAND_LEN);
  363. server = strchr(target, '@');
  364. if (server) {
  365. *server = '\0';
  366. server++;
  367. }
  368. host = strchr(target, '%');
  369. if (host) {
  370. *host = '\0';
  371. host++;
  372. }
  373. user = strchr(target, '!');
  374. if (user) {
  375. /* msgto form: nick!user@host */
  376. *user = '\0';
  377. user++;
  378. nick = target;
  379. host = server; /* not "@server" but "@host" */
  380. } else {
  381. user = target;
  382. }
  383. for (cl = Client_First(); cl != NULL; cl = Client_Next(cl)) {
  384. if (Client_Type(cl) != CLIENT_USER &&
  385. Client_Type(cl) != CLIENT_SERVICE)
  386. continue;
  387. if (nick != NULL && host != NULL) {
  388. if (strcasecmp(nick, Client_ID(cl)) == 0 &&
  389. strcasecmp(user, Client_User(cl)) == 0 &&
  390. strcasecmp(host, Client_HostnameDisplayed(cl)) == 0)
  391. break;
  392. else
  393. continue;
  394. }
  395. if (strcasecmp(user, Client_User(cl)) != 0)
  396. continue;
  397. if (host != NULL && strcasecmp(host,
  398. Client_HostnameDisplayed(cl)) != 0)
  399. continue;
  400. if (server != NULL && strcasecmp(server,
  401. Client_ID(Client_Introducer(cl))) != 0)
  402. continue;
  403. break;
  404. }
  405. }
  406. if (cl) {
  407. /* Target is a user, enforce type */
  408. #ifndef STRICT_RFC
  409. if (Client_Type(cl) != ForceType &&
  410. !(ForceType == CLIENT_USER &&
  411. (Client_Type(cl) == CLIENT_USER ||
  412. Client_Type(cl) == CLIENT_SERVICE))) {
  413. #else
  414. if (Client_Type(cl) != ForceType) {
  415. #endif
  416. if (SendErrors && !IRC_WriteStrClient(
  417. from, ERR_NOSUCHNICK_MSG,Client_ID(from),
  418. currentTarget))
  419. return DISCONNECTED;
  420. goto send_next_target;
  421. }
  422. #ifndef STRICT_RFC
  423. if (ForceType == CLIENT_SERVICE &&
  424. (Conn_Options(Client_Conn(Client_NextHop(cl)))
  425. & CONN_RFC1459)) {
  426. /* SQUERY command but RFC 1459 link: convert
  427. * request to PRIVMSG command */
  428. Req->command = "PRIVMSG";
  429. }
  430. #endif
  431. if (Client_HasMode(cl, 'b') &&
  432. !Client_HasMode(from, 'R') &&
  433. !Client_HasMode(from, 'o') &&
  434. !(Client_Type(from) == CLIENT_SERVER) &&
  435. !(Client_Type(from) == CLIENT_SERVICE)) {
  436. if (SendErrors && !IRC_WriteStrClient(from,
  437. ERR_NONONREG_MSG,
  438. Client_ID(from), Client_ID(cl)))
  439. return DISCONNECTED;
  440. goto send_next_target;
  441. }
  442. if (Client_HasMode(cl, 'C')) {
  443. cl2chan = Channel_FirstChannelOf(cl);
  444. while (cl2chan) {
  445. chan = Channel_GetChannel(cl2chan);
  446. if (Channel_IsMemberOf(chan, from))
  447. break;
  448. cl2chan = Channel_NextChannelOf(cl, cl2chan);
  449. }
  450. if (!cl2chan) {
  451. if (SendErrors && !IRC_WriteStrClient(
  452. from, ERR_NOTONSAMECHANNEL_MSG,
  453. Client_ID(from), Client_ID(cl)))
  454. return DISCONNECTED;
  455. goto send_next_target;
  456. }
  457. }
  458. if (SendErrors && (Client_Type(Client) != CLIENT_SERVER)
  459. && strchr(Client_Modes(cl), 'a')) {
  460. /* Target is away */
  461. if (!IRC_WriteStrClient(from, RPL_AWAY_MSG,
  462. Client_ID(from),
  463. Client_ID(cl),
  464. Client_Away(cl)))
  465. return DISCONNECTED;
  466. }
  467. if (Client_Conn(from) > NONE) {
  468. Conn_UpdateIdle(Client_Conn(from));
  469. }
  470. if (!IRC_WriteStrClientPrefix(cl, from, "%s %s :%s",
  471. Req->command, Client_ID(cl),
  472. message))
  473. return DISCONNECTED;
  474. } else if (ForceType != CLIENT_SERVICE
  475. && (chan = Channel_Search(currentTarget))) {
  476. if (!Channel_Write(chan, from, Client, Req->command,
  477. SendErrors, message))
  478. return DISCONNECTED;
  479. } else if (ForceType != CLIENT_SERVICE
  480. /* $#: server/target mask, RFC 2812, sec. 3.3.1 */
  481. && strchr("$#", currentTarget[0])
  482. && strchr(currentTarget, '.')) {
  483. /* targetmask */
  484. if (!Send_Message_Mask(from, Req->command, currentTarget,
  485. message, SendErrors))
  486. return DISCONNECTED;
  487. } else {
  488. if (!SendErrors)
  489. return CONNECTED;
  490. if (!IRC_WriteStrClient(from, ERR_NOSUCHNICK_MSG,
  491. Client_ID(from), currentTarget))
  492. return DISCONNECTED;
  493. }
  494. send_next_target:
  495. currentTarget = strtok_r(NULL, ",", &lastCurrentTarget);
  496. if (currentTarget)
  497. Conn_SetPenalty(Client_Conn(Client), 1);
  498. }
  499. return CONNECTED;
  500. } /* Send_Message */
  501. static bool
  502. Send_Message_Mask(CLIENT * from, char * command, char * targetMask,
  503. char * message, bool SendErrors)
  504. {
  505. CLIENT *cl;
  506. bool client_match;
  507. char *mask = targetMask + 1;
  508. const char *check_wildcards;
  509. cl = NULL;
  510. if (strchr(Client_Modes(from), 'o') == NULL) {
  511. if (!SendErrors)
  512. return true;
  513. return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG,
  514. Client_ID(from));
  515. }
  516. /*
  517. * RFC 2812, sec. 3.3.1 requires that targetMask have at least one
  518. * dot (".") and no wildcards ("*", "?") following the last one.
  519. */
  520. check_wildcards = strrchr(targetMask, '.');
  521. assert(check_wildcards != NULL);
  522. if (check_wildcards &&
  523. check_wildcards[strcspn(check_wildcards, "*?")])
  524. {
  525. if (!SendErrors)
  526. return true;
  527. return IRC_WriteStrClient(from, ERR_WILDTOPLEVEL, targetMask);
  528. }
  529. /* #: hostmask, see RFC 2812, sec. 3.3.1 */
  530. if (targetMask[0] == '#') {
  531. for (cl = Client_First(); cl != NULL; cl = Client_Next(cl)) {
  532. if (Client_Type(cl) != CLIENT_USER)
  533. continue;
  534. client_match = MatchCaseInsensitive(mask, Client_Hostname(cl));
  535. if (client_match)
  536. if (!IRC_WriteStrClientPrefix(cl, from, "%s %s :%s",
  537. command, Client_ID(cl), message))
  538. return false;
  539. }
  540. } else {
  541. assert(targetMask[0] == '$'); /* $: server mask, see RFC 2812, sec. 3.3.1 */
  542. for (cl = Client_First(); cl != NULL; cl = Client_Next(cl)) {
  543. if (Client_Type(cl) != CLIENT_USER)
  544. continue;
  545. client_match = MatchCaseInsensitive(mask,
  546. Client_ID(Client_Introducer(cl)));
  547. if (client_match)
  548. if (!IRC_WriteStrClientPrefix(cl, from, "%s %s :%s",
  549. command, Client_ID(cl), message))
  550. return false;
  551. }
  552. }
  553. return CONNECTED;
  554. } /* Send_Message_Mask */
  555. /* -eof- */