From: Alexander Barton Date: Sat, 16 Aug 2008 00:36:30 +0000 (+0200) Subject: Allow ngIRCd to detect services connected to an "virtual services server". X-Git-Tag: rel-13-rc1~43 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=commitdiff_plain;h=02d76230743a63d29800afc4d2f1f2473e624793 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 ;-) --- diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index a60a10e7..97ecb10f 100644 --- a/src/ngircd/conf.c +++ b/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, char *MyPwd, char *PeerPwd } /* 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 ); diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h index 0e5b2abd..af489edf 100644 --- a/src/ngircd/conf.h +++ b/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,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_IsService PARAMS((int ConfServer, char *Nick)); + #endif diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c index 85d95022..3cf6ab91 100644 --- a/src/ngircd/irc-login.c +++ b/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