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.
25 #include "conn-func.h"
34 #include "irc-write.h"
37 #include "irc-login.h"
40 static bool Hello_User PARAMS(( CLIENT *Client ));
41 static void Kill_Nick PARAMS(( char *Nick, char *Reason ));
42 static void Introduce_Client PARAMS((CLIENT *To, CLIENT *Client, int Type));
43 static void cb_introduceClient PARAMS((CLIENT *Client, CLIENT *Prefix,
48 * Handler for the IRC command "PASS".
49 * See RFC 2813 section 4.1.1, and RFC 2812 section 3.1.1.
52 IRC_PASS( CLIENT *Client, REQUEST *Req )
54 char *type, *orig_flags;
55 int protohigh, protolow;
57 assert( Client != NULL );
58 assert( Req != NULL );
60 /* Return an error if this is not a local client */
61 if (Client_Conn(Client) <= NONE)
62 return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
63 Client_ID(Client), Req->command);
65 if (Client_Type(Client) == CLIENT_UNKNOWN && Req->argc == 1) {
66 /* Not yet registered "unknown" connection, PASS with one
67 * argument: either a regular client, service, or server
68 * using the old RFC 1459 section 4.1.1 syntax. */
69 LogDebug("Connection %d: got PASS command (RFC 1459) ...",
71 } else if ((Client_Type(Client) == CLIENT_UNKNOWN ||
72 Client_Type(Client) == CLIENT_UNKNOWNSERVER) &&
73 (Req->argc == 3 || Req->argc == 4)) {
74 /* Not yet registered "unknown" connection or outgoing server
75 * link, PASS with three or four argument: server using the
76 * RFC 2813 section 4.1.1 syntax. */
77 LogDebug("Connection %d: got PASS command (RFC 2813, new server link) ...",
79 } else if (Client_Type(Client) == CLIENT_UNKNOWN ||
80 Client_Type(Client) == CLIENT_UNKNOWNSERVER) {
81 /* Unregistered connection, but wrong number of arguments: */
82 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
83 Client_ID(Client), Req->command);
85 /* Registered connection, PASS command is not allowed! */
86 return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
90 Client_SetPassword(Client, Req->argv[0]);
92 /* Protocol version */
93 if (Req->argc >= 2 && strlen(Req->argv[1]) >= 4) {
99 Req->argv[1][4] = '\0';
100 protolow = atoi(&Req->argv[1][2]);
101 Req->argv[1][2] = '\0';
102 protohigh = atoi(Req->argv[1]);
104 Req->argv[1][2] = c2;
105 Req->argv[1][4] = c4;
107 Client_SetType(Client, CLIENT_GOTPASS_2813);
109 protohigh = protolow = 0;
110 Client_SetType(Client, CLIENT_GOTPASS);
113 /* Protocol type, see doc/Protocol.txt */
114 if (Req->argc >= 2 && strlen(Req->argv[1]) > 4)
115 type = &Req->argv[1][4];
119 /* Protocol flags/options */
121 orig_flags = Req->argv[3];
125 /* Implementation, version and IRC+ flags */
126 if (Req->argc >= 3) {
127 char *impl, *ptr, *serverver, *flags;
130 ptr = strchr(impl, '|');
134 if (type && strcmp(type, PROTOIRCPLUS) == 0) {
135 /* The peer seems to be a server which supports the
136 * IRC+ protocol (see doc/Protocol.txt). */
138 flags = strchr(serverver, ':');
145 "Peer announces itself as %s-%s using protocol %d.%d/IRC+ (flags: \"%s\").",
146 impl, serverver, protohigh, protolow, flags);
148 /* The peer seems to be a server supporting the
149 * "original" IRC protocol (RFC 2813). */
150 if (strchr(orig_flags, 'Z'))
155 "Peer announces itself as \"%s\" using protocol %d.%d (flags: \"%s\").",
156 impl, protohigh, protolow, flags);
158 Client_SetFlags(Client, flags);
166 * IRC "NICK" command.
167 * This function implements the IRC command "NICK" which is used to register
168 * with the server, to change already registered nicknames and to introduce
169 * new users which are connected to other servers.
172 IRC_NICK( CLIENT *Client, REQUEST *Req )
174 CLIENT *intr_c, *target, *c;
175 char *nick, *user, *hostname, *modes, *info;
178 assert( Client != NULL );
179 assert( Req != NULL );
181 /* Some IRC clients, for example BitchX, send the NICK and USER
182 * commands in the wrong order ... */
183 if(Client_Type(Client) == CLIENT_UNKNOWN
184 || Client_Type(Client) == CLIENT_GOTPASS
185 || Client_Type(Client) == CLIENT_GOTNICK
187 || Client_Type(Client) == CLIENT_GOTUSER
189 || Client_Type(Client) == CLIENT_USER
190 || Client_Type(Client) == CLIENT_SERVICE
191 || (Client_Type(Client) == CLIENT_SERVER && Req->argc == 1))
193 /* User registration or change of nickname */
195 /* Wrong number of arguments? */
197 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG,
201 /* Search "target" client */
202 if( Client_Type( Client ) == CLIENT_SERVER )
204 target = Client_Search( Req->prefix );
206 return IRC_WriteStrClient( Client,
213 /* Is this a restricted client? */
214 if( Client_HasMode( Client, 'r' ))
215 return IRC_WriteStrClient( Client,
217 Client_ID( Client ));
223 /* If the clients tries to change to its own nickname we won't
224 * do anything. This is how the original ircd behaves and some
225 * clients (for example Snak) expect it to be like this.
226 * But I doubt that this is "really the right thing" ... */
227 if( strcmp( Client_ID( target ), Req->argv[0] ) == 0 )
231 /* Check that the new nickname is available. Special case:
232 * the client only changes from/to upper to lower case. */
233 if( strcasecmp( Client_ID( target ), Req->argv[0] ) != 0 )
235 if( ! Client_CheckNick( target, Req->argv[0] ))
239 if (Client_Type(target) != CLIENT_USER &&
240 Client_Type(target) != CLIENT_SERVICE &&
241 Client_Type(target) != CLIENT_SERVER) {
243 LogDebug("Connection %d: got valid NICK command ...",
244 Client_Conn( Client ));
246 /* Register new nickname of this client */
247 Client_SetID( target, Req->argv[0] );
249 /* If we received a valid USER command already then
250 * register the new client! */
251 if( Client_Type( Client ) == CLIENT_GOTUSER )
252 return Hello_User( Client );
254 Client_SetType( Client, CLIENT_GOTNICK );
256 /* Nickname change */
257 if (Client_Conn(target) > NONE) {
260 "%s \"%s\" changed nick (connection %d): \"%s\" -> \"%s\".",
261 Client_TypeText(target), Client_Mask(target),
262 Client_Conn(target), Client_ID(target),
264 Conn_UpdateIdle(Client_Conn(target));
267 LogDebug("%s \"%s\" changed nick: \"%s\" -> \"%s\".",
268 Client_TypeText(target),
269 Client_Mask(target), Client_ID(target),
273 /* Inform all users and servers (which have to know)
274 * of this nickname change */
275 if( Client_Type( Client ) == CLIENT_USER )
276 IRC_WriteStrClientPrefix( Client, Client,
279 IRC_WriteStrServersPrefix( Client, target,
280 "NICK :%s", Req->argv[0] );
281 IRC_WriteStrRelatedPrefix( target, target, false,
282 "NICK :%s", Req->argv[0] );
284 /* Register old nickname for WHOWAS queries */
285 Client_RegisterWhowas( target );
287 /* Save new nickname */
288 Client_SetID( target, Req->argv[0] );
290 IRC_SetPenalty( target, 2 );
294 } else if(Client_Type(Client) == CLIENT_SERVER ||
295 Client_Type(Client) == CLIENT_SERVICE) {
296 /* Server or service introduces new client */
298 /* Bad number of parameters? */
299 if (Req->argc != 2 && Req->argc != 7)
300 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
301 Client_ID(Client), Req->command);
303 if (Req->argc >= 7) {
304 /* RFC 2813 compatible syntax */
306 hops = atoi(Req->argv[1]);
308 hostname = Req->argv[3];
309 token = atoi(Req->argv[4]);
310 modes = Req->argv[5] + 1;
313 /* RFC 1459 compatible syntax */
317 hostname = Client_ID(Client);
318 token = atoi(Req->argv[1]);
323 c = Client_Search(nick);
326 * the new nick is already present on this server:
327 * the new and the old one have to be disconnected now.
329 Log( LOG_ERR, "Server %s introduces already registered nick \"%s\"!", Client_ID( Client ), Req->argv[0] );
330 Kill_Nick( Req->argv[0], "Nick collision" );
334 /* Find the Server this client is connected to */
335 intr_c = Client_GetFromToken(Client, token);
338 Log( LOG_ERR, "Server %s introduces nick \"%s\" on unknown server!?", Client_ID( Client ), Req->argv[0] );
339 Kill_Nick( Req->argv[0], "Unknown server" );
343 c = Client_NewRemoteUser(intr_c, nick, hops, user, hostname,
344 token, modes, info, true);
347 /* out of memory, need to disconnect client to keep network state consistent */
348 Log( LOG_ALERT, "Can't create client structure! (on connection %d)", Client_Conn( Client ));
349 Kill_Nick( Req->argv[0], "Server error" );
353 /* RFC 2813: client is now fully registered, inform all the
354 * other servers about the new user.
355 * RFC 1459: announce the new client only after receiving the
356 * USER command, first we need more information! */
358 LogDebug("Client \"%s\" is being registered (RFC 1459) ...",
360 Client_SetType(c, CLIENT_GOTNICK);
362 Introduce_Client(Client, c, CLIENT_USER);
366 else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
371 * Handler for the IRC command "USER".
374 IRC_USER(CLIENT * Client, REQUEST * Req)
381 assert(Client != NULL);
384 if (Client_Type(Client) == CLIENT_GOTNICK ||
386 Client_Type(Client) == CLIENT_UNKNOWN ||
388 Client_Type(Client) == CLIENT_GOTPASS)
392 return IRC_WriteStrClient(Client,
393 ERR_NEEDMOREPARAMS_MSG,
399 ptr = Client_User(Client);
400 if (!ptr || !*ptr || *ptr == '~')
401 Client_SetUser(Client, Req->argv[0], false);
403 Client_SetUser(Client, Req->argv[0], false);
406 /* "Real name" or user info text: Don't set it to the empty
407 * string, the original ircd can't deal with such "real names"
408 * (e. g. "USER user * * :") ... */
410 Client_SetInfo(Client, Req->argv[3]);
412 Client_SetInfo(Client, "-");
414 LogDebug("Connection %d: got valid USER command ...",
415 Client_Conn(Client));
416 if (Client_Type(Client) == CLIENT_GOTNICK)
417 return Hello_User(Client);
419 Client_SetType(Client, CLIENT_GOTUSER);
422 } else if (Client_Type(Client) == CLIENT_SERVER ||
423 Client_Type(Client) == CLIENT_SERVICE) {
424 /* Server/service updating an user */
426 return IRC_WriteStrClient(Client,
427 ERR_NEEDMOREPARAMS_MSG,
430 c = Client_Search(Req->prefix);
432 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
436 Client_SetUser(c, Req->argv[0], true);
437 Client_SetHostname(c, Req->argv[1]);
438 Client_SetInfo(c, Req->argv[3]);
440 LogDebug("Connection %d: got valid USER command for \"%s\".",
441 Client_Conn(Client), Client_Mask(c));
443 /* RFC 1459 style user registration?
444 * Introduce client to network: */
445 if (Client_Type(c) == CLIENT_GOTNICK)
446 Introduce_Client(Client, c, CLIENT_USER);
449 } else if (Client_Type(Client) == CLIENT_USER) {
450 /* Already registered connection */
451 return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
454 /* Unexpected/invalid connection state? */
455 return IRC_WriteStrClient(Client, ERR_NOTREGISTERED_MSG,
462 * Handler for the IRC command "SERVICE".
463 * This function implements IRC Services registration using the SERVICE command
464 * defined in RFC 2812 3.1.6 and RFC 2813 4.1.4.
465 * At the moment ngIRCd doesn't support directly linked services, so this
466 * function returns ERR_ERRONEUSNICKNAME when the SERVICE command has not been
467 * received from a peer server.
470 IRC_SERVICE(CLIENT *Client, REQUEST *Req)
473 char *nick, *user, *host, *info, *modes, *ptr;
476 assert(Client != NULL);
479 if (Client_Type(Client) != CLIENT_GOTPASS &&
480 Client_Type(Client) != CLIENT_SERVER)
481 return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
485 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
486 Client_ID(Client), Req->command);
488 if (Client_Type(Client) != CLIENT_SERVER)
489 return IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
490 Client_ID(Client), Req->argv[0]);
492 /* Bad number of parameters? */
494 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
495 Client_ID(Client), Req->command);
498 user = NULL; host = NULL;
499 token = atoi(Req->argv[1]);
500 hops = atoi(Req->argv[4]);
503 /* Validate service name ("nick name") */
504 c = Client_Search(nick);
506 /* Nick name collission: disconnect (KILL) both clients! */
507 Log(LOG_ERR, "Server %s introduces already registered service \"%s\"!",
508 Client_ID(Client), nick);
509 Kill_Nick(nick, "Nick collision");
513 /* Get the server to which the service is connected */
514 intr_c = Client_GetFromToken(Client, token);
516 Log(LOG_ERR, "Server %s introduces service \"%s\" on unknown server!?",
517 Client_ID(Client), nick);
518 Kill_Nick(nick, "Unknown server");
522 /* Get user and host name */
523 ptr = strchr(nick, '@');
529 host = Client_Hostname(intr_c);
530 ptr = strchr(nick, '!');
538 /* According to RFC 2812/2813 parameter 4 <type> "is currently reserved
539 * for future usage"; but we use it to transfer the modes and check
540 * that the first character is a '+' sign and ignore it otherwise. */
541 modes = (Req->argv[3][0] == '+') ? ++Req->argv[3] : "";
543 c = Client_NewRemoteUser(intr_c, nick, hops, user, host,
544 token, modes, info, true);
546 /* Couldn't create client structure, so KILL the service to
547 * keep network status consistent ... */
548 Log(LOG_ALERT, "Can't create client structure! (on connection %d)",
549 Client_Conn(Client));
550 Kill_Nick(nick, "Server error");
554 Introduce_Client(Client, c, CLIENT_SERVICE);
560 * Handler for the IRC command "WEBIRC".
561 * Syntax: WEBIRC <password> <username> <real-hostname> <real-IP-address>
564 IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
566 /* Exactly 4 parameters are requited */
568 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
569 Client_ID(Client), Req->command);
571 if (!Conf_WebircPwd[0] || strcmp(Req->argv[0], Conf_WebircPwd) != 0)
572 return IRC_WriteStrClient(Client, ERR_PASSWDMISMATCH_MSG,
575 LogDebug("Connection %d: got valid WEBIRC command: user=%s, host=%s, ip=%s",
576 Client_Conn(Client), Req->argv[1], Req->argv[2], Req->argv[3]);
578 Client_SetUser(Client, Req->argv[1], true);
579 Client_SetHostname(Client, Req->argv[2]);
585 IRC_QUIT( CLIENT *Client, REQUEST *Req )
588 char quitmsg[LINE_LEN];
590 assert( Client != NULL );
591 assert( Req != NULL );
593 /* Wrong number of arguments? */
595 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
598 strlcpy(quitmsg, Req->argv[0], sizeof quitmsg);
600 if ( Client_Type( Client ) == CLIENT_SERVER )
603 target = Client_Search( Req->prefix );
606 Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
610 Client_Destroy( target, "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
616 if (Req->argc == 1 && quitmsg[0] != '\"') {
617 /* " " to avoid confusion */
618 strlcpy(quitmsg, "\"", sizeof quitmsg);
619 strlcat(quitmsg, Req->argv[0], sizeof quitmsg-1);
620 strlcat(quitmsg, "\"", sizeof quitmsg );
623 /* User, Service, or not yet registered */
624 Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
632 IRC_PING(CLIENT *Client, REQUEST *Req)
634 CLIENT *target, *from;
636 assert(Client != NULL);
640 return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
643 /* Don't ignore additional arguments when in "strict" mode */
645 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
646 Client_ID(Client), Req->command);
650 /* A target has been specified ... */
651 target = Client_Search(Req->argv[1]);
653 if (!target || Client_Type(target) != CLIENT_SERVER)
654 return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
655 Client_ID(Client), Req->argv[1]);
657 if (target != Client_ThisServer()) {
658 /* Ok, we have to forward the PING */
659 if (Client_Type(Client) == CLIENT_SERVER)
660 from = Client_Search(Req->prefix);
664 return IRC_WriteStrClient(Client,
665 ERR_NOSUCHSERVER_MSG,
666 Client_ID(Client), Req->prefix);
668 return IRC_WriteStrClientPrefix(target, from,
669 "PING %s :%s", Req->argv[0],
674 if (Client_Type(Client) == CLIENT_SERVER) {
676 from = Client_Search(Req->prefix);
680 from = Client_ThisServer();
682 return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
683 Client_ID(Client), Req->prefix);
685 Log(LOG_DEBUG, "Connection %d: got PING, sending PONG ...",
686 Client_Conn(Client));
689 return IRC_WriteStrClient(Client, "PONG %s :%s",
690 Client_ID(from), Client_ID(Client));
692 /* Some clients depend on the argument being returned in the PONG
693 * reply (not mentioned in any RFC, though) */
694 return IRC_WriteStrClient(Client, "PONG %s :%s",
695 Client_ID(from), Req->argv[0]);
701 IRC_PONG(CLIENT *Client, REQUEST *Req)
703 CLIENT *target, *from;
706 assert(Client != NULL);
709 /* Wrong number of arguments? */
711 return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
714 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
715 Client_ID(Client), Req->command);
718 if (Req->argc == 2 && Client_Type(Client) == CLIENT_SERVER) {
719 target = Client_Search(Req->argv[0]);
721 return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
722 Client_ID(Client), Req->argv[0]);
724 from = Client_Search(Req->prefix);
726 if (target != Client_ThisServer() && target != from) {
727 /* Ok, we have to forward the message. */
729 return IRC_WriteStrClient(Client,
730 ERR_NOSUCHSERVER_MSG,
731 Client_ID(Client), Req->prefix);
733 if (Client_Type(Client_NextHop(target)) != CLIENT_SERVER)
737 return IRC_WriteStrClientPrefix(target, from,
738 "PONG %s :%s", s, Req->argv[1]);
742 /* The connection timestamp has already been updated when the data has
743 * been read from so socket, so we don't need to update it here. */
745 if (Client_Conn(Client) > NONE)
747 "Connection %d: received PONG. Lag: %ld seconds.",
749 time(NULL) - Conn_LastPing(Client_Conn(Client)));
752 "Connection %d: received PONG.", Client_Conn(Client));
759 Hello_User(CLIENT * Client)
761 assert(Client != NULL);
763 /* Check password ... */
764 if (strcmp(Client_Password(Client), Conf_ServerPwd) != 0) {
767 "Client \"%s\" rejected (connection %d): Bad password!",
768 Client_Mask(Client), Client_Conn(Client));
769 Conn_Close(Client_Conn(Client), NULL, "Bad password", true);
773 Introduce_Client(NULL, Client, CLIENT_USER);
775 if (!IRC_WriteStrClient
776 (Client, RPL_WELCOME_MSG, Client_ID(Client), Client_Mask(Client)))
778 if (!IRC_WriteStrClient
779 (Client, RPL_YOURHOST_MSG, Client_ID(Client),
780 Client_ID(Client_ThisServer()), PACKAGE_VERSION, TARGET_CPU,
781 TARGET_VENDOR, TARGET_OS))
783 if (!IRC_WriteStrClient
784 (Client, RPL_CREATED_MSG, Client_ID(Client), NGIRCd_StartStr))
786 if (!IRC_WriteStrClient
787 (Client, RPL_MYINFO_MSG, Client_ID(Client),
788 Client_ID(Client_ThisServer()), PACKAGE_VERSION, USERMODES,
792 /* Features supported by this server (005 numeric, ISUPPORT),
793 * see <http://www.irc.org/tech_docs/005.html> for details. */
794 if (!IRC_Send_ISUPPORT(Client))
797 if (!IRC_Send_LUSERS(Client))
799 if (!IRC_Show_MOTD(Client))
802 /* Suspend the client for a second ... */
803 IRC_SetPenalty(Client, 1);
810 Kill_Nick( char *Nick, char *Reason )
814 assert( Nick != NULL );
815 assert( Reason != NULL );
817 r.prefix = (char *)Client_ThisServer( );
822 Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason );
823 IRC_KILL( Client_ThisServer( ), &r );
828 Introduce_Client(CLIENT *From, CLIENT *Client, int Type)
830 /* Set client type (user or service) */
831 Client_SetType(Client, Type);
834 if (Conf_IsService(Conf_GetServer(Client_Conn(From)),
836 Client_SetType(Client, CLIENT_SERVICE);
837 LogDebug("%s \"%s\" (+%s) registered (via %s, on %s, %d hop%s).",
838 Client_TypeText(Client), Client_Mask(Client),
839 Client_Modes(Client), Client_ID(From),
840 Client_ID(Client_Introducer(Client)),
841 Client_Hops(Client), Client_Hops(Client) > 1 ? "s": "");
843 Log(LOG_NOTICE, "%s \"%s\" registered (connection %d).",
844 Client_TypeText(Client), Client_Mask(Client),
845 Client_Conn(Client));
846 Log_ServerNotice('c', "Client connecting: %s (%s@%s) [%s] - %s",
847 Client_ID(Client), Client_User(Client),
848 Client_Hostname(Client),
849 Conn_IPA(Client_Conn(Client)),
850 Client_TypeText(Client));
853 /* Inform other servers */
854 IRC_WriteStrServersPrefixFlag_CB(From,
855 From != NULL ? From : Client_ThisServer(),
856 '\0', cb_introduceClient, (void *)Client);
857 } /* Introduce_Client */
861 cb_introduceClient(CLIENT *To, CLIENT *Prefix, void *data)
863 CLIENT *c = (CLIENT *)data;
865 char *modes, *user, *host;
867 modes = Client_Modes(c);
868 user = Client_User(c) ? Client_User(c) : "-";
869 host = Client_Hostname(c) ? Client_Hostname(c) : "-";
871 conn = Client_Conn(To);
872 if (Conn_Options(conn) & CONN_RFC1459) {
873 /* RFC 1459 mode: separate NICK and USER commands */
874 Conn_WriteStr(conn, "NICK %s :%d", Client_ID(c),
876 Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
877 Client_ID(c), user, host,
878 Client_ID(Client_Introducer(c)), Client_Info(c));
880 Conn_WriteStr(conn, ":%s MODE %s +%s",
881 Client_ID(c), Client_ID(c), modes);
883 /* RFC 2813 mode: one combined NICK or SERVICE command */
884 if (Client_Type(c) == CLIENT_SERVICE
885 && strchr(Client_Flags(To), 'S'))
886 IRC_WriteStrClientPrefix(To, Prefix,
887 "SERVICE %s %d * +%s %d :%s",
889 Client_MyToken(Client_Introducer(c)),
890 Client_Modes(c), Client_Hops(c) + 1,
893 IRC_WriteStrClientPrefix(To, Prefix,
894 "NICK %s %d %s %s %d +%s :%s",
895 Client_ID(c), Client_Hops(c) + 1,
897 Client_MyToken(Client_Introducer(c)),
898 modes, Client_Info(c));
900 } /* cb_introduceClient */