X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fnumeric.c;h=9b8240bdca0227f7e9862d4fb6d5e0646d36ce7a;hb=a78c7b3898e8f2b037fb42aac599ed8f8ec9bd58;hp=0dcfe75b6e3d9c0bca6ad9d7b7a0ead4876aaa74;hpb=5462c6c50fd01fd516e29a42ee0b15c946c11d27;p=ngircd-alex.git diff --git a/src/ngircd/numeric.c b/src/ngircd/numeric.c index 0dcfe75b..9b8240bd 100644 --- a/src/ngircd/numeric.c +++ b/src/ngircd/numeric.c @@ -7,12 +7,15 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * Please read the file COPYING, README and AUTHORS for more information. - * - * Handlers for IRC numerics sent to the server */ #include "portab.h" +/** + * @file + * Handlers for IRC numerics sent to the server + */ + #include "imp.h" #include #include @@ -25,6 +28,7 @@ #include "conn.h" #include "conn-func.h" #include "channel.h" +#include "class.h" #include "irc-write.h" #include "lists.h" #include "log.h" @@ -44,12 +48,11 @@ Announce_Channel(CLIENT *Client, CHANNEL *Chan) CL2CHAN *cl2chan; CLIENT *cl; char str[LINE_LEN], *ptr; - bool njoin; + bool njoin, xop; - if (Conn_Options(Client_Conn(Client)) & CONN_RFC1459) - njoin = false; - else - njoin = true; + /* Check features of remote server */ + njoin = Conn_Options(Client_Conn(Client)) & CONN_RFC1459 ? false : true; + xop = strchr(Client_Flags(Client), 'X') ? true : false; /* Get all the members of this channel */ cl2chan = Channel_FirstMember(Chan); @@ -59,14 +62,23 @@ Announce_Channel(CLIENT *Client, CHANNEL *Chan) assert(cl != NULL); if (njoin) { - /* RFC 2813: send NJOIN with nick names and modes + /* RFC 2813: send NJOIN with nicknames and modes * (if user is channel operator or has voice) */ if (str[strlen(str) - 1] != ':') strlcat(str, ",", sizeof(str)); - if (strchr(Channel_UserModes(Chan, cl), 'v')) - strlcat(str, "+", sizeof(str)); + + /* Prepare user prefix (ChanOp, voiced, ...) */ + if (xop && strchr(Channel_UserModes(Chan, cl), 'q')) + strlcat(str, "~", sizeof(str)); + if (xop && strchr(Channel_UserModes(Chan, cl), 'a')) + strlcat(str, "&", sizeof(str)); if (strchr(Channel_UserModes(Chan, cl), 'o')) strlcat(str, "@", sizeof(str)); + if (xop && strchr(Channel_UserModes(Chan, cl), 'h')) + strlcat(str, "%", sizeof(str)); + if (strchr(Channel_UserModes(Chan, cl), 'v')) + strlcat(str, "+", sizeof(str)); + strlcat(str, Client_ID(cl), sizeof(str)); /* Send the data if the buffer is "full" */ @@ -167,32 +179,50 @@ Announce_User(CLIENT * Client, CLIENT * User) Client_ID(User), Client_ID(User), modes); } - return CONNECTED; } else { /* RFC 2813 mode: one combined NICK or SERVICE command */ if (Client_Type(User) == CLIENT_SERVICE - && strchr(Client_Flags(Client), 'S')) - return IRC_WriteStrClient(Client, - "SERVICE %s %d * +%s %d :%s", Client_Mask(User), - Client_MyToken(Client_Introducer(User)), - Client_Modes(User), Client_Hops(User) + 1, - Client_Info(User)); - else - return IRC_WriteStrClient(Client, - "NICK %s %d %s %s %d +%s :%s", - Client_ID(User), Client_Hops(User) + 1, - Client_User(User), Client_Hostname(User), - Client_MyToken(Client_Introducer(User)), - Client_Modes(User), Client_Info(User)); + && strchr(Client_Flags(Client), 'S')) { + if (!IRC_WriteStrClient(Client, + "SERVICE %s %d * +%s %d :%s", + Client_Mask(User), + Client_MyToken(Client_Introducer(User)), + Client_Modes(User), Client_Hops(User) + 1, + Client_Info(User))) + return DISCONNECTED; + } else { + if (!IRC_WriteStrClient(Client, + "NICK %s %d %s %s %d +%s :%s", + Client_ID(User), Client_Hops(User) + 1, + Client_User(User), Client_Hostname(User), + Client_MyToken(Client_Introducer(User)), + Client_Modes(User), Client_Info(User))) + return DISCONNECTED; + } + } + + if (strchr(Client_Flags(Client), 'M')) { + /* Synchronize metadata */ + if (Client_HostnameCloaked(User)) { + if (!IRC_WriteStrClient(Client, + "METADATA %s cloakhost :%s", + Client_ID(User), + Client_HostnameCloaked(User))) + return DISCONNECTED; + } } + + return CONNECTED; } /* Announce_User */ #ifdef IRCPLUS /** - * Synchronize invite and ban lists between servers - * @param Client New server + * Synchronize invite, ban, G- and K-Line lists between servers. + * + * @param Client New server. + * @return CONNECTED or DISCONNECTED. */ static bool Synchronize_Lists(CLIENT * Client) @@ -203,6 +233,18 @@ Synchronize_Lists(CLIENT * Client) assert(Client != NULL); + /* g-lines */ + head = Class_GetList(CLASS_GLINE); + elem = Lists_GetFirst(head); + while (elem) { + if (!IRC_WriteStrClient(Client, "GLINE %s %ld :%s", + Lists_GetMask(elem), + Lists_GetValidity(elem) - time(NULL), + Lists_GetReason(elem))) + return DISCONNECTED; + elem = Lists_GetNext(elem); + } + c = Channel_First(); while (c) { /* ban list */ @@ -366,6 +408,10 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req) } #endif + if (!IRC_WriteStrClient(Client, "PING :%s", + Client_ID(Client_ThisServer()))) + return DISCONNECTED; + return CONNECTED; } /* IRC_Num_ENDOFMOTD */ @@ -391,12 +437,12 @@ IRC_Num_ISUPPORT(CLIENT * Client, REQUEST * Req) if ((unsigned int)atol(value) == Conf_MaxNickLength - 1) continue; - /* Nick name length settings are different! */ + /* Nickname length settings are different! */ Log(LOG_ERR, - "Peer uses incompatible nick name length (%d/%d)! Disconnecting ...", + "Peer uses incompatible nickname length (%d/%d)! Disconnecting ...", Conf_MaxNickLength - 1, atoi(value)); Conn_Close(Client_Conn(Client), - "Incompatible nick name length", + "Incompatible nickname length", NULL, false); return DISCONNECTED; }