2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
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.
26 #include "conn-func.h"
35 #include "irc-write.h"
38 #include "irc-login.h"
41 static bool Hello_User PARAMS(( CLIENT *Client ));
42 static void Kill_Nick PARAMS(( char *Nick, char *Reason ));
43 static void Introduce_Client PARAMS((CLIENT *To, CLIENT *Client, int Type));
44 static void cb_introduceClient PARAMS((CLIENT *Client, CLIENT *Prefix,
49 * Handler for the IRC command "PASS".
50 * See RFC 2813 section 4.1.1, and RFC 2812 section 3.1.1.
53 IRC_PASS( CLIENT *Client, REQUEST *Req )
55 char *type, *orig_flags;
56 int protohigh, protolow;
58 assert( Client != NULL );
59 assert( Req != NULL );
61 /* Return an error if this is not a local client */
62 if (Client_Conn(Client) <= NONE)
63 return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
64 Client_ID(Client), Req->command);
66 if (Client_Type(Client) == CLIENT_UNKNOWN && Req->argc == 1) {
67 /* Not yet registered "unknown" connection, PASS with one
68 * argument: either a regular client, service, or server
69 * using the old RFC 1459 section 4.1.1 syntax. */
70 LogDebug("Connection %d: got PASS command (RFC 1459) ...",
72 } else if ((Client_Type(Client) == CLIENT_UNKNOWN ||
73 Client_Type(Client) == CLIENT_UNKNOWNSERVER) &&
74 (Req->argc == 3 || Req->argc == 4)) {
75 /* Not yet registered "unknown" connection or outgoing server
76 * link, PASS with three or four argument: server using the
77 * RFC 2813 section 4.1.1 syntax. */
78 LogDebug("Connection %d: got PASS command (RFC 2813, new server link) ...",
80 } else if (Client_Type(Client) == CLIENT_UNKNOWN ||
81 Client_Type(Client) == CLIENT_UNKNOWNSERVER) {
82 /* Unregistered connection, but wrong number of arguments: */
83 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
84 Client_ID(Client), Req->command);
86 /* Registered connection, PASS command is not allowed! */
87 return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
91 Client_SetPassword(Client, Req->argv[0]);
93 /* Protocol version */
94 if (Req->argc >= 2 && strlen(Req->argv[1]) >= 4) {
100 Req->argv[1][4] = '\0';
101 protolow = atoi(&Req->argv[1][2]);
102 Req->argv[1][2] = '\0';
103 protohigh = atoi(Req->argv[1]);
105 Req->argv[1][2] = c2;
106 Req->argv[1][4] = c4;
108 Client_SetType(Client, CLIENT_GOTPASS_2813);
110 protohigh = protolow = 0;
111 Client_SetType(Client, CLIENT_GOTPASS);
114 /* Protocol type, see doc/Protocol.txt */
115 if (Req->argc >= 2 && strlen(Req->argv[1]) > 4)
116 type = &Req->argv[1][4];
120 /* Protocol flags/options */
122 orig_flags = Req->argv[3];
126 /* Implementation, version and IRC+ flags */
127 if (Req->argc >= 3) {
128 char *impl, *ptr, *serverver, *flags;
131 ptr = strchr(impl, '|');
135 if (type && strcmp(type, PROTOIRCPLUS) == 0) {
136 /* The peer seems to be a server which supports the
137 * IRC+ protocol (see doc/Protocol.txt). */
139 flags = strchr(serverver, ':');
146 "Peer announces itself as %s-%s using protocol %d.%d/IRC+ (flags: \"%s\").",
147 impl, serverver, protohigh, protolow, flags);
149 /* The peer seems to be a server supporting the
150 * "original" IRC protocol (RFC 2813). */
151 if (strchr(orig_flags, 'Z'))
156 "Peer announces itself as \"%s\" using protocol %d.%d (flags: \"%s\").",
157 impl, protohigh, protolow, flags);
159 Client_SetFlags(Client, flags);
167 * IRC "NICK" command.
168 * This function implements the IRC command "NICK" which is used to register
169 * with the server, to change already registered nicknames and to introduce
170 * new users which are connected to other servers.
173 IRC_NICK( CLIENT *Client, REQUEST *Req )
175 CLIENT *intr_c, *target, *c;
176 char *nick, *user, *hostname, *modes, *info;
179 assert( Client != NULL );
180 assert( Req != NULL );
182 /* Some IRC clients, for example BitchX, send the NICK and USER
183 * commands in the wrong order ... */
184 if(Client_Type(Client) == CLIENT_UNKNOWN
185 || Client_Type(Client) == CLIENT_GOTPASS
186 || Client_Type(Client) == CLIENT_GOTNICK
188 || Client_Type(Client) == CLIENT_GOTUSER
190 || Client_Type(Client) == CLIENT_USER
191 || Client_Type(Client) == CLIENT_SERVICE
192 || (Client_Type(Client) == CLIENT_SERVER && Req->argc == 1))
194 /* User registration or change of nickname */
196 /* Wrong number of arguments? */
198 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG,
202 /* Search "target" client */
203 if( Client_Type( Client ) == CLIENT_SERVER )
205 target = Client_Search( Req->prefix );
207 return IRC_WriteStrClient( Client,
214 /* Is this a restricted client? */
215 if( Client_HasMode( Client, 'r' ))
216 return IRC_WriteStrClient( Client,
218 Client_ID( Client ));
224 /* If the clients tries to change to its own nickname we won't
225 * do anything. This is how the original ircd behaves and some
226 * clients (for example Snak) expect it to be like this.
227 * But I doubt that this is "really the right thing" ... */
228 if( strcmp( Client_ID( target ), Req->argv[0] ) == 0 )
232 /* Check that the new nickname is available. Special case:
233 * the client only changes from/to upper to lower case. */
234 if( strcasecmp( Client_ID( target ), Req->argv[0] ) != 0 )
236 if( ! Client_CheckNick( target, Req->argv[0] ))
240 if (Client_Type(target) != CLIENT_USER &&
241 Client_Type(target) != CLIENT_SERVICE &&
242 Client_Type(target) != CLIENT_SERVER) {
244 LogDebug("Connection %d: got valid NICK command ...",
245 Client_Conn( Client ));
247 /* Register new nickname of this client */
248 Client_SetID( target, Req->argv[0] );
250 /* If we received a valid USER command already then
251 * register the new client! */
252 if( Client_Type( Client ) == CLIENT_GOTUSER )
253 return Hello_User( Client );
255 Client_SetType( Client, CLIENT_GOTNICK );
257 /* Nickname change */
258 if (Client_Conn(target) > NONE) {
261 "%s \"%s\" changed nick (connection %d): \"%s\" -> \"%s\".",
262 Client_TypeText(target), Client_Mask(target),
263 Client_Conn(target), Client_ID(target),
265 Conn_UpdateIdle(Client_Conn(target));
268 LogDebug("%s \"%s\" changed nick: \"%s\" -> \"%s\".",
269 Client_TypeText(target),
270 Client_Mask(target), Client_ID(target),
274 /* Inform all users and servers (which have to know)
275 * of this nickname change */
276 if( Client_Type( Client ) == CLIENT_USER )
277 IRC_WriteStrClientPrefix( Client, Client,
280 IRC_WriteStrServersPrefix( Client, target,
281 "NICK :%s", Req->argv[0] );
282 IRC_WriteStrRelatedPrefix( target, target, false,
283 "NICK :%s", Req->argv[0] );
285 /* Register old nickname for WHOWAS queries */
286 Client_RegisterWhowas( target );
288 /* Save new nickname */
289 Client_SetID( target, Req->argv[0] );
291 IRC_SetPenalty( target, 2 );
295 } else if(Client_Type(Client) == CLIENT_SERVER ||
296 Client_Type(Client) == CLIENT_SERVICE) {
297 /* Server or service introduces new client */
299 /* Bad number of parameters? */
300 if (Req->argc != 2 && Req->argc != 7)
301 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
302 Client_ID(Client), Req->command);
304 if (Req->argc >= 7) {
305 /* RFC 2813 compatible syntax */
307 hops = atoi(Req->argv[1]);
309 hostname = Req->argv[3];
310 token = atoi(Req->argv[4]);
311 modes = Req->argv[5] + 1;
314 /* RFC 1459 compatible syntax */
318 hostname = Client_ID(Client);
319 token = atoi(Req->argv[1]);
324 c = Client_Search(nick);
327 * the new nick is already present on this server:
328 * the new and the old one have to be disconnected now.
330 Log( LOG_ERR, "Server %s introduces already registered nick \"%s\"!", Client_ID( Client ), Req->argv[0] );
331 Kill_Nick( Req->argv[0], "Nick collision" );
335 /* Find the Server this client is connected to */
336 intr_c = Client_GetFromToken(Client, token);
339 Log( LOG_ERR, "Server %s introduces nick \"%s\" on unknown server!?", Client_ID( Client ), Req->argv[0] );
340 Kill_Nick( Req->argv[0], "Unknown server" );
344 c = Client_NewRemoteUser(intr_c, nick, hops, user, hostname,
345 token, modes, info, true);
348 /* out of memory, need to disconnect client to keep network state consistent */
349 Log( LOG_ALERT, "Can't create client structure! (on connection %d)", Client_Conn( Client ));
350 Kill_Nick( Req->argv[0], "Server error" );
354 /* RFC 2813: client is now fully registered, inform all the
355 * other servers about the new user.
356 * RFC 1459: announce the new client only after receiving the
357 * USER command, first we need more information! */
359 LogDebug("Client \"%s\" is being registered (RFC 1459) ...",
361 Client_SetType(c, CLIENT_GOTNICK);
363 Introduce_Client(Client, c, CLIENT_USER);
367 else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
372 * Handler for the IRC command "USER".
375 IRC_USER(CLIENT * Client, REQUEST * Req)
382 assert(Client != NULL);
385 if (Client_Type(Client) == CLIENT_GOTNICK ||
387 Client_Type(Client) == CLIENT_UNKNOWN ||
389 Client_Type(Client) == CLIENT_GOTPASS)
393 return IRC_WriteStrClient(Client,
394 ERR_NEEDMOREPARAMS_MSG,
400 ptr = Client_User(Client);
401 if (!ptr || !*ptr || *ptr == '~')
402 Client_SetUser(Client, Req->argv[0], false);
404 Client_SetUser(Client, Req->argv[0], false);
407 /* "Real name" or user info text: Don't set it to the empty
408 * string, the original ircd can't deal with such "real names"
409 * (e. g. "USER user * * :") ... */
411 Client_SetInfo(Client, Req->argv[3]);
413 Client_SetInfo(Client, "-");
415 LogDebug("Connection %d: got valid USER command ...",
416 Client_Conn(Client));
417 if (Client_Type(Client) == CLIENT_GOTNICK)
418 return Hello_User(Client);
420 Client_SetType(Client, CLIENT_GOTUSER);
423 } else if (Client_Type(Client) == CLIENT_SERVER ||
424 Client_Type(Client) == CLIENT_SERVICE) {
425 /* Server/service updating an user */
427 return IRC_WriteStrClient(Client,
428 ERR_NEEDMOREPARAMS_MSG,
431 c = Client_Search(Req->prefix);
433 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
437 Client_SetUser(c, Req->argv[0], true);
438 Client_SetHostname(c, Req->argv[1]);
439 Client_SetInfo(c, Req->argv[3]);
441 LogDebug("Connection %d: got valid USER command for \"%s\".",
442 Client_Conn(Client), Client_Mask(c));
444 /* RFC 1459 style user registration?
445 * Introduce client to network: */
446 if (Client_Type(c) == CLIENT_GOTNICK)
447 Introduce_Client(Client, c, CLIENT_USER);
450 } else if (Client_Type(Client) == CLIENT_USER) {
451 /* Already registered connection */
452 return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
455 /* Unexpected/invalid connection state? */
456 return IRC_WriteStrClient(Client, ERR_NOTREGISTERED_MSG,
463 * Handler for the IRC command "SERVICE".
464 * This function implements IRC Services registration using the SERVICE command
465 * defined in RFC 2812 3.1.6 and RFC 2813 4.1.4.
466 * At the moment ngIRCd doesn't support directly linked services, so this
467 * function returns ERR_ERRONEUSNICKNAME when the SERVICE command has not been
468 * received from a peer server.
471 IRC_SERVICE(CLIENT *Client, REQUEST *Req)
474 char *nick, *user, *host, *info, *modes, *ptr;
477 assert(Client != NULL);
480 if (Client_Type(Client) != CLIENT_GOTPASS &&
481 Client_Type(Client) != CLIENT_SERVER)
482 return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
486 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
487 Client_ID(Client), Req->command);
489 if (Client_Type(Client) != CLIENT_SERVER)
490 return IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
491 Client_ID(Client), Req->argv[0]);
493 /* Bad number of parameters? */
495 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
496 Client_ID(Client), Req->command);
499 user = NULL; host = NULL;
500 token = atoi(Req->argv[1]);
501 hops = atoi(Req->argv[4]);
504 /* Validate service name ("nick name") */
505 c = Client_Search(nick);
507 /* Nick name collission: disconnect (KILL) both clients! */
508 Log(LOG_ERR, "Server %s introduces already registered service \"%s\"!",
509 Client_ID(Client), nick);
510 Kill_Nick(nick, "Nick collision");
514 /* Get the server to which the service is connected */
515 intr_c = Client_GetFromToken(Client, token);
517 Log(LOG_ERR, "Server %s introduces service \"%s\" on unknown server!?",
518 Client_ID(Client), nick);
519 Kill_Nick(nick, "Unknown server");
523 /* Get user and host name */
524 ptr = strchr(nick, '@');
530 host = Client_Hostname(intr_c);
531 ptr = strchr(nick, '!');
539 /* According to RFC 2812/2813 parameter 4 <type> "is currently reserved
540 * for future usage"; but we use it to transfer the modes and check
541 * that the first character is a '+' sign and ignore it otherwise. */
542 modes = (Req->argv[3][0] == '+') ? ++Req->argv[3] : "";
544 c = Client_NewRemoteUser(intr_c, nick, hops, user, host,
545 token, modes, info, true);
547 /* Couldn't create client structure, so KILL the service to
548 * keep network status consistent ... */
549 Log(LOG_ALERT, "Can't create client structure! (on connection %d)",
550 Client_Conn(Client));
551 Kill_Nick(nick, "Server error");
555 Introduce_Client(Client, c, CLIENT_SERVICE);
561 * Handler for the IRC command "WEBIRC".
562 * Syntax: WEBIRC <password> <username> <real-hostname> <real-IP-address>
565 IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
567 /* Exactly 4 parameters are requited */
569 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
570 Client_ID(Client), Req->command);
572 if (!Conf_WebircPwd[0] || strcmp(Req->argv[0], Conf_WebircPwd) != 0)
573 return IRC_WriteStrClient(Client, ERR_PASSWDMISMATCH_MSG,
576 LogDebug("Connection %d: got valid WEBIRC command: user=%s, host=%s, ip=%s",
577 Client_Conn(Client), Req->argv[1], Req->argv[2], Req->argv[3]);
579 Client_SetUser(Client, Req->argv[1], true);
580 Client_SetHostname(Client, Req->argv[2]);
586 IRC_QUIT( CLIENT *Client, REQUEST *Req )
589 char quitmsg[LINE_LEN];
591 assert( Client != NULL );
592 assert( Req != NULL );
594 /* Wrong number of arguments? */
596 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
599 strlcpy(quitmsg, Req->argv[0], sizeof quitmsg);
601 if ( Client_Type( Client ) == CLIENT_SERVER )
604 target = Client_Search( Req->prefix );
607 Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
611 Client_Destroy( target, "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
617 if (Req->argc == 1 && quitmsg[0] != '\"') {
618 /* " " to avoid confusion */
619 strlcpy(quitmsg, "\"", sizeof quitmsg);
620 strlcat(quitmsg, Req->argv[0], sizeof quitmsg-1);
621 strlcat(quitmsg, "\"", sizeof quitmsg );
624 /* User, Service, or not yet registered */
625 Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
633 IRC_PING(CLIENT *Client, REQUEST *Req)
635 CLIENT *target, *from;
637 assert(Client != NULL);
641 return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
644 /* Don't ignore additional arguments when in "strict" mode */
646 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
647 Client_ID(Client), Req->command);
651 /* A target has been specified ... */
652 target = Client_Search(Req->argv[1]);
654 if (!target || Client_Type(target) != CLIENT_SERVER)
655 return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
656 Client_ID(Client), Req->argv[1]);
658 if (target != Client_ThisServer()) {
659 /* Ok, we have to forward the PING */
660 if (Client_Type(Client) == CLIENT_SERVER)
661 from = Client_Search(Req->prefix);
665 return IRC_WriteStrClient(Client,
666 ERR_NOSUCHSERVER_MSG,
667 Client_ID(Client), Req->prefix);
669 return IRC_WriteStrClientPrefix(target, from,
670 "PING %s :%s", Req->argv[0],
675 if (Client_Type(Client) == CLIENT_SERVER) {
677 from = Client_Search(Req->prefix);
681 from = Client_ThisServer();
683 return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
684 Client_ID(Client), Req->prefix);
686 Log(LOG_DEBUG, "Connection %d: got PING, sending PONG ...",
687 Client_Conn(Client));
690 return IRC_WriteStrClient(Client, "PONG %s :%s",
691 Client_ID(from), Client_ID(Client));
693 /* Some clients depend on the argument being returned in the PONG
694 * reply (not mentioned in any RFC, though) */
695 return IRC_WriteStrClient(Client, "PONG %s :%s",
696 Client_ID(from), Req->argv[0]);
702 IRC_PONG(CLIENT *Client, REQUEST *Req)
704 CLIENT *target, *from;
707 assert(Client != NULL);
710 /* Wrong number of arguments? */
712 return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
715 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
716 Client_ID(Client), Req->command);
719 if (Req->argc == 2 && Client_Type(Client) == CLIENT_SERVER) {
720 target = Client_Search(Req->argv[0]);
722 return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
723 Client_ID(Client), Req->argv[0]);
725 from = Client_Search(Req->prefix);
727 if (target != Client_ThisServer() && target != from) {
728 /* Ok, we have to forward the message. */
730 return IRC_WriteStrClient(Client,
731 ERR_NOSUCHSERVER_MSG,
732 Client_ID(Client), Req->prefix);
734 if (Client_Type(Client_NextHop(target)) != CLIENT_SERVER)
738 return IRC_WriteStrClientPrefix(target, from,
739 "PONG %s :%s", s, Req->argv[1]);
743 /* The connection timestamp has already been updated when the data has
744 * been read from so socket, so we don't need to update it here. */
746 if (Client_Conn(Client) > NONE)
748 "Connection %d: received PONG. Lag: %ld seconds.",
750 time(NULL) - Conn_LastPing(Client_Conn(Client)));
753 "Connection %d: received PONG.", Client_Conn(Client));
760 Hello_User(CLIENT * Client)
762 assert(Client != NULL);
764 /* Check password ... */
765 if (strcmp(Client_Password(Client), Conf_ServerPwd) != 0) {
768 "Client \"%s\" rejected (connection %d): Bad password!",
769 Client_Mask(Client), Client_Conn(Client));
770 Conn_Close(Client_Conn(Client), NULL, "Bad password", true);
774 Introduce_Client(NULL, Client, CLIENT_USER);
776 if (!IRC_WriteStrClient
777 (Client, RPL_WELCOME_MSG, Client_ID(Client), Client_Mask(Client)))
779 if (!IRC_WriteStrClient
780 (Client, RPL_YOURHOST_MSG, Client_ID(Client),
781 Client_ID(Client_ThisServer()), PACKAGE_VERSION, TARGET_CPU,
782 TARGET_VENDOR, TARGET_OS))
784 if (!IRC_WriteStrClient
785 (Client, RPL_CREATED_MSG, Client_ID(Client), NGIRCd_StartStr))
787 if (!IRC_WriteStrClient
788 (Client, RPL_MYINFO_MSG, Client_ID(Client),
789 Client_ID(Client_ThisServer()), PACKAGE_VERSION, USERMODES,
793 /* Features supported by this server (005 numeric, ISUPPORT),
794 * see <http://www.irc.org/tech_docs/005.html> for details. */
795 if (!IRC_Send_ISUPPORT(Client))
798 if (!IRC_Send_LUSERS(Client))
800 if (!IRC_Show_MOTD(Client))
803 /* Suspend the client for a second ... */
804 IRC_SetPenalty(Client, 1);
811 Kill_Nick( char *Nick, char *Reason )
815 assert( Nick != NULL );
816 assert( Reason != NULL );
818 r.prefix = (char *)Client_ThisServer( );
823 Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason );
824 IRC_KILL( Client_ThisServer( ), &r );
829 Introduce_Client(CLIENT *From, CLIENT *Client, int Type)
831 /* Set client type (user or service) */
832 Client_SetType(Client, Type);
835 if (Conf_IsService(Conf_GetServer(Client_Conn(From)),
837 Client_SetType(Client, CLIENT_SERVICE);
838 LogDebug("%s \"%s\" (+%s) registered (via %s, on %s, %d hop%s).",
839 Client_TypeText(Client), Client_Mask(Client),
840 Client_Modes(Client), Client_ID(From),
841 Client_ID(Client_Introducer(Client)),
842 Client_Hops(Client), Client_Hops(Client) > 1 ? "s": "");
844 Log(LOG_NOTICE, "%s \"%s\" registered (connection %d).",
845 Client_TypeText(Client), Client_Mask(Client),
846 Client_Conn(Client));
848 /* Inform other servers */
849 IRC_WriteStrServersPrefixFlag_CB(From,
850 From != NULL ? From : Client_ThisServer(),
851 '\0', cb_introduceClient, (void *)Client);
852 } /* Introduce_Client */
856 cb_introduceClient(CLIENT *To, CLIENT *Prefix, void *data)
858 CLIENT *c = (CLIENT *)data;
860 char *modes, *user, *host;
862 modes = Client_Modes(c);
863 user = Client_User(c) ? Client_User(c) : "-";
864 host = Client_Hostname(c) ? Client_Hostname(c) : "-";
866 conn = Client_Conn(To);
867 if (Conn_Options(conn) & CONN_RFC1459) {
868 /* RFC 1459 mode: separate NICK and USER commands */
869 Conn_WriteStr(conn, "NICK %s :%d", Client_ID(c),
871 Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
872 Client_ID(c), user, host,
873 Client_ID(Client_Introducer(c)), Client_Info(c));
875 Conn_WriteStr(conn, ":%s MODE %s +%s",
876 Client_ID(c), Client_ID(c), modes);
878 /* RFC 2813 mode: one combined NICK or SERVICE command */
879 if (Client_Type(c) == CLIENT_SERVICE
880 && strchr(Client_Flags(To), 'S'))
881 IRC_WriteStrClientPrefix(To, Prefix,
882 "SERVICE %s %d * +%s %d :%s",
884 Client_MyToken(Client_Introducer(c)),
885 Client_Modes(c), Client_Hops(c) + 1,
888 IRC_WriteStrClientPrefix(To, Prefix,
889 "NICK %s %d %s %s %d +%s :%s",
890 Client_ID(c), Client_Hops(c) + 1,
892 Client_MyToken(Client_Introducer(c)),
893 modes, Client_Info(c));
895 } /* cb_introduceClient */