]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/parse.c
Only log "IDENT ... no result" when IDENT was looked up
[ngircd-alex.git] / src / ngircd / parse.c
index 72e3430998b301d4011b9b55175e1a91d41875a6..e5eaa6ee3ff9ad6771f13668664fe1c3b5b6ead8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2013 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
 
 #include "imp.h"
 #include "irc.h"
+#include "irc-cap.h"
 #include "irc-channel.h"
+#include "irc-encoding.h"
 #include "irc-info.h"
 #include "irc-login.h"
+#include "irc-metadata.h"
 #include "irc-mode.h"
 #include "irc-op.h"
 #include "irc-oper.h"
@@ -59,10 +62,12 @@ static COMMAND My_Commands[] =
 {
        { "ADMIN", IRC_ADMIN, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "AWAY", IRC_AWAY, CLIENT_USER, 0, 0, 0 },
+       { "CAP", IRC_CAP, 0xFFFF, 0, 0, 0 },
        { "CONNECT", IRC_CONNECT, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "DIE", IRC_DIE, CLIENT_USER, 0, 0, 0 },
        { "DISCONNECT", IRC_DISCONNECT, CLIENT_USER, 0, 0, 0 },
        { "ERROR", IRC_ERROR, 0xFFFF, 0, 0, 0 },
+       { "GLINE", IRC_xLINE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "HELP", IRC_HELP, CLIENT_USER, 0, 0, 0 },
        { "INFO", IRC_INFO, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "INVITE", IRC_INVITE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
@@ -70,9 +75,11 @@ static COMMAND My_Commands[] =
        { "JOIN", IRC_JOIN, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "KICK", IRC_KICK, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "KILL", IRC_KILL, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+       { "KLINE", IRC_xLINE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "LINKS", IRC_LINKS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "LIST", IRC_LIST, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "LUSERS", IRC_LUSERS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+       { "METADATA", IRC_METADATA, CLIENT_SERVER, 0, 0, 0 },
        { "MODE", IRC_MODE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "MOTD", IRC_MOTD, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "NAMES", IRC_NAMES, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
@@ -94,6 +101,7 @@ static COMMAND My_Commands[] =
        { "SQUERY", IRC_SQUERY, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "SQUIT", IRC_SQUIT, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "STATS", IRC_STATS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+       { "SVSNICK", IRC_SVSNICK, CLIENT_SERVER, 0, 0, 0 },
        { "SUMMON", IRC_SUMMON, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "TIME", IRC_TIME, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "TOPIC", IRC_TOPIC, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
@@ -107,14 +115,19 @@ static COMMAND My_Commands[] =
        { "WHO", IRC_WHO, CLIENT_USER, 0, 0, 0 },
        { "WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+
 #ifdef IRCPLUS
        { "CHANINFO", IRC_CHANINFO, CLIENT_SERVER, 0, 0, 0 },
+# ifdef ICONV
+       { "CHARCONV", IRC_CHARCONV, CLIENT_USER, 0, 0, 0 },
+# endif
 #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 */
+       { NULL, NULL, 0x0, 0, 0, 0 } /* End-Mark */
 };
 
 static void Init_Request PARAMS(( REQUEST *Req ));
@@ -144,7 +157,7 @@ Parse_GetCommandStruct( void )
  * Parse a command ("request") received from a client.
  * 
  * This function is called after the connection layer received a valid CR+LF
- * terminated line of text: we asume that this is a valid IRC command and
+ * terminated line of text: we assume that this is a valid IRC command and
  * try to do something useful with it :-)
  *
  * All errors are reported to the client from which the command has been
@@ -156,7 +169,7 @@ Parse_GetCommandStruct( void )
  * @param Idx Index of the connection from which the command has been received.
  * @param Request NULL terminated line of text (the "command").
  * @return true on success (valid command or "regular" error), false if a
- *     fatal error occured and the connection has been shut down.
+ *     fatal error occurred and the connection has been shut down.
  */
 GLOBAL bool
 Parse_Request( CONN_ID Idx, char *Request )
@@ -258,8 +271,6 @@ Parse_Request( CONN_ID Idx, char *Request )
 static void
 Init_Request( REQUEST *Req )
 {
-       /* Neue Request-Struktur initialisieren */
-
        int i;
 
        assert( Req != NULL );
@@ -325,13 +336,21 @@ Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Closed )
        /* check if the client named in the prefix is expected
         * to come from that direction */
        if (Client_NextHop(c) != client) {
-               Log(LOG_ERR,
-                   "Spoofed prefix \"%s\" from \"%s\" (connection %d, command \"%s\")!",
-                   Req->prefix, Client_Mask(Conn_GetClient(Idx)), Idx,
-                   Req->command);
-               Conn_Close(Idx, NULL, "Spoofed prefix", true);
-               *Closed = true;
+               if (Client_Type(c) != CLIENT_SERVER) {
+                       Log(LOG_ERR,
+                           "Spoofed prefix \"%s\" from \"%s\" (connection %d, command \"%s\")!",
+                           Req->prefix, Client_Mask(Conn_GetClient(Idx)), Idx,
+                           Req->command);
+                       Conn_Close(Idx, NULL, "Spoofed prefix", true);
+                       *Closed = true;
+               } else {
+                       Log(LOG_INFO,
+                           "Ignoring spoofed prefix \"%s\" from \"%s\" (connection %d, command \"%s\").",
+                           Req->prefix, Client_Mask(Conn_GetClient(Idx)), Idx,
+                           Req->command);
+               }
                return false;
+
        }
 
        return true;
@@ -346,7 +365,7 @@ Validate_Command( UNUSED CONN_ID Idx, UNUSED REQUEST *Req, bool *Closed )
        *Closed = false;
 
        return true;
-} /* Validate_Comman */
+} /* Validate_Command */
 
 
 static bool
@@ -493,10 +512,20 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
                        continue;
                }
 
-               if (!(client_type & cmd->type))
-                       return IRC_WriteStrClient(client, ERR_NOTREGISTERED_MSG, Client_ID(client));
+               if (!(client_type & cmd->type)) {
+                       if (client_type == CLIENT_USER
+                           && cmd->type & CLIENT_SERVER)
+                               return IRC_WriteErrClient(client,
+                                                ERR_NOTREGISTEREDSERVER_MSG,
+                                                Client_ID(client));
+                       else
+                               return IRC_WriteErrClient(client,
+                                               ERR_NOTREGISTERED_MSG,
+                                               Client_ID(client));
+               }
 
-               /* Command is allowed for this client: call it and count produced bytes */
+               /* Command is allowed for this client: call it and count
+                * generated bytes in output */
                Conn_ResetWCounter();
                result = (cmd->function)(client, Req);
                cmd->bytes += Conn_WCounter();
@@ -520,11 +549,10 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
                        Req->argc == 1 ? "parameter" : "parameters",
                        Req->prefix ? "" : " no" );
 
-       if (Client_Type(client) != CLIENT_SERVER) {
-               result = IRC_WriteStrClient(client, ERR_UNKNOWNCOMMAND_MSG,
+       if (Client_Type(client) != CLIENT_SERVER)
+               result = IRC_WriteErrClient(client, ERR_UNKNOWNCOMMAND_MSG,
                                Client_ID(client), Req->command);
-               Conn_SetPenalty(Idx, 1);
-       }
+
        return result;
 } /* Handle_Request */