From: Alexander Barton Date: Sat, 19 Mar 2011 16:16:14 +0000 (+0100) Subject: Merge branches 'CloakUserHost', 'QuitOnHTTP' and 'bug72-WHOIS-List' X-Git-Tag: rel-18-rc1~37 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=commitdiff_plain;h=fa8b83e69b0d7edcfdcf8f0a4496c79f9c5ec161;hp=d1f604ab89f34412cbe44aaf323b450b800a49d9 Merge branches 'CloakUserHost', 'QuitOnHTTP' and 'bug72-WHOIS-List' * CloakUserHost: Add a note not to use a percent sign ("%") in CloakHost variable Rename ClientHost to CloakHost, and ClientUserNick to CloakUserToNick Don't use "the.net" in sample-ngircd.conf, use "example.net" ngircd.conf.5: document "ClientHost" and "ClientUserNick" Move "ClientHost" and "ClientUserNick" to end of [Global] section ClientUserNick setting ClientHost setting * QuitOnHTTP: Only "handle" HTTP commands on unregistered connections Don't use IRC_QUIT_HTTP() if STRICT_RFC is #define'd IRC_QUIT_HTTP(): enhance error message Move IRC_QUIT_HTTP() below IRC_QUIT() quit on HTTP commands: GET & POST * bug72-WHOIS-List: Add "whois-test" to testsuite and distribution archive Add support for up to 3 targets in WHOIS queries. --- diff --git a/doc/sample-ngircd.conf.tmpl b/doc/sample-ngircd.conf.tmpl index 58696be4..e07b5205 100644 --- a/doc/sample-ngircd.conf.tmpl +++ b/doc/sample-ngircd.conf.tmpl @@ -22,7 +22,7 @@ # Server name in the IRC network, must contain at least one dot # (".") and be unique in the IRC network. Required! - Name = irc.the.net + Name = irc.example.net # Info text of the server. This will be shown by WHOIS and # LINKS requests for example. @@ -154,6 +154,14 @@ # maximum nick name length! ;MaxNickLength = 9 + # Set this hostname for every client instead of the real one. + # Please note: don't use the percentage sign ("%"), it is reserved for + # future extensions! + ;CloakHost = irc.example.net + + # Set every clients' user name to their nick name + ;CloakUserToNick = yes + [Features] # Do any DNS lookups when a client connects to the server. ;DNS = yes @@ -196,11 +204,11 @@ # IRC name of the remote server, must match the "Name" variable in # the [Global] section of the other server (when using ngIRCd). - ;Name = irc2.the.net + ;Name = irc2.example.net # Internet host name or IP address of the peer (only required when # this server should establish the connection). - ;Host = connect-to-host.the.net + ;Host = connect-to-host.example.net # IP address to use as _source_ address for the connection. if # unspecified, ngircd will let the operating system pick an address. diff --git a/man/ngircd.conf.5.tmpl b/man/ngircd.conf.5.tmpl index f071af18..e53cf3cc 100644 --- a/man/ngircd.conf.5.tmpl +++ b/man/ngircd.conf.5.tmpl @@ -250,6 +250,20 @@ Default: 10. Maximum length of an user nick name (Default: 9, as in RFC 2812). Please note that all servers in an IRC network MUST use the same maximum nick name length! +.TP +\fBCloakHost\fR +Set this hostname for every client instead of the real one. Default: empty, +don't change. +.PP +.RS +.B Please note: +.br +Don't use the percentage sign ("%"), it is reserved for future extensions! +.RE +.TP +\fBCloakUserToNick\fR +Set every clients' user name to their nick name and hide the one supplied +by the IRC client. Default: no. .SH [OPERATOR] .I [Operator] sections are used to define IRC Operators. There may be more than one diff --git a/src/ngircd/client.c b/src/ngircd/client.c index 0bfe73d3..e01c4240 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -319,7 +319,11 @@ Client_SetHostname( CLIENT *Client, const char *Hostname ) assert( Client != NULL ); assert( Hostname != NULL ); - strlcpy( Client->host, Hostname, sizeof( Client->host )); + if (strlen(Conf_CloakHost)) { + strlcpy( Client->host, Conf_CloakHost, sizeof( Client->host )); + } else { + strlcpy( Client->host, Hostname, sizeof( Client->host )); + } } /* Client_SetHostname */ @@ -331,6 +335,9 @@ Client_SetID( CLIENT *Client, const char *ID ) strlcpy( Client->id, ID, sizeof( Client->id )); + if (Conf_CloakUserToNick) + strlcpy( Client->user, ID, sizeof( Client->user )); + /* Hash */ Client->hash = Hash( Client->id ); } /* Client_SetID */ @@ -344,6 +351,8 @@ Client_SetUser( CLIENT *Client, const char *User, bool Idented ) assert( Client != NULL ); assert( User != NULL ); + if (Conf_CloakUserToNick) return; + if (Idented) { strlcpy(Client->user, User, sizeof(Client->user)); } else { diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 3ff5ddd8..fb8db2c4 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -351,7 +351,9 @@ Conf_Test( void ) printf(" MaxConnections = %ld\n", Conf_MaxConnections); printf(" MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP); printf(" MaxJoins = %d\n", Conf_MaxJoins > 0 ? Conf_MaxJoins : -1); - printf(" MaxNickLength = %u\n\n", Conf_MaxNickLength - 1); + printf(" MaxNickLength = %u\n", Conf_MaxNickLength - 1); + printf(" CloakHost = %s\n", Conf_CloakHost); + printf(" CloakUserToNick = %s\n\n", yesno_to_str(Conf_CloakUserToNick)); puts("[FEATURES]"); printf(" DNS = %s\n", yesno_to_str(Conf_DNS)); @@ -629,6 +631,9 @@ Set_Defaults(bool InitServers) Conf_MaxJoins = 10; Conf_MaxNickLength = CLIENT_NICK_LEN_DEFAULT; + strcpy(Conf_CloakHost, ""); + Conf_CloakUserToNick = false; + #ifdef SYSLOG #ifdef LOG_LOCAL5 Conf_SyslogFacility = LOG_LOCAL5; @@ -970,6 +975,18 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) Config_Error_TooLong( Line, Var ); return; } + if( strcasecmp( Var, "CloakHost" ) == 0 ) { + /* Client hostname */ + len = strlcpy( Conf_CloakHost, Arg, sizeof( Conf_CloakHost )); + if (len >= sizeof( Conf_CloakHost )) + Config_Error_TooLong( Line, Var ); + return; + } + if( strcasecmp( Var, "CloakUserToNick" ) == 0 ) { + /* Use client nick name as user name */ + Conf_CloakUserToNick = Check_ArgIsTrue( Arg ); + return; + } if( strcasecmp( Var, "Info" ) == 0 ) { /* Info text of server */ len = strlcpy( Conf_ServerInfo, Arg, sizeof( Conf_ServerInfo )); diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h index 8c6aea86..305ccaa1 100644 --- a/src/ngircd/conf.h +++ b/src/ngircd/conf.h @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2010 Alexander Barton (alex@barton.de) + * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors. * * 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 @@ -163,6 +163,12 @@ GLOBAL bool Conf_OperServerMode; /** Flag indicating if remote IRC operators are allowed to manage this server */ GLOBAL bool Conf_AllowRemoteOper; +/** Cloaked hostname of the clients */ +GLOBAL char Conf_CloakHost[CLIENT_ID_LEN]; + +/** Use nick name as user name? */ +GLOBAL bool Conf_CloakUserToNick; + /** Enable all DNS functions? */ GLOBAL bool Conf_DNS; diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c index f76a6270..92d54ab1 100644 --- a/src/ngircd/irc-login.c +++ b/src/ngircd/irc-login.c @@ -683,6 +683,29 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req ) } /* IRC_QUIT */ +#ifndef STRICT_RFC + +/** + * Handler for HTTP command, e.g. GET and POST + * + * We handle these commands here to avoid the quite long timeout when + * some user tries to access this IRC daemon using an web browser ... + * + * @param Client The client from which this command has been received. + * @param Req Request structure with prefix and all parameters. + * @returns CONNECTED or DISCONNECTED. + */ +GLOBAL bool +IRC_QUIT_HTTP( CLIENT *Client, REQUEST *Req ) +{ + Req->argc = 1; + Req->argv[0] = "Oops, HTTP request received? This is IRC!"; + return IRC_QUIT(Client, Req); +} /* IRC_QUIT_HTTP */ + +#endif + + /** * Handler for the IRC "PING" command. * diff --git a/src/ngircd/irc-login.h b/src/ngircd/irc-login.h index 7ba53571..f3138f6e 100644 --- a/src/ngircd/irc-login.h +++ b/src/ngircd/irc-login.h @@ -25,6 +25,7 @@ GLOBAL bool IRC_WEBIRC PARAMS((CLIENT *Client, REQUEST *Req)); GLOBAL bool IRC_PING PARAMS((CLIENT *Client, REQUEST *Req)); GLOBAL bool IRC_PONG PARAMS((CLIENT *Client, REQUEST *Req)); GLOBAL bool IRC_QUIT PARAMS((CLIENT *Client, REQUEST *Req)); +GLOBAL bool IRC_QUIT_HTTP PARAMS((CLIENT *Client, REQUEST *Req)); #endif diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c index 7c56a03d..8203dd0e 100644 --- a/src/ngircd/parse.c +++ b/src/ngircd/parse.c @@ -108,6 +108,10 @@ static COMMAND My_Commands[] = { "WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 }, #ifdef IRCPLUS { "CHANINFO", IRC_CHANINFO, CLIENT_SERVER, 0, 0, 0 }, +#endif +#ifndef STRICT_RFC + { "GET", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, 0, 0 }, + { "POST", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, 0, 0 }, #endif { NULL, NULL, 0x0, 0, 0, 0 } /* Ende-Marke */ };