Allow restriction of module command arguments

The module commands now support an optional flag for arguments that when
enabled checks that the argument module name matches the registered domain
name. This can be used to enforce argument type validity for arguments
that are given to modules that expect objects of a certain type.

For example, this is used by the cache and dbfwfilter to prevent valid
filters but of the wrong type being given as arguments.
This commit is contained in:
Markus Mäkelä
2017-01-13 14:12:38 +02:00
parent 265e5c0593
commit 60d4e17996
6 changed files with 66 additions and 40 deletions

View File

@ -24,6 +24,9 @@
* @endverbatim
*/
#define MXS_MODULE_NAME "avrorouter"
#include <maxscale/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -134,10 +137,10 @@ MXS_MODULE* MXS_CREATE_MODULE()
static modulecmd_arg_type_t args[] =
{
{ MODULECMD_ARG_SERVICE, "The avrorouter service" },
{ MODULECMD_ARG_SERVICE | MODULECMD_ARG_NAME_MATCHES_DOMAIN, "The avrorouter service" },
{ MODULECMD_ARG_STRING, "Action, whether to 'start' or 'stop' the conversion process" }
};
modulecmd_register_command("avrorouter", "convert", avro_handle_convert, 2, args);
modulecmd_register_command(MXS_MODULE_NAME, "convert", avro_handle_convert, 2, args);
static ROUTER_OBJECT MyObject =
{