/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
+ * Copyright (c)2001-2018 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
_CMD("GLINE", IRC_xLINE, CLIENT_USER|CLIENT_SERVER, 0, -1, 0),
_CMD("HELP", IRC_HELP, CLIENT_USER, 0, 1, 2),
_CMD("INFO", IRC_INFO, CLIENT_USER|CLIENT_SERVER, 0, 1, 2),
- _CMD("INVITE", IRC_INVITE, CLIENT_USER|CLIENT_SERVER, 2, 2, 0),
+ _CMD("INVITE", IRC_INVITE, CLIENT_USER|CLIENT_SERVER, 2, 2, 1),
_CMD("ISON", IRC_ISON, CLIENT_USER, 1, -1, 0),
_CMD("JOIN", IRC_JOIN, CLIENT_USER|CLIENT_SERVER, 1, 2, 0),
_CMD("KICK", IRC_KICK, CLIENT_USER|CLIENT_SERVER, 2, 3, 0),
_CMD("USERS", IRC_USERS, CLIENT_USER|CLIENT_SERVER, 0, -1, 0),
_CMD("VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0, 1, 1),
_CMD("WALLOPS", IRC_WALLOPS, CLIENT_USER|CLIENT_SERVER, 1, 1, 0),
- _CMD("WEBIRC", IRC_WEBIRC, CLIENT_UNKNOWN, 4, 4, 0),
+ _CMD("WEBIRC", IRC_WEBIRC, CLIENT_UNKNOWN, 4, 5, 0),
_CMD("WHO", IRC_WHO, CLIENT_USER, 0, 2, 1),
_CMD("WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, -1, 1),
_CMD("WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, -1, 0),
/**
* 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 assume that this is a valid IRC command and
* try to do something useful with it :-)
*
* @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 occurred and the connection has been shut down.
+ * @return CONNECTED on success (valid command or "regular" error), DISCONNECTED
+ * if a fatal error occurred and the connection has been shut down.
*/
GLOBAL bool
Parse_Request( CONN_ID Idx, char *Request )
}
}
- if( ! Validate_Prefix( Idx, &req, &closed )) return ! closed;
- if( ! Validate_Command( Idx, &req, &closed )) return ! closed;
- if( ! Validate_Args( Idx, &req, &closed )) return ! closed;
+ if(!Validate_Prefix(Idx, &req, &closed))
+ return !closed;
+ if(!Validate_Command(Idx, &req, &closed))
+ return !closed;
+ if(!Validate_Args(Idx, &req, &closed))
+ return !closed;
- return Handle_Request( Idx, &req );
+ return Handle_Request(Idx, &req);
} /* Parse_Request */
/* check if the client named in the prefix is expected
* to come from that direction */
if (Client_NextHop(c) != client) {
- if (Client_Type(c) != CLIENT_SERVER) {
+ if (Client_Type(client) != CLIENT_SERVER) {
Log(LOG_ERR,
"Spoofed prefix \"%s\" from \"%s\" (connection %d, command \"%s\"), closing connection!",
Req->prefix, Client_ID(client), Idx, Req->command);
}
/* Determine source */
- if (! Req->prefix[0]) {
- /* Oops, no prefix!? */
- Log(LOG_WARNING, "Got status code %s from \"%s\" without prefix!?",
- Req->command, Client_ID(client));
+ if (!Req->prefix) {
+ Log(LOG_WARNING,
+ "Got status code %s from \"%s\" without prefix!?",
+ Req->command, Client_ID(client));
return true;
}
Handle_Request( CONN_ID Idx, REQUEST *Req )
{
CLIENT *client;
- bool result = true;
+ bool result = CONNECTED;
int client_type;
COMMAND *cmd;
cmd->lcount++;
else
cmd->rcount++;
+
+ /* Return result of command (CONNECTED/DISCONNECTED). */
return result;
}
client_type != CLIENT_SERVICE )
return true;
- /* Unknown command and registered connection: generate error: */
LogDebug("Connection %d: Unknown command \"%s\", %d %s,%s prefix.",
Client_Conn( client ), Req->command, Req->argc,
Req->argc == 1 ? "parameter" : "parameters",
Req->prefix ? "" : " no" );
- if (Client_Type(client) != CLIENT_SERVER)
+ /* Unknown command and registered connection: generate error: */
+ if (client_type != CLIENT_SERVER)
result = IRC_WriteErrClient(client, ERR_UNKNOWNCOMMAND_MSG,
Client_ID(client), Req->command);