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"
33 #include "irc-write.h"
36 #include "irc-login.h"
39 static bool Hello_User PARAMS(( CLIENT *Client ));
40 static void Kill_Nick PARAMS(( char *Nick, char *Reason ));
41 static void Introduce_Client PARAMS((CLIENT *To, CLIENT *Client, int Type));
42 static void cb_introduceClient PARAMS((CLIENT *Client, CLIENT *Prefix,
47 * Handler for the IRC command "PASS".
48 * See RFC 2813 section 4.1.1, and RFC 2812 section 3.1.1.
51 IRC_PASS( CLIENT *Client, REQUEST *Req )
53 char *type, *orig_flags;
54 int protohigh, protolow;
56 assert( Client != NULL );
57 assert( Req != NULL );
59 /* Return an error if this is not a local client */
60 if (Client_Conn(Client) <= NONE)
61 return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
62 Client_ID(Client), Req->command);
64 if (Client_Type(Client) == CLIENT_UNKNOWN && Req->argc == 1) {
65 /* Not yet registered "unknown" connection, PASS with one
66 * argument: either a regular client, service, or server
67 * using the old RFC 1459 section 4.1.1 syntax. */
68 LogDebug("Connection %d: got PASS command (RFC 1459) ...",
70 } else if ((Client_Type(Client) == CLIENT_UNKNOWN ||
71 Client_Type(Client) == CLIENT_UNKNOWNSERVER) &&
72 (Req->argc == 3 || Req->argc == 4)) {
73 /* Not yet registered "unknown" connection or outgoing server
74 * link, PASS with three or four argument: server using the
75 * RFC 2813 section 4.1.1 syntax. */
76 LogDebug("Connection %d: got PASS command (RFC 2813, new server link) ...",
78 } else if (Client_Type(Client) == CLIENT_UNKNOWN ||
79 Client_Type(Client) == CLIENT_UNKNOWNSERVER) {
80 /* Unregistered connection, but wrong number of arguments: */
81 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
82 Client_ID(Client), Req->command);
84 /* Registered connection, PASS command is not allowed! */
85 return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
89 Client_SetPassword(Client, Req->argv[0]);
91 /* Protocol version */
92 if (Req->argc >= 2 && strlen(Req->argv[1]) >= 4) {
98 Req->argv[1][4] = '\0';
99 protolow = atoi(&Req->argv[1][2]);
100 Req->argv[1][2] = '\0';
101 protohigh = atoi(Req->argv[1]);
103 Req->argv[1][2] = c2;
104 Req->argv[1][4] = c4;
106 Client_SetType(Client, CLIENT_GOTPASS_2813);
108 protohigh = protolow = 0;
109 Client_SetType(Client, CLIENT_GOTPASS);
112 /* Protocol type, see doc/Protocol.txt */
113 if (Req->argc >= 2 && strlen(Req->argv[1]) > 4)
114 type = &Req->argv[1][4];
118 /* Protocol flags/options */
120 orig_flags = Req->argv[3];
124 /* Implementation, version and IRC+ flags */
125 if (Req->argc >= 3) {
126 char *impl, *ptr, *serverver, *flags;
129 ptr = strchr(impl, '|');
133 if (type && strcmp(type, PROTOIRCPLUS) == 0) {
134 /* The peer seems to be a server which supports the
135 * IRC+ protocol (see doc/Protocol.txt). */
137 flags = strchr(serverver, ':');
144 "Peer announces itself as %s-%s using protocol %d.%d/IRC+ (flags: \"%s\").",
145 impl, serverver, protohigh, protolow, flags);
147 /* The peer seems to be a server supporting the
148 * "original" IRC protocol (RFC 2813). */
149 if (strchr(orig_flags, 'Z'))
154 "Peer announces itself as \"%s\" using protocol %d.%d (flags: \"%s\").",
155 impl, protohigh, protolow, flags);
157 Client_SetFlags(Client, flags);
165 * IRC "NICK" command.
166 * This function implements the IRC command "NICK" which is used to register
167 * with the server, to change already registered nicknames and to introduce
168 * new users which are connected to other servers.
171 IRC_NICK( CLIENT *Client, REQUEST *Req )
173 CLIENT *intr_c, *target, *c;
174 char *nick, *user, *hostname, *modes, *info;
177 assert( Client != NULL );
178 assert( Req != NULL );
180 /* Some IRC clients, for example BitchX, send the NICK and USER
181 * commands in the wrong order ... */
182 if(Client_Type(Client) == CLIENT_UNKNOWN
183 || Client_Type(Client) == CLIENT_GOTPASS
184 || Client_Type(Client) == CLIENT_GOTNICK
186 || Client_Type(Client) == CLIENT_GOTUSER
188 || Client_Type(Client) == CLIENT_USER
189 || Client_Type(Client) == CLIENT_SERVICE
190 || (Client_Type(Client) == CLIENT_SERVER && Req->argc == 1))
192 /* User registration or change of nickname */
194 /* Wrong number of arguments? */
196 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG,
200 /* Search "target" client */
201 if( Client_Type( Client ) == CLIENT_SERVER )
203 target = Client_Search( Req->prefix );
205 return IRC_WriteStrClient( Client,
212 /* Is this a restricted client? */
213 if( Client_HasMode( Client, 'r' ))
214 return IRC_WriteStrClient( Client,
216 Client_ID( Client ));
222 /* If the clients tries to change to its own nickname we won't
223 * do anything. This is how the original ircd behaves and some
224 * clients (for example Snak) expect it to be like this.
225 * But I doubt that this is "really the right thing" ... */
226 if( strcmp( Client_ID( target ), Req->argv[0] ) == 0 )
230 /* Check that the new nickname is available. Special case:
231 * the client only changes from/to upper to lower case. */
232 if( strcasecmp( Client_ID( target ), Req->argv[0] ) != 0 )
234 if( ! Client_CheckNick( target, Req->argv[0] ))
238 if (Client_Type(target) != CLIENT_USER &&
239 Client_Type(target) != CLIENT_SERVICE &&
240 Client_Type(target) != CLIENT_SERVER) {
242 LogDebug("Connection %d: got valid NICK command ...",
243 Client_Conn( Client ));
245 /* Register new nickname of this client */
246 Client_SetID( target, Req->argv[0] );
248 /* If we received a valid USER command already then
249 * register the new client! */
250 if( Client_Type( Client ) == CLIENT_GOTUSER )
251 return Hello_User( Client );
253 Client_SetType( Client, CLIENT_GOTNICK );
255 /* Nickname change */
256 if (Client_Conn(target) > NONE) {
259 "%s \"%s\" changed nick (connection %d): \"%s\" -> \"%s\".",
260 Client_TypeText(target), Client_Mask(target),
261 Client_Conn(target), Client_ID(target),
263 Conn_UpdateIdle(Client_Conn(target));
266 LogDebug("%s \"%s\" changed nick: \"%s\" -> \"%s\".",
267 Client_TypeText(target),
268 Client_Mask(target), Client_ID(target),
272 /* Inform all users and servers (which have to know)
273 * of this nickname change */
274 if( Client_Type( Client ) == CLIENT_USER )
275 IRC_WriteStrClientPrefix( Client, Client,
278 IRC_WriteStrServersPrefix( Client, target,
279 "NICK :%s", Req->argv[0] );
280 IRC_WriteStrRelatedPrefix( target, target, false,
281 "NICK :%s", Req->argv[0] );
283 /* Register old nickname for WHOWAS queries */
284 Client_RegisterWhowas( target );
286 /* Save new nickname */
287 Client_SetID( target, Req->argv[0] );
289 IRC_SetPenalty( target, 2 );
293 } else if(Client_Type(Client) == CLIENT_SERVER ||
294 Client_Type(Client) == CLIENT_SERVICE) {
295 /* Server or service introduces new client */
297 /* Bad number of parameters? */
298 if (Req->argc != 2 && Req->argc != 7)
299 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
300 Client_ID(Client), Req->command);
302 if (Req->argc >= 7) {
303 /* RFC 2813 compatible syntax */
305 hops = atoi(Req->argv[1]);
307 hostname = Req->argv[3];
308 token = atoi(Req->argv[4]);
309 modes = Req->argv[5] + 1;
312 /* RFC 1459 compatible syntax */
316 hostname = Client_ID(Client);
317 token = atoi(Req->argv[1]);
322 c = Client_Search(nick);
325 * the new nick is already present on this server:
326 * the new and the old one have to be disconnected now.
328 Log( LOG_ERR, "Server %s introduces already registered nick \"%s\"!", Client_ID( Client ), Req->argv[0] );
329 Kill_Nick( Req->argv[0], "Nick collision" );
333 /* Find the Server this client is connected to */
334 intr_c = Client_GetFromToken(Client, token);
337 Log( LOG_ERR, "Server %s introduces nick \"%s\" on unknown server!?", Client_ID( Client ), Req->argv[0] );
338 Kill_Nick( Req->argv[0], "Unknown server" );
342 c = Client_NewRemoteUser(intr_c, nick, hops, user, hostname,
343 token, modes, info, true);
346 /* out of memory, need to disconnect client to keep network state consistent */
347 Log( LOG_ALERT, "Can't create client structure! (on connection %d)", Client_Conn( Client ));
348 Kill_Nick( Req->argv[0], "Server error" );
352 /* RFC 2813: client is now fully registered, inform all the
353 * other servers about the new user.
354 * RFC 1459: announce the new client only after receiving the
355 * USER command, first we need more information! */
357 LogDebug("Client \"%s\" is being registered (RFC 1459) ...",
359 Client_SetType(c, CLIENT_GOTNICK);
361 Introduce_Client(Client, c, CLIENT_USER);
365 else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
370 * Handler for the IRC command "USER".
373 IRC_USER(CLIENT * Client, REQUEST * Req)
380 assert(Client != NULL);
383 if (Client_Type(Client) == CLIENT_GOTNICK ||
385 Client_Type(Client) == CLIENT_UNKNOWN ||
387 Client_Type(Client) == CLIENT_GOTPASS)
391 return IRC_WriteStrClient(Client,
392 ERR_NEEDMOREPARAMS_MSG,
398 ptr = Client_User(Client);
399 if (!ptr || !*ptr || *ptr == '~')
400 Client_SetUser(Client, Req->argv[0], false);
402 Client_SetUser(Client, Req->argv[0], false);
405 /* "Real name" or user info text: Don't set it to the empty
406 * string, the original ircd can't deal with such "real names"
407 * (e. g. "USER user * * :") ... */
409 Client_SetInfo(Client, Req->argv[3]);
411 Client_SetInfo(Client, "-");
413 LogDebug("Connection %d: got valid USER command ...",
414 Client_Conn(Client));
415 if (Client_Type(Client) == CLIENT_GOTNICK)
416 return Hello_User(Client);
418 Client_SetType(Client, CLIENT_GOTUSER);
421 } else if (Client_Type(Client) == CLIENT_SERVER ||
422 Client_Type(Client) == CLIENT_SERVICE) {
423 /* Server/service updating an user */
425 return IRC_WriteStrClient(Client,
426 ERR_NEEDMOREPARAMS_MSG,
429 c = Client_Search(Req->prefix);
431 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
435 Client_SetUser(c, Req->argv[0], true);
436 Client_SetHostname(c, Req->argv[1]);
437 Client_SetInfo(c, Req->argv[3]);
439 LogDebug("Connection %d: got valid USER command for \"%s\".",
440 Client_Conn(Client), Client_Mask(c));
442 /* RFC 1459 style user registration?
443 * Introduce client to network: */
444 if (Client_Type(c) == CLIENT_GOTNICK)
445 Introduce_Client(Client, c, CLIENT_USER);
448 } else if (Client_Type(Client) == CLIENT_USER) {
449 /* Already registered connection */
450 return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
453 /* Unexpected/invalid connection state? */
454 return IRC_WriteStrClient(Client, ERR_NOTREGISTERED_MSG,
461 * Handler for the IRC command "SERVICE".
462 * This function implements IRC Services registration using the SERVICE command
463 * defined in RFC 2812 3.1.6 and RFC 2813 4.1.4.
464 * At the moment ngIRCd doesn't support directly linked services, so this
465 * function returns ERR_ERRONEUSNICKNAME when the SERVICE command has not been
466 * received from a peer server.
469 IRC_SERVICE(CLIENT *Client, REQUEST *Req)
472 char *nick, *user, *host, *info, *modes, *ptr;
475 assert(Client != NULL);
478 if (Client_Type(Client) != CLIENT_GOTPASS &&
479 Client_Type(Client) != CLIENT_SERVER)
480 return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
484 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
485 Client_ID(Client), Req->command);
487 if (Client_Type(Client) != CLIENT_SERVER)
488 return IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
489 Client_ID(Client), Req->argv[0]);
491 /* Bad number of parameters? */
493 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
494 Client_ID(Client), Req->command);
497 user = NULL; host = NULL;
498 token = atoi(Req->argv[1]);
499 hops = atoi(Req->argv[4]);
502 /* Validate service name ("nick name") */
503 c = Client_Search(nick);
505 /* Nick name collission: disconnect (KILL) both clients! */
506 Log(LOG_ERR, "Server %s introduces already registered service \"%s\"!",
507 Client_ID(Client), nick);
508 Kill_Nick(nick, "Nick collision");
512 /* Get the server to which the service is connected */
513 intr_c = Client_GetFromToken(Client, token);
515 Log(LOG_ERR, "Server %s introduces service \"%s\" on unknown server!?",
516 Client_ID(Client), nick);
517 Kill_Nick(nick, "Unknown server");
521 /* Get user and host name */
522 ptr = strchr(nick, '@');
528 host = Client_Hostname(intr_c);
529 ptr = strchr(nick, '!');
537 /* According to RFC 2812/2813 parameter 4 <type> "is currently reserved
538 * for future usage"; but we use it to transfer the modes and check
539 * that the first character is a '+' sign and ignore it otherwise. */
540 modes = (Req->argv[3][0] == '+') ? ++Req->argv[3] : "";
542 c = Client_NewRemoteUser(intr_c, nick, hops, user, host,
543 token, modes, info, true);
545 /* Couldn't create client structure, so KILL the service to
546 * keep network status consistent ... */
547 Log(LOG_ALERT, "Can't create client structure! (on connection %d)",
548 Client_Conn(Client));
549 Kill_Nick(nick, "Server error");
553 Introduce_Client(Client, c, CLIENT_SERVICE);
559 * Handler for the IRC command "WEBIRC".
560 * Syntax: WEBIRC <password> <username> <real-hostname> <real-IP-address>
563 IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
565 /* Exactly 4 parameters are requited */
567 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
568 Client_ID(Client), Req->command);
570 if (!Conf_WebircPwd[0] || strcmp(Req->argv[0], Conf_WebircPwd) != 0)
571 return IRC_WriteStrClient(Client, ERR_PASSWDMISMATCH_MSG,
574 LogDebug("Connection %d: got valid WEBIRC command: user=%s, host=%s, ip=%s",
575 Client_Conn(Client), Req->argv[1], Req->argv[2], Req->argv[3]);
577 Client_SetUser(Client, Req->argv[1], true);
578 Client_SetHostname(Client, Req->argv[2]);
584 IRC_QUIT( CLIENT *Client, REQUEST *Req )
587 char quitmsg[LINE_LEN];
589 assert( Client != NULL );
590 assert( Req != NULL );
592 /* Wrong number of arguments? */
594 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
597 strlcpy(quitmsg, Req->argv[0], sizeof quitmsg);
599 if ( Client_Type( Client ) == CLIENT_SERVER )
602 target = Client_Search( Req->prefix );
605 Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
609 Client_Destroy( target, "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
615 if (Req->argc == 1 && quitmsg[0] != '\"') {
616 /* " " to avoid confusion */
617 strlcpy(quitmsg, "\"", sizeof quitmsg);
618 strlcat(quitmsg, Req->argv[0], sizeof quitmsg-1);
619 strlcat(quitmsg, "\"", sizeof quitmsg );
622 /* User, Service, or not yet registered */
623 Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
631 IRC_PING(CLIENT *Client, REQUEST *Req)
633 CLIENT *target, *from;
635 assert(Client != NULL);
639 return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
642 /* Don't ignore additional arguments when in "strict" mode */
644 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
645 Client_ID(Client), Req->command);
649 /* A target has been specified ... */
650 target = Client_Search(Req->argv[1]);
652 if (!target || Client_Type(target) != CLIENT_SERVER)
653 return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
654 Client_ID(Client), Req->argv[1]);
656 if (target != Client_ThisServer()) {
657 /* Ok, we have to forward the PING */
658 if (Client_Type(Client) == CLIENT_SERVER)
659 from = Client_Search(Req->prefix);
663 return IRC_WriteStrClient(Client,
664 ERR_NOSUCHSERVER_MSG,
665 Client_ID(Client), Req->prefix);
667 return IRC_WriteStrClientPrefix(target, from,
668 "PING %s :%s", Req->argv[0],
673 if (Client_Type(Client) == CLIENT_SERVER) {
675 from = Client_Search(Req->prefix);
679 from = Client_ThisServer();
681 return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
682 Client_ID(Client), Req->prefix);
684 Log(LOG_DEBUG, "Connection %d: got PING, sending PONG ...",
685 Client_Conn(Client));
688 return IRC_WriteStrClient(Client, "PONG %s :%s",
689 Client_ID(from), Client_ID(Client));
691 /* Some clients depend on the argument being returned in the PONG
692 * reply (not mentioned in any RFC, though) */
693 return IRC_WriteStrClient(Client, "PONG %s :%s",
694 Client_ID(from), Req->argv[0]);
700 IRC_PONG(CLIENT *Client, REQUEST *Req)
702 CLIENT *target, *from;
705 assert(Client != NULL);
708 /* Wrong number of arguments? */
710 return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
713 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
714 Client_ID(Client), Req->command);
717 if (Req->argc == 2 && Client_Type(Client) == CLIENT_SERVER) {
718 target = Client_Search(Req->argv[0]);
720 return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
721 Client_ID(Client), Req->argv[0]);
723 from = Client_Search(Req->prefix);
725 if (target != Client_ThisServer() && target != from) {
726 /* Ok, we have to forward the message. */
728 return IRC_WriteStrClient(Client,
729 ERR_NOSUCHSERVER_MSG,
730 Client_ID(Client), Req->prefix);
732 if (Client_Type(Client_NextHop(target)) != CLIENT_SERVER)
736 return IRC_WriteStrClientPrefix(target, from,
737 "PONG %s :%s", s, Req->argv[1]);
741 /* The connection timestamp has already been updated when the data has
742 * been read from so socket, so we don't need to update it here. */
744 if (Client_Conn(Client) > NONE)
746 "Connection %d: received PONG. Lag: %ld seconds.",
748 time(NULL) - Conn_LastPing(Client_Conn(Client)));
751 "Connection %d: received PONG.", Client_Conn(Client));
758 Hello_User(CLIENT * Client)
760 assert(Client != NULL);
762 /* Check password ... */
763 if (strcmp(Client_Password(Client), Conf_ServerPwd) != 0) {
766 "Client \"%s\" rejected (connection %d): Bad password!",
767 Client_Mask(Client), Client_Conn(Client));
768 Conn_Close(Client_Conn(Client), NULL, "Bad password", true);
772 Introduce_Client(NULL, Client, CLIENT_USER);
774 if (!IRC_WriteStrClient
775 (Client, RPL_WELCOME_MSG, Client_ID(Client), Client_Mask(Client)))
777 if (!IRC_WriteStrClient
778 (Client, RPL_YOURHOST_MSG, Client_ID(Client),
779 Client_ID(Client_ThisServer()), PACKAGE_VERSION, TARGET_CPU,
780 TARGET_VENDOR, TARGET_OS))
782 if (!IRC_WriteStrClient
783 (Client, RPL_CREATED_MSG, Client_ID(Client), NGIRCd_StartStr))
785 if (!IRC_WriteStrClient
786 (Client, RPL_MYINFO_MSG, Client_ID(Client),
787 Client_ID(Client_ThisServer()), PACKAGE_VERSION, USERMODES,
791 /* Features supported by this server (005 numeric, ISUPPORT),
792 * see <http://www.irc.org/tech_docs/005.html> for details. */
793 if (!IRC_Send_ISUPPORT(Client))
796 if (!IRC_Send_LUSERS(Client))
798 if (!IRC_Show_MOTD(Client))
801 /* Suspend the client for a second ... */
802 IRC_SetPenalty(Client, 1);
809 Kill_Nick( char *Nick, char *Reason )
813 assert( Nick != NULL );
814 assert( Reason != NULL );
816 r.prefix = (char *)Client_ThisServer( );
821 Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason );
822 IRC_KILL( Client_ThisServer( ), &r );
827 Introduce_Client(CLIENT *From, CLIENT *Client, int Type)
829 /* Set client type (user or service) */
830 Client_SetType(Client, Type);
833 if (Conf_IsService(Conf_GetServer(Client_Conn(From)),
835 Client_SetType(Client, CLIENT_SERVICE);
836 LogDebug("%s \"%s\" (+%s) registered (via %s, on %s, %d hop%s).",
837 Client_TypeText(Client), Client_Mask(Client),
838 Client_Modes(Client), Client_ID(From),
839 Client_ID(Client_Introducer(Client)),
840 Client_Hops(Client), Client_Hops(Client) > 1 ? "s": "");
842 Log(LOG_NOTICE, "%s \"%s\" registered (connection %d).",
843 Client_TypeText(Client), Client_Mask(Client),
844 Client_Conn(Client));
845 Log_ServerNotice('c', "Client connecting: %s (%s@%s) [%s] - %s",
846 Client_ID(Client), Client_User(Client),
847 Client_Hostname(Client),
848 Conn_IPA(Client_Conn(Client)),
849 Client_TypeText(Client));
852 /* Inform other servers */
853 IRC_WriteStrServersPrefixFlag_CB(From,
854 From != NULL ? From : Client_ThisServer(),
855 '\0', cb_introduceClient, (void *)Client);
856 } /* Introduce_Client */
860 cb_introduceClient(CLIENT *To, CLIENT *Prefix, void *data)
862 CLIENT *c = (CLIENT *)data;
864 char *modes, *user, *host;
866 modes = Client_Modes(c);
867 user = Client_User(c) ? Client_User(c) : "-";
868 host = Client_Hostname(c) ? Client_Hostname(c) : "-";
870 conn = Client_Conn(To);
871 if (Conn_Options(conn) & CONN_RFC1459) {
872 /* RFC 1459 mode: separate NICK and USER commands */
873 Conn_WriteStr(conn, "NICK %s :%d", Client_ID(c),
875 Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
876 Client_ID(c), user, host,
877 Client_ID(Client_Introducer(c)), Client_Info(c));
879 Conn_WriteStr(conn, ":%s MODE %s +%s",
880 Client_ID(c), Client_ID(c), modes);
882 /* RFC 2813 mode: one combined NICK or SERVICE command */
883 if (Client_Type(c) == CLIENT_SERVICE
884 && strchr(Client_Flags(To), 'S'))
885 IRC_WriteStrClientPrefix(To, Prefix,
886 "SERVICE %s %d * +%s %d :%s",
888 Client_MyToken(Client_Introducer(c)),
889 Client_Modes(c), Client_Hops(c) + 1,
892 IRC_WriteStrClientPrefix(To, Prefix,
893 "NICK %s %d %s %s %d +%s :%s",
894 Client_ID(c), Client_Hops(c) + 1,
896 Client_MyToken(Client_Introducer(c)),
897 modes, Client_Info(c));
899 } /* cb_introduceClient */