]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Make real use of the CLIENT_SERVICE client type.
authorAlexander Barton <alex@barton.de>
Sat, 16 Aug 2008 15:52:02 +0000 (17:52 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 23 Sep 2008 09:53:15 +0000 (11:53 +0200)
This patch enables ngIRCd to handle IRC services as real services, and not
as "fake users":

  - Set correct client type CLIENT_SERVICE for services,
  - Change log messages to include correct client type,
  - PRIVMSG: allow users to send messages to services,
  - Send services nick names to other servers (as users).

Please note that this patch doesn't announce services as services in the
network, but as regular users (as before). Only the local server knows
of services as services (see LUSERS command, for example). It is up to
one of the next patches to fix this and to introduce the SERVICE command
in server to server communication.

The propagation of services as regular users between servers doesn't limit
the functionality of the IRC services and will be the fallback for servers
that don't support "real" services propagation in the future.

src/ngircd/client.c
src/ngircd/irc-channel.c
src/ngircd/irc-login.c
src/ngircd/irc-mode.c
src/ngircd/irc.c
src/ngircd/numeric.c

index a8a2ddfa528c3e34ec84989d0a64acffb8352dfc..1d01f784387bac124925d41c01844ebc7ae1a991 100644 (file)
@@ -402,7 +402,8 @@ Client_SetAway( CLIENT *Client, char *Txt )
        assert( Txt != NULL );
 
        strlcpy( Client->away, Txt, sizeof( Client->away ));
-       Log( LOG_DEBUG, "User \"%s\" is away: %s", Client_Mask( Client ), Txt );
+       LogDebug("%s \"%s\" is away: %s", Client_TypeText(Client),
+                Client_Mask(Client), Txt);
 } /* Client_SetAway */
 
 
index f64570ad6483924c8a72fd08ac8b74088ebf31e7..b557b531192b44074313dff3b74e372be4c96bb9 100644 (file)
@@ -396,9 +396,9 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
 
        /* Set new topic */
        Channel_SetTopic(chan, from, Req->argv[1]);
-       Log(LOG_DEBUG, "User \"%s\" set topic on \"%s\": %s",
-               Client_Mask(from), Channel_Name(chan),
-               Req->argv[1][0] ? Req->argv[1] : "<none>");
+       LogDebug("%s \"%s\" set topic on \"%s\": %s",
+                Client_TypeText(from), Client_Mask(from), Channel_Name(chan),
+                Req->argv[1][0] ? Req->argv[1] : "<none>");
 
        /* im Channel bekannt machen und an Server weiterleiten */
        IRC_WriteStrServersPrefix( Client, from, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
index 95ec959cc0cf9bbf9d588e2776c4a51bbe59a442..9a04a3f74cf29c3eba66208904f8615fbf520c47 100644 (file)
@@ -672,7 +672,7 @@ Hello_User(CLIENT * Client)
        if (strcmp(Client_Password(Client), Conf_ServerPwd) != 0) {
                /* Bad password! */
                Log(LOG_ERR,
-                   "User \"%s\" rejected (connection %d): Bad password!",
+                   "Client \"%s\" rejected (connection %d): Bad password!",
                    Client_Mask(Client), Client_Conn(Client));
                Conn_Close(Client_Conn(Client), NULL, "Bad password", true);
                return DISCONNECTED;
@@ -742,6 +742,7 @@ Introduce_Client(CLIENT *From, CLIENT *Client)
        if (From) {
                if (Conf_IsService(Conf_GetServer(Client_Conn(From)), Client_ID(Client))) {
                        type = "Service";
+                       Client_SetType(Client, CLIENT_SERVICE);
                } else
                        type = "User";
                LogDebug("%s \"%s\" (+%s) registered (via %s, on %s, %d hop%s).",
index f4e3e0f92696bde34fc02b76de825c99585ed00d..76e3ab4677fd40d372e99187c4481ba9b54781db 100644 (file)
@@ -229,7 +229,9 @@ client_exit:
                        ok = IRC_WriteStrClientPrefix( Client, Origin, "MODE %s :%s", Client_ID( Target ), the_modes );
                        IRC_WriteStrServersPrefix( Client, Origin, "MODE %s :%s", Client_ID( Target ), the_modes );
                }
-               Log( LOG_DEBUG, "User \"%s\": Mode change, now \"%s\".", Client_Mask( Target ), Client_Modes( Target ));
+               LogDebug("%s \"%s\": Mode change, now \"%s\".",
+                        Client_TypeText(Target), Client_Mask(Target),
+                        Client_Modes(Target));
        }
        
        IRC_SetPenalty( Client, 1 );    
index ad9d32c9ff0845a90a7a7a2299956b1459bbe986..0741aefa9622f02dc06439c63cba0142365d1f46 100644 (file)
@@ -419,7 +419,14 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
 
                if (cl) {
                        /* Target is a user, enforce type */
+#ifndef STRICT_RFC
+                       if (Client_Type(cl) != ForceType &&
+                           !(ForceType == CLIENT_USER &&
+                             (Client_Type(cl) == CLIENT_USER ||
+                              Client_Type(cl) == CLIENT_SERVICE))) {
+#else
                        if (Client_Type(cl) != ForceType) {
+#endif
                                if (!SendErrors)
                                        return CONNECTED;
                                return IRC_WriteStrClient(from, ERR_NOSUCHNICK_MSG,
index af1ac027927f5215aa0070f0ca3b1c804f0125e3..927989db9923d99567703938a9800ec60b8803ab 100644 (file)
@@ -252,7 +252,8 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
        /* Announce all the users to the new server */
        c = Client_First();
        while (c) {
-               if (Client_Type(c) == CLIENT_USER) {
+               if (Client_Type(c) == CLIENT_USER ||
+                   Client_Type(c) == CLIENT_SERVICE) {
                        if (!Announce_User(Client, c))
                                return DISCONNECTED;
                }