]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Merge branches 'CloakUserHost', 'QuitOnHTTP' and 'bug72-WHOIS-List'
authorAlexander Barton <alex@barton.de>
Sat, 19 Mar 2011 16:16:14 +0000 (17:16 +0100)
committerAlexander Barton <alex@barton.de>
Sat, 19 Mar 2011 16:16:14 +0000 (17:16 +0100)
* 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.

doc/sample-ngircd.conf.tmpl
man/ngircd.conf.5.tmpl
src/ngircd/client.c
src/ngircd/conf.c
src/ngircd/conf.h
src/ngircd/irc-login.c
src/ngircd/irc-login.h
src/ngircd/parse.c

index 58696be469f801684db8fab24690f227e776e767..e07b520544c5599d44ed14d04dc22de3f92e1d47 100644 (file)
@@ -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.
        # 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
 
        # 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.
index f071af18e75324f07bb918f1038cccc8e229bda8..e53cf3cc44353cc654b652d57d5e602ca70bc12a 100644 (file)
@@ -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
index 0bfe73d383d399e3903b78b540c382242e65bdb5..e01c424091dc274b559cedd95d87f6275e895ead 100644 (file)
@@ -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 {
index 3ff5ddd896bf57ee5016f9e4b7b866217e6afb78..fb8db2c4c3842b8f0c1b58f4466c317e634b79a8 100644 (file)
@@ -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 ));
index 8c6aea8641194693d90ca0cac3362ecb454abab1..305ccaa1ff8c36540253f6283b43266d16fc043f 100644 (file)
@@ -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;
 
index f76a62707ae8c22cc097385da60ecda80a16db74..92d54ab15e42ad64d2e7d05bd605bccc1cd7f734 100644 (file)
@@ -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.
  *
index 7ba5357114347f69b2915025551496c33c4f486d..f3138f6efaa0a8ddb55fa37910aec3f56850f7b3 100644 (file)
@@ -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
 
index 7c56a03d3478be3fe0111580d294f99e73ae111c..8203dd0ecb2687617af5f911db820733d239d35d 100644 (file)
@@ -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 */
 };