Format filters

This commit is contained in:
Markus Mäkelä
2019-05-09 11:17:34 +03:00
parent 418ccf861d
commit fbd61967a7
54 changed files with 608 additions and 602 deletions

View File

@ -32,7 +32,6 @@ const size_t INMEMORY_KEY_LENGTH = 2 * SHA512_DIGEST_LENGTH;
#if INMEMORY_KEY_LENGTH > CACHE_KEY_MAXLEN #if INMEMORY_KEY_LENGTH > CACHE_KEY_MAXLEN
#error storage_inmemory key is too long. #error storage_inmemory key is too long.
#endif #endif
} }
InMemoryStorage::InMemoryStorage(const string& name, const CACHE_STORAGE_CONFIG& config) InMemoryStorage::InMemoryStorage(const string& name, const CACHE_STORAGE_CONFIG& config)

View File

@ -26,14 +26,14 @@ unsigned int millisleep(unsigned int milliseconds)
unsigned int seconds = milliseconds / 1000; unsigned int seconds = milliseconds / 1000;
milliseconds -= (seconds * 1000); milliseconds -= (seconds * 1000);
timespec req = { seconds, milliseconds * 1000000 }; // Parentheses required by uncrustify, otherwise it'll think it's a pointer
timespec req = {seconds, (milliseconds * 1000000)};
timespec rem = {0, 0}; timespec rem = {0, 0};
nanosleep(&req, &rem); nanosleep(&req, &rem);
return rem.tv_sec * 1000 + rem.tv_nsec / 1000000; return rem.tv_sec * 1000 + rem.tv_nsec / 1000000;
} }
} }
// //

View File

@ -39,7 +39,6 @@ const MXS_ENUM_VALUE option_values[] =
{"extended", PCRE2_EXTENDED}, {"extended", PCRE2_EXTENDED},
{NULL} {NULL}
}; };
} }
class CCRFilter; class CCRFilter;
@ -343,16 +342,22 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
"V1.1.0", "V1.1.0",
RCAP_TYPE_CONTIGUOUS_INPUT, RCAP_TYPE_CONTIGUOUS_INPUT,
&CCRFilter::s_object, &CCRFilter::s_object,
NULL, /* Process init. */ NULL,
NULL, /* Process finish. */ NULL,
NULL, /* Thread init. */ NULL,
NULL, /* Thread finish. */ NULL,
{ {
{"count", MXS_MODULE_PARAM_COUNT, "0" }, {"count", MXS_MODULE_PARAM_COUNT, "0" },
{"time", MXS_MODULE_PARAM_DURATION, "60s"}, {"time", MXS_MODULE_PARAM_DURATION, "60s"},
{PARAM_MATCH, MXS_MODULE_PARAM_REGEX}, {PARAM_MATCH, MXS_MODULE_PARAM_REGEX},
{PARAM_IGNORE, MXS_MODULE_PARAM_REGEX}, {PARAM_IGNORE, MXS_MODULE_PARAM_REGEX},
{"options", MXS_MODULE_PARAM_ENUM, "ignorecase", MXS_MODULE_OPT_NONE, option_values}, {
"options",
MXS_MODULE_PARAM_ENUM,
"ignorecase",
MXS_MODULE_OPT_NONE,
option_values
},
{MXS_END_MODULE_PARAMS} {MXS_END_MODULE_PARAMS}
} }
}; };

View File

@ -50,7 +50,8 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
return &info; return &info;
} }
CommentFilter::CommentFilter(std::string comment) : m_comment(comment) CommentFilter::CommentFilter(std::string comment)
: m_comment(comment)
{ {
MXS_INFO("Comment filter with comment [%s] created.", m_comment.c_str()); MXS_INFO("Comment filter with comment [%s] created.", m_comment.c_str());
} }

View File

@ -169,7 +169,6 @@ private:
uint32_t m_options; uint32_t m_options;
bool m_disable; bool m_disable;
}; };
} }
bool parse_at_times(const char** tok, char** saveptr, Rule* ruledef); bool parse_at_times(const char** tok, char** saveptr, Rule* ruledef);

View File

@ -36,7 +36,7 @@ void test(const std::string& input, std::initializer_list<std::string> expected)
if (it == expected.end()) if (it == expected.end())
{ {
std::cout << "Too much output: " << std::string(output.first, output.second) << std::endl; std::cout << "Too much output: " << std::string(output.first, output.second) << std::endl;
errors++;; errors++;
break; break;
} }
@ -46,12 +46,12 @@ void test(const std::string& input, std::initializer_list<std::string> expected)
if (have != need) if (have != need)
{ {
std::cout << "Need " << need << " bytes but only have " << have << std::endl; std::cout << "Need " << need << " bytes but only have " << have << std::endl;
errors++;; errors++;
} }
else if (!std::equal(output.first, output.second, it->begin())) else if (!std::equal(output.first, output.second, it->begin()))
{ {
std::cout << "Output not equal to expected output" << std::endl; std::cout << "Output not equal to expected output" << std::endl;
errors++;; errors++;
} }
if (!rval) if (!rval)
@ -69,7 +69,7 @@ void test(const std::string& input, std::initializer_list<std::string> expected)
{ {
std::cout << "Not enough output, need " << std::distance(it, expected.end()) std::cout << "Not enough output, need " << std::distance(it, expected.end())
<< " more comments" << std::endl; << " more comments" << std::endl;
errors++;; errors++;
} }
} }

View File

@ -47,7 +47,6 @@ extern "C"
#include <lua.h> #include <lua.h>
#include <lualib.h> #include <lualib.h>
#include <string.h> #include <string.h>
} }
#include <mutex> #include <mutex>

View File

@ -34,7 +34,6 @@ const char config_value_ignore[] = "ignore";
const char config_value_never[] = "never"; const char config_value_never[] = "never";
const char config_value_true[] = "true"; const char config_value_true[] = "true";
} }
/* /*

View File

@ -88,7 +88,6 @@ private:
uint32_t m_options; uint32_t m_options;
bool m_disable; bool m_disable;
}; };
} }
MaskingFilterSession::MaskingFilterSession(MXS_SESSION* pSession, const MaskingFilter* pFilter) MaskingFilterSession::MaskingFilterSession(MXS_SESSION* pSession, const MaskingFilter* pFilter)

View File

@ -290,45 +290,51 @@ extern "C"
"V1.0.2", "V1.0.2",
RCAP_TYPE_CONTIGUOUS_INPUT, RCAP_TYPE_CONTIGUOUS_INPUT,
&MyObject, &MyObject,
NULL, /* Process init. */ NULL,
NULL, /* Process finish. */ NULL,
NULL, /* Thread init. */ NULL,
NULL, /* Thread finish. */ NULL,
{ {
{"hostname", MXS_MODULE_PARAM_STRING, {"hostname", MXS_MODULE_PARAM_STRING, "localhost" },
"localhost"}, {"username", MXS_MODULE_PARAM_STRING, "guest" },
{"username", MXS_MODULE_PARAM_STRING, {"password", MXS_MODULE_PARAM_STRING, "guest" },
"guest"}, {"vhost", MXS_MODULE_PARAM_STRING, "/" },
{"password", MXS_MODULE_PARAM_STRING, {"port", MXS_MODULE_PARAM_COUNT, "5672" },
"guest"}, {"exchange", MXS_MODULE_PARAM_STRING, "default_exchange"},
{"vhost", MXS_MODULE_PARAM_STRING, {"key", MXS_MODULE_PARAM_STRING, "key" },
"/"},
{"port", MXS_MODULE_PARAM_COUNT,
"5672"},
{"exchange", MXS_MODULE_PARAM_STRING,
"default_exchange"},
{"key", MXS_MODULE_PARAM_STRING,
"key"},
{"queue", MXS_MODULE_PARAM_STRING}, {"queue", MXS_MODULE_PARAM_STRING},
{"ssl_client_certificate", MXS_MODULE_PARAM_PATH, NULL, {"exchange_type", MXS_MODULE_PARAM_STRING, "direct" },
MXS_MODULE_OPT_PATH_R_OK},
{"ssl_client_key", MXS_MODULE_PARAM_PATH, NULL,
MXS_MODULE_OPT_PATH_R_OK},
{"ssl_CA_cert", MXS_MODULE_PARAM_PATH, NULL,
MXS_MODULE_OPT_PATH_R_OK},
{"exchange_type", MXS_MODULE_PARAM_STRING,
"direct"},
{"logging_trigger", MXS_MODULE_PARAM_ENUM, "all",
MXS_MODULE_OPT_NONE,
trigger_values},
{"logging_source_user", MXS_MODULE_PARAM_STRING}, {"logging_source_user", MXS_MODULE_PARAM_STRING},
{"logging_source_host", MXS_MODULE_PARAM_STRING}, {"logging_source_host", MXS_MODULE_PARAM_STRING},
{"logging_schema", MXS_MODULE_PARAM_STRING}, {"logging_schema", MXS_MODULE_PARAM_STRING},
{"logging_object", MXS_MODULE_PARAM_STRING}, {"logging_object", MXS_MODULE_PARAM_STRING},
{"logging_log_all", MXS_MODULE_PARAM_BOOL, {"logging_log_all", MXS_MODULE_PARAM_BOOL, "false" },
"false"}, {"logging_strict", MXS_MODULE_PARAM_BOOL, "true" },
{"logging_strict", MXS_MODULE_PARAM_BOOL, {
"true"}, "ssl_client_certificate",
MXS_MODULE_PARAM_PATH,
NULL,
MXS_MODULE_OPT_PATH_R_OK
},
{
"ssl_client_key",
MXS_MODULE_PARAM_PATH,
NULL,
MXS_MODULE_OPT_PATH_R_OK
},
{
"ssl_CA_cert",
MXS_MODULE_PARAM_PATH,
NULL,
MXS_MODULE_OPT_PATH_R_OK},
{
"logging_trigger",
MXS_MODULE_PARAM_ENUM,
"all",
MXS_MODULE_OPT_NONE,
trigger_values
},
{MXS_END_MODULE_PARAMS} {MXS_END_MODULE_PARAMS}
} }
}; };

View File

@ -878,7 +878,6 @@ void diagnostic(MXS_FILTER* instance, MXS_FILTER_SESSION* fsession, DCB* dcb)
{ {
auto my_instance = static_cast<QlaInstance*>(instance); auto my_instance = static_cast<QlaInstance*>(instance);
my_instance->diagnostics(dcb); my_instance->diagnostics(dcb);
} }
} }
@ -910,7 +909,6 @@ bool cb_log(const MODULECMD_ARG* argv, json_t** output)
return instance->read_to_json(start, end, output); return instance->read_to_json(start, end, output);
} }
} }
/** /**

View File

@ -129,7 +129,6 @@ private:
FILE* m_unified_fp {nullptr}; /* Unified log file. */ FILE* m_unified_fp {nullptr}; /* Unified log file. */
int m_rotation_count {0}; /* Log rotation counter */ int m_rotation_count {0}; /* Log rotation counter */
bool m_write_error_logged {false}; /* Avoid repeatedly printing some errors/warnings. */ bool m_write_error_logged {false}; /* Avoid repeatedly printing some errors/warnings. */
}; };
/* The session structure for this QLA filter. */ /* The session structure for this QLA filter. */
@ -247,5 +246,6 @@ struct LogEventElems
, query(query) , query(query)
, querylen(querylen) , querylen(querylen)
, elapsed_ms(elapsed_ms) , elapsed_ms(elapsed_ms)
{} {
}
}; };

View File

@ -57,7 +57,8 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
namespace throttle namespace throttle
{ {
ThrottleFilter::ThrottleFilter(const ThrottleConfig& config) : m_config(config) ThrottleFilter::ThrottleFilter(const ThrottleConfig& config)
: m_config(config)
{ {
} }