]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Allow ngIRCd to detect services connected to an "virtual services server".
authorAlexander Barton <alex@barton.de>
Sat, 16 Aug 2008 00:36:30 +0000 (02:36 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 23 Sep 2008 09:51:16 +0000 (11:51 +0200)
Introduce a new configuration variable "ServiceMask" in SERVER blocks to
define a mask matching nick names that should be treated as services.
Regular servers don't need this parameter (leave it empty, the default),
but you should set it to "*Serv" when connection ircservices, for example.

This patch allows ngIRCd to detect services, it doesn't change the
functionality: you only get different log messages ;-)

src/ngircd/conf.c
src/ngircd/conf.h
src/ngircd/irc-login.c

index a60a10e7a250586ce6b51e21f8b9ddb8004bba56..97ecb10ff0176edf525a99b05e87eb1661942dcc 100644 (file)
@@ -42,6 +42,7 @@
 #include "client.h"
 #include "defines.h"
 #include "log.h"
 #include "client.h"
 #include "defines.h"
 #include "log.h"
+#include "match.h"
 #include "resolve.h"
 #include "tool.h"
 
 #include "resolve.h"
 #include "tool.h"
 
@@ -292,6 +293,7 @@ Conf_Test( void )
 #endif
                printf( "  MyPassword = %s\n", Conf_Server[i].pwd_in );
                printf( "  PeerPassword = %s\n", Conf_Server[i].pwd_out );
 #endif
                printf( "  MyPassword = %s\n", Conf_Server[i].pwd_in );
                printf( "  PeerPassword = %s\n", Conf_Server[i].pwd_out );
+               printf( "  ServiceMask = %s\n", Conf_Server[i].svs_mask);
                printf( "  Group = %d\n", Conf_Server[i].group );
                printf( "  Passive = %s\n\n", Conf_Server[i].flags & CONF_SFLAG_DISABLED ? "yes" : "no");
        }
                printf( "  Group = %d\n", Conf_Server[i].group );
                printf( "  Passive = %s\n\n", Conf_Server[i].flags & CONF_SFLAG_DISABLED ? "yes" : "no");
        }
@@ -469,6 +471,16 @@ Conf_AddServer( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd
 } /* Conf_AddServer */
 
 
 } /* Conf_AddServer */
 
 
+/**
+ * Check if the given nick name is an service
+ */
+GLOBAL bool
+Conf_IsService(int ConfServer, char *Nick)
+{
+       return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick);
+} /* Conf_IsService */
+
+
 static void
 Set_Defaults( bool InitServers )
 {
 static void
 Set_Defaults( bool InitServers )
 {
@@ -1128,6 +1140,13 @@ Handle_SERVER( int Line, char *Var, char *Arg )
                        New_Server.flags |= CONF_SFLAG_DISABLED;
                return;
        }
                        New_Server.flags |= CONF_SFLAG_DISABLED;
                return;
        }
+       if (strcasecmp(Var, "ServiceMask") == 0) {
+               len = strlcpy(New_Server.svs_mask, ngt_LowerStr(Arg),
+                             sizeof(New_Server.svs_mask));
+               if (len >= sizeof(New_Server.svs_mask))
+                       Config_Error_TooLong(Line, Var);
+               return;
+       }
        
        Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!",
                                                                NGIRCd_ConfFile, Line, Var );
        
        Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!",
                                                                NGIRCd_ConfFile, Line, Var );
index 0e5b2abd96565dbd4434620e8ced5338d284c594..af489edfc02b64fc484fd7b31a2e0b1f3c2255ff 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -8,8 +8,6 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: conf.h,v 1.49 2008/03/18 20:12:47 fw Exp $
- *
  * Configuration management (header)
  */
 
  * Configuration management (header)
  */
 
@@ -47,11 +45,14 @@ typedef struct _Conf_Server
        RES_STAT res_stat;              /* Status of the resolver */
        int flags;                      /* Flags */
        CONN_ID conn_id;                /* ID of server connection or NONE */
        RES_STAT res_stat;              /* Status of the resolver */
        int flags;                      /* Flags */
        CONN_ID conn_id;                /* ID of server connection or NONE */
-       ng_ipaddr_t bind_addr;          /* source address to use for outgoing connections */
+       ng_ipaddr_t bind_addr;          /* source address to use for outgoing
+                                          connections */
        ng_ipaddr_t dst_addr[2];        /* list of addresses to connect to */
 #ifdef SSL_SUPPORT
        bool SSLConnect;                /* connect() using SSL? */
 #endif
        ng_ipaddr_t dst_addr[2];        /* list of addresses to connect to */
 #ifdef SSL_SUPPORT
        bool SSLConnect;                /* connect() using SSL? */
 #endif
+       char svs_mask[CLIENT_ID_LEN];   /* Mask of nick names that are
+                                          services */
 } CONF_SERVER;
 
 
 } CONF_SERVER;
 
 
@@ -181,6 +182,8 @@ GLOBAL bool Conf_EnablePassiveServer PARAMS((const char *Name));
 GLOBAL bool Conf_DisableServer PARAMS(( char *Name ));
 GLOBAL bool Conf_AddServer PARAMS(( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd ));
 
 GLOBAL bool Conf_DisableServer PARAMS(( char *Name ));
 GLOBAL bool Conf_AddServer PARAMS(( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd ));
 
+GLOBAL bool Conf_IsService PARAMS((int ConfServer, char *Nick));
+
 
 #endif
 
 
 #endif
 
index 85d95022c74ed1f85ea5f6ec874af1ef919a0b48..3cf6ab91e39c0ccd28633a45509b79f4882433ab 100644 (file)
@@ -368,7 +368,7 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
                 * RFC 1459: announce the new client only after receiving the
                 * USER command, first we need more information! */
                if (Req->argc < 7) {
                 * RFC 1459: announce the new client only after receiving the
                 * USER command, first we need more information! */
                if (Req->argc < 7) {
-                       LogDebug("User \"%s\" is beeing registered (RFC 1459) ...",
+                       LogDebug("Client \"%s\" is beeing registered (RFC 1459) ...",
                                 Client_Mask(c));
                        Client_SetType(c, CLIENT_GOTNICK);
                } else
                                 Client_Mask(c));
                        Client_SetType(c, CLIENT_GOTNICK);
                } else
@@ -743,11 +743,17 @@ Kill_Nick( char *Nick, char *Reason )
 static void
 Introduce_Client(CLIENT *From, CLIENT *Client)
 {
 static void
 Introduce_Client(CLIENT *From, CLIENT *Client)
 {
+       char *type;
+
        Client_SetType(Client, CLIENT_USER);
 
        if (From) {
        Client_SetType(Client, CLIENT_USER);
 
        if (From) {
-               LogDebug("User \"%s\" (+%s) registered (via %s, on %s, %d hop%s).",
-                        Client_Mask(Client), Client_Modes(Client),
+               if (Conf_IsService(Conf_GetServer(Client_Conn(From)), Client_ID(Client))) {
+                       type = "Service";
+               } else
+                       type = "User";
+               LogDebug("%s \"%s\" (+%s) registered (via %s, on %s, %d hop%s).",
+                        type, Client_Mask(Client), Client_Modes(Client),
                         Client_ID(From), Client_ID(Client_Introducer(Client)),
                         Client_Hops(Client), Client_Hops(Client) > 1 ? "s": "");
        } else
                         Client_ID(From), Client_ID(Client_Introducer(Client)),
                         Client_Hops(Client), Client_Hops(Client) > 1 ? "s": "");
        } else