commit 02d76230743a63d29800afc4d2f1f2473e624793 from: Alexander Barton date: Tue Sep 23 09:51:16 2008 UTC Allow ngIRCd to detect services connected to an "virtual services server". 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 ;-) commit - c5342fb4670387fb7f7335e36ac3260c1e8ab514 commit + 02d76230743a63d29800afc4d2f1f2473e624793 blob - a60a10e7a250586ce6b51e21f8b9ddb8004bba56 blob + 97ecb10ff0176edf525a99b05e87eb1661942dcc --- src/ngircd/conf.c +++ src/ngircd/conf.c @@ -42,6 +42,7 @@ #include "client.h" #include "defines.h" #include "log.h" +#include "match.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 ); + 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"); } @@ -469,6 +471,16 @@ Conf_AddServer( char *Name, UINT16 Port, char *Host, c } /* 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 ) { @@ -1128,6 +1140,13 @@ Handle_SERVER( int Line, char *Var, char *Arg ) 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 ); blob - 0e5b2abd96565dbd4434620e8ced5338d284c594 blob + af489edfc02b64fc484fd7b31a2e0b1f3c2255ff --- src/ngircd/conf.h +++ src/ngircd/conf.h @@ -1,6 +1,6 @@ /* * 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 @@ -8,8 +8,6 @@ * (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) */ @@ -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 */ - 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 + char svs_mask[CLIENT_ID_LEN]; /* Mask of nick names that are + services */ } CONF_SERVER; @@ -181,7 +182,9 @@ GLOBAL bool Conf_EnablePassiveServer PARAMS((const cha 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 blob - 85d95022c74ed1f85ea5f6ec874af1ef919a0b48 blob + 3cf6ab91e39c0ccd28633a45509b79f4882433ab --- src/ngircd/irc-login.c +++ src/ngircd/irc-login.c @@ -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) { - 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 @@ -743,11 +743,17 @@ Kill_Nick( char *Nick, char *Reason ) static void Introduce_Client(CLIENT *From, CLIENT *Client) { + char *type; + 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