From 86bdf6e1d4539da1076afe10b57b177fb54dd147 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Fri, 27 Dec 2013 23:16:11 +0100 Subject: Implement new configuration option "Network" The new configuration variable "Network" is used to set the (completely optional) "network name", to which this instance of the daemon belongs. When set, this name is used in the ISUPPORT(005) numeric which is sent to all clients connecting to the server after logging in. Closes bug #165. --- src/ngircd/conf.c | 16 ++++++++++++++++ src/ngircd/conf.h | 3 +++ src/ngircd/irc-info.c | 4 ++++ src/ngircd/messages.h | 1 + 4 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 16275877..bdbb506f 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -369,6 +369,7 @@ Conf_Test( void ) printf(" MotdPhrase = %s\n", array_bytes(&Conf_Motd) ? (const char*) array_start(&Conf_Motd) : ""); } + printf(" Network = %s\n", Conf_Network); #ifndef PAM printf(" Password = %s\n", Conf_ServerPwd); #endif @@ -749,6 +750,7 @@ Set_Defaults(bool InitServers) strcpy(Conf_ServerAdminMail, ""); snprintf(Conf_ServerInfo, sizeof Conf_ServerInfo, "%s %s", PACKAGE_NAME, PACKAGE_VERSION); + strcpy(Conf_Network, ""); free(Conf_ListenAddress); Conf_ListenAddress = NULL; array_free(&Conf_ListenPorts); @@ -1409,6 +1411,7 @@ Handle_GLOBAL(const char *File, int Line, char *Var, char *Arg ) struct group *grp; size_t len; const char *section; + char *ptr; assert(File != NULL); assert(Line > 0); @@ -1491,6 +1494,19 @@ Handle_GLOBAL(const char *File, int Line, char *Var, char *Arg ) Using_MotdFile = false; return; } + if (strcasecmp(Var, "Network") == 0) { + len = strlcpy(Conf_Network, Arg, sizeof(Conf_Network)); + if (len >= sizeof(Conf_Network)) + Config_Error_TooLong(File, Line, Var); + ptr = strchr(Conf_Network, ' '); + if (ptr) { + Config_Error(LOG_WARNING, + "%s, line %d: \"Network\" can't contain spaces!", + File, Line); + *ptr = '\0'; + } + return; + } if(strcasecmp(Var, "Password") == 0) { len = strlcpy(Conf_ServerPwd, Arg, sizeof(Conf_ServerPwd)); if (len >= sizeof(Conf_ServerPwd)) diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h index 02d23315..aa80b8dd 100644 --- a/src/ngircd/conf.h +++ b/src/ngircd/conf.h @@ -109,6 +109,9 @@ GLOBAL char Conf_ServerAdmin1[CLIENT_INFO_LEN]; GLOBAL char Conf_ServerAdmin2[CLIENT_INFO_LEN]; GLOBAL char Conf_ServerAdminMail[CLIENT_INFO_LEN]; +/** Network name (optional, no spaces allowed) */ +GLOBAL char Conf_Network[CLIENT_INFO_LEN]; + /** Message of the day (MOTD) of this server */ GLOBAL array Conf_Motd; diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 56cae2ac..aa98a5b5 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -1539,6 +1539,10 @@ IRC_Send_NAMES(CLIENT * Client, CHANNEL * Chan) GLOBAL bool IRC_Send_ISUPPORT(CLIENT * Client) { + if (Conf_Network[0] && !IRC_WriteStrClient(Client, RPL_ISUPPORTNET_MSG, + Client_ID(Client), + Conf_Network)) + return DISCONNECTED; if (!IRC_WriteStrClient(Client, RPL_ISUPPORT1_MSG, Client_ID(Client), CHANTYPES, CHANTYPES, Conf_MaxJoins)) return DISCONNECTED; diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h index 53b96581..f3a0ba44 100644 --- a/src/ngircd/messages.h +++ b/src/ngircd/messages.h @@ -21,6 +21,7 @@ #define RPL_YOURHOST_MSG "002 %s :Your host is %s, running version ngircd-%s (%s/%s/%s)" #define RPL_CREATED_MSG "003 %s :This server has been started %s" #define RPL_MYINFO_MSG "004 %s %s ngircd-%s %s %s" +#define RPL_ISUPPORTNET_MSG "005 %s NETWORK=%s :is my network name" #define RPL_ISUPPORT1_MSG "005 %s RFC2812 IRCD=ngIRCd CHARSET=UTF-8 CASEMAPPING=ascii PREFIX=(qaohv)~&@%%+ CHANTYPES=%s CHANMODES=beI,k,l,imMnOPQRstVz CHANLIMIT=%s:%d :are supported on this server" #define RPL_ISUPPORT2_MSG "005 %s CHANNELLEN=%d NICKLEN=%d TOPICLEN=%d AWAYLEN=%d KICKLEN=%d MODES=%d MAXLIST=beI:%d EXCEPTS=e INVEX=I PENALTY :are supported on this server" -- cgit 1.4.1