Optimized const String usage in the message sniffer module.

Hide the returned value of user.auth from sniffing when it holds a password.


git-svn-id: http://voip.null.ro/svn/yate@4445 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2011-06-08 11:44:51 +00:00
parent 0333de04f3
commit bf8bc1a591
1 changed files with 15 additions and 9 deletions

View File

@ -85,11 +85,11 @@ static void dumpParams(const Message &msg, String& par)
bool SniffHandler::received(Message &msg)
{
if (msg == "engine.timer")
if (msg == YSTRING("engine.timer"))
return false;
if (msg == "engine.command") {
if (msg == YSTRING("engine.command")) {
static const String name("sniffer");
String line(msg.getValue("line"));
String line(msg.getValue(YSTRING("line")));
if (line.startSkip(name)) {
line >> s_active;
line.trimSpaces();
@ -104,13 +104,13 @@ bool SniffHandler::received(Message &msg)
msg.retValue() << "\r\n";
return true;
}
line = msg.getParam("partline");
line = msg.getParam(YSTRING("partline"));
if (line.null()) {
if (name.startsWith(msg.getValue("partword")))
if (name.startsWith(msg.getValue(YSTRING("partword"))))
msg.retValue().append(name,"\t");
}
else if (name == line) {
line = msg.getValue("partword");
line = msg.getValue(YSTRING("partword"));
for (const char** b = s_debugs; *b; b++)
if (line.null() || String(*b).startsWith(line))
msg.retValue().append(*b,"\t");
@ -140,7 +140,7 @@ bool SniffHandler::received(Message &msg)
void HookHandler::dispatched(const Message& msg, bool handled)
{
if ((!s_active) || (msg == "engine.timer"))
if ((!s_active) || (msg == YSTRING("engine.timer")))
return;
Lock lock(s_mutex);
if (s_filter && !s_filter.matches(msg))
@ -149,7 +149,13 @@ void HookHandler::dispatched(const Message& msg, bool handled)
u_int64_t dt = Time::now() - msg.msgTime().usec();
String par;
dumpParams(msg,par);
Output("Returned %s '%s' delay=%u.%06u%s\r\n thread=%p '%s'\r\n data=%p\r\n retval='%s'%s",
const char* rval = msg.retValue().c_str();
const char* rsep = "'";
if (handled && rval && (rval[0] != '-' || rval[1]) && (msg == YSTRING("user.auth"))) {
rval = "(hidden)";
rsep = "";
}
Output("Returned %s '%s' delay=%u.%06u%s\r\n thread=%p '%s'\r\n data=%p\r\n retval=%s%s%s%s",
String::boolText(handled),
msg.c_str(),
(unsigned int)(dt / 1000000),
@ -158,7 +164,7 @@ void HookHandler::dispatched(const Message& msg, bool handled)
Thread::current(),
Thread::currentName(),
msg.userData(),
msg.retValue().c_str(),
rsep,rval,rsep,
par.safe());
}