Commit aac1f108 authored by Simon Morlat's avatar Simon Morlat

Deep rework of flexisip's logging and sip boolean expressions, introducing a...

Deep rework of flexisip's logging and sip boolean expressions, introducing a new feature: contextual logs.
With more details:
- the boolean expression parser/builder is now generic and could be applied to anything (not just sip message)
- the variables and operators supported by the boolean expressions can easily by extended thanks to map of lambdas.
- the boolean expression builder no longer does any kind of parsing when evaluating expressions. Everything is parsed once and the object representation is then used to perform evaluations. So it is faster than before.
- clear out the previous flexisip::log preinit() and init(), which were hardly understandable, and replace them with a LogManager singleton.
- a new global/log-directory settings allows to set the directory where logs are written
- the logs files are now named consistently with the systemd service name, for clarity: flexisip-proxy.log flexisip-presence.log flexisip-conference.log. (Was previously FlexisipLogs_proxy.log)
- a new global/contextual-log-filter setting allows to set SIP boolean expression conditionning the output of contextual logs.
- a new global/contextual-log-level setting allows to set the log level when the contextual-log-filter is matched.
- log directory is now automatically created by the rpm and deb packages.
- a bc-tester style test suite is added, for now it just tests the boolean expression engine. The goal of the test suite is to test low level features of flexisip. It does not intend to replace the "Flexisip" tests suite of liblinphone_tester. We need linphone to test flexisip.
parent b5054bcc
Pipeline #4566 passed with stages
in 13 minutes and 14 seconds
......@@ -14,3 +14,11 @@ Group changes to describe their impact on the project, as follows:
### [Added]
- [Presence server] Support of bodyless subscription.
- [Proxy] Add contextual logs settings
### [Changed]
- [Proxy] log files are now named flexisip-proxy.log, flexisip-conference.log flexisip-presence.log
- [Proxy] boolean expression engine is faster
### [Fixed]
- Memory leak (of SIP transactions) in presence server
......@@ -54,6 +54,7 @@ option(ENABLE_TRANSCODER "Build transcoder support" YES)
option(ENABLE_MDNS "Build multicast DNS support" NO)
option(ENABLE_EXTERNAL_AUTH_PLUGIN "Enable ExternalAuth plugin support" NO)
option(ENABLE_JWE_AUTH_PLUGIN "Enable JweAuth plugin support" NO)
option(ENABLE_UNIT_TESTS "Enable flexisip unit tests (low level tests)" ON)
cmake_dependent_option(ENABLE_SPECIFIC_FEATURES "Enable mediarelay specific features" OFF "ENABLE_TRANSCODER" OFF)
......@@ -250,5 +251,9 @@ add_subdirectory(src)
add_subdirectory(scripts)
add_subdirectory(share)
if(ENABLE_UNIT_TESTS)
add_subdirectory(tester)
endif()
# Packaging
add_subdirectory(build)
......@@ -56,6 +56,8 @@ integration can be used directly, for example:
The "flexisip-rpm" ./prepare.py target can be used to generate rpm packages for flexisip and its dependencies.
"Alien" program is used internaly to convert into debian packages, when this build is run on a debian or debian like linux OS.
The following dependency packages are required (as rpm package name):
mbedtls-devel sqlite-devel postgresql-devel rpm-build bison speex-devel
./prepare.py flexisip-rpm -DENABLE_REDIS=ON -DENABLE_BC_HIREDIS=ON
make
......
......@@ -131,6 +131,7 @@ make install DESTDIR=%{buildroot}
mkdir -p $RPM_BUILD_ROOT/etc/flexisip
mkdir -p $RPM_BUILD_ROOT/%{_docdir}
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/flexisip
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/%{_prefix}/log/flexisip
mkdir -p $RPM_BUILD_ROOT/lib/systemd/system
install -p -m 0644 scripts/flexisip.service $RPM_BUILD_ROOT/lib/systemd/system
......@@ -175,6 +176,7 @@ rm -rf $RPM_BUILD_ROOT
%dir %{_includedir}/flexisip
%{_includedir}/flexisip/*.hh
%{_includedir}/flexisip/*.h
%{_includedir}/flexisip/*.cc
%{_localstatedir}/*
%if @ENABLE_PRESENCE@
......
......@@ -44,6 +44,9 @@ set(HEADER_FILES
plugin.hh
registrardb.hh
transaction.hh
sip-boolean-expressions.hh
expressionparser.hh
expressionparser-impl.cc
)
find_package(Git)
......
......@@ -61,10 +61,12 @@ typedef unsigned long oid;
extern oid company_id;
#include <flexisip/expressionparser.hh>
#include <flexisip/sip-boolean-expressions.hh>
#include <flexisip/global.hh>
#include <flexisip/flexisip-exception.hh>
typedef struct sip_s sip_t;
namespace flexisip {
struct LpConfig;
......@@ -538,7 +540,7 @@ class ConfigBooleanExpression : public ConfigValue {
public:
ConfigBooleanExpression(const std::string &name, const std::string &help, const std::string &default_value,
oid oid_index);
std::shared_ptr<BooleanExpression> read() const;
std::shared_ptr<SipBooleanExpression> read() const;
};
template <typename _retType> _retType *GenericStruct::get(const char *name) const {
......
......@@ -39,7 +39,6 @@ class OutgoingAgent;
class IncomingTransaction;
class OutgoingTransaction;
class EventLog;
class SipAttributes;
class MsgSip {
friend class Agent;
......@@ -68,15 +67,11 @@ class MsgSip {
void serialize() const {
msg_serialize(mMsg, (msg_pub_t *)getSip());
}
inline std::shared_ptr<SipAttributes> getSipAttr() {
return mSipAttr;
}
const char *print();
private:
void assignMsg(msg_t *msg);
msg_t *mMsg;
std::shared_ptr<SipAttributes> mSipAttr;
};
class SipEvent : public std::enable_shared_from_this<SipEvent> {
......
This diff is collapsed.
......@@ -29,21 +29,28 @@
namespace flexisip {
class ExpressionElement{
public:
virtual ~ExpressionElement() = default;
};
/*
* Variable represents a text field which is evaluated at run-time using the _valuesT argument.
*/
template <typename _valuesT>
class Variable{
class Variable : public ExpressionElement{
public:
Variable(const std::function< string (const _valuesT &)> &func) : mFunc(func){
Variable(const std::function< std::string (const _valuesT &)> &func) : mFunc(func){
}
~Variable() = default;
virtual std::string get(const _valuesT &args) = 0;
virtual std::string get(const _valuesT &args){
return mFunc(args);
}
virtual bool defined(const _valuesT &args){
if (get(args).empty()) return false;
return true;
}
virtual list<string> getAsList(const _valuesT &args) {
virtual std::list<std::string> getAsList(const _valuesT &args) {
std::list<std::string> valueList;
std::string s = get(args);
......@@ -69,7 +76,9 @@ public:
return valueList;
}
private:
std::function< string (const _valuesT &)> mFunc;
std::function< std::string (const _valuesT &)> mFunc;
protected:
Variable() = default;
};
/*
......@@ -78,9 +87,9 @@ private:
*/
template <typename _valuesT>
class Constant : public Variable<_valuesT>{
string mVal;
std::string mVal;
public:
Constant(const std::string &val) : mVal(val) {
Constant(const std::string &val) : Variable<_valuesT>(), mVal(val) {
}
virtual std::string get(const _valuesT &arg) override{
return mVal;
......@@ -112,15 +121,15 @@ protected:
* true or false.
*/
template <typename _valuesT>
class NamedOperator : public BooleanExpression<_valuesT>{
class NamedOperator : public BooleanExpression<_valuesT>, public ExpressionElement{
public:
NamedOperator(const std::function< bool (const _valuesT &) func) : mFunc(func){
NamedOperator(const std::function< bool (const _valuesT &)> func) : mFunc(func){
}
virtual bool eval(const _valuesT &args) override{
return mFunc(args);
}
private:
std::function< bool (const _valuesT &) mFunc;
std::function< bool (const _valuesT &)> mFunc;
};
/*
......@@ -133,8 +142,8 @@ private:
template <typename _valuesT>
struct ExpressionRules{
public:
std::map<std::string, std::function< string (const _valuesT &)> variables; // the map of variables with their function to evaluate
std::map<std::string, std::function< bool (const _valuesT &)> operators; // the named operators, with their function to evaluate.
std::map<std::string, std::function< std::string (const _valuesT &)>> variables; // the map of variables with their function to evaluate
std::map<std::string, std::function< bool (const _valuesT &)>> operators; // the named operators, with their function to evaluate.
};
/*
......@@ -146,12 +155,19 @@ template <typename _valuesT>
class BooleanExpressionBuilder{
public:
using Var = Variable<_valuesT>;
using Const = Constant<_valuesT>;
using Expr = BooleanExpression<_valuesT>;
BooleanExpressionBuilder(const ExpressionRules<_valuesT> &rules) : mRules(rules){};
BooleanExpressionBuilder(const ExpressionRules<_valuesT> &rules);
std::shared_ptr<BooleanExpression<_valuesT>> parse(const std::string &expression);
private:
std::shared_ptr<Expr> parseExpression(const std::string &expr, size_t *newpos);
size_t findMatchingClosingParenthesis(const std::string &expr, size_t offset) {
void checkRulesOverlap();
size_t findFirstNonWord(const std::string &expr, size_t offset);
size_t findMatchingClosingParenthesis(const std::string &expr, size_t offset);
bool isKeyword(const std::string &expr, size_t *newpos, const std::string &keyword);
std::shared_ptr<Var> buildVariable(const std::string &expr, size_t *newpos);
std::shared_ptr<Const> buildConstant(const std::string &expr, size_t *newpos);
std::shared_ptr<ExpressionElement> buildElement(const std::string &expr, size_t *newpos);
std::shared_ptr<Expr> parseExpression(const std::string &expr, size_t *newpos, bool immediateNeighbour = false);
const ExpressionRules<_valuesT> mRules;
static const std::list<std::string> sBuiltinOperators;
};
......
This diff is collapsed.
......@@ -61,7 +61,7 @@ private:
regex_t mRequiredSubject;
auth_challenger_t mRegistrarChallenger;
auth_challenger_t mProxyChallenger;
std::shared_ptr<BooleanExpression> mNo403Expr;
std::shared_ptr<SipBooleanExpression> mNo403Expr;
bool mNewAuthOn407 = false;
bool mTestAccountsEnabled = false;
bool mDisableQOPAuth = false;
......
/*
Flexisip, a flexible SIP proxy server with media capabilities.
Copyright (C) 2010 Belledonne Communications SARL.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "flexisip/expressionparser.hh"
typedef struct sip_s sip_t;
namespace flexisip{
typedef BooleanExpression<sip_t> SipBooleanExpression;
class SipBooleanExpressionBuilder : public BooleanExpressionBuilder<sip_t>{
public:
static SipBooleanExpressionBuilder &get();
std::shared_ptr<SipBooleanExpression> parse(const std::string &expression);
private:
SipBooleanExpressionBuilder();
static std::shared_ptr<SipBooleanExpressionBuilder> sInstance;
};
}//end of namespace
Subproject commit baecc61d7bb537a5a46e80734b260bcdfb38db9b
Subproject commit 9d2632d8a7b655787c5a3d0a3f4a05dc1cfe8509
......@@ -46,6 +46,7 @@ set(FLEXISIP_SOURCES
cli.cc
cJSON.c
common.cc
sip-boolean-expressions.cc
configdumper.cc
configmanager.cc
contact-masquerader.cc
......@@ -54,7 +55,6 @@ set(FLEXISIP_SOURCES
etchosts.cc
event.cc
eventlogs/eventlogs.cc
expressionparser.cc
forkbasiccontext.cc
forkcallcontext.cc
forkcontext.cc
......@@ -96,7 +96,6 @@ set(FLEXISIP_SOURCES
registrardb-internal.cc
registrardb.cc
sdp-modifier.cc
sipattrextractor.cc
service-server.cc
stun.cc
stun/stun_udp.c
......@@ -343,14 +342,6 @@ if(ENABLE_JWE_AUTH_PLUGIN)
add_subdirectory(plugin/jwe-auth-plugin)
endif()
# expression parser tester
if(MEDIASTREAMER2_FOUND)
add_executable(expr test/expr.cc expressionparser.cc sipattrextractor.hh)
target_link_libraries(expr ${BCTOOLBOX_CORE_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES})
set_property(TARGET expr PROPERTY CXX_STANDARD 11)
set_property(TARGET expr PROPERTY CXX_STANDARD_REQUIRED ON)
target_compile_options(expr PUBLIC -DTEST_BOOL_EXPR -DNO_SOFIA)
endif()
add_executable(flexisip_serializer tools/serializer.cc)
target_link_libraries(flexisip_serializer flexisip)
......
......@@ -24,7 +24,6 @@
#include <flexisip/registrardb.hh>
#include <flexisip/logmanager.hh>
#include "sipattrextractor.hh"
#include "etchosts.hh"
#include <algorithm>
......@@ -974,16 +973,6 @@ template <typename SipEventT>
inline void Agent::doSendEvent(
shared_ptr<SipEventT> ev, const list<Module *>::iterator &begin, const list<Module *>::iterator &end
) {
#define LOG_SCOPED_EV_THREAD(ssargs, key) LOG_SCOPED_THREAD(key, ssargs->getOrEmpty(key));
auto ssargs = ev->getMsgSip()->getSipAttr();
LOG_SCOPED_EV_THREAD(ssargs, "from.uri.user");
LOG_SCOPED_EV_THREAD(ssargs, "from.uri.domain");
LOG_SCOPED_EV_THREAD(ssargs, "to.uri.user");
LOG_SCOPED_EV_THREAD(ssargs, "to.uri.domain");
LOG_SCOPED_EV_THREAD(ssargs, "method_or_status");
LOG_SCOPED_EV_THREAD(ssargs, "callid");
for (auto it = begin; it != end; ++it) {
ev->mCurrModule = (*it);
(*it)->process(ev);
......@@ -996,6 +985,7 @@ inline void Agent::doSendEvent(
}
void Agent::sendRequestEvent(shared_ptr<RequestSipEvent> ev) {
SipLogContext ctx(ev->getMsgSip());
sip_t *sip = ev->getMsgSip()->getSip();
const sip_request_t *req = sip->sip_request;
const url_t *from_url = sip->sip_from ? sip->sip_from->a_url : NULL;
......@@ -1046,7 +1036,7 @@ void Agent::sendResponseEvent(shared_ptr<ResponseSipEvent> ev) {
LOGI("Skipping incoming message on expired agent");
return;
}
SipLogContext ctx(ev->getMsgSip());
SLOGD << "Receiving new Response SIP message: " << ev->getMsgSip()->getSip()->sip_status->st_status << "\n"
<< *ev->getMsgSip();
......@@ -1100,6 +1090,7 @@ void Agent::sendResponseEvent(shared_ptr<ResponseSipEvent> ev) {
}
void Agent::injectRequestEvent(shared_ptr<RequestSipEvent> ev) {
SipLogContext ctx(ev->getMsgSip());
SLOGD << "Inject Request SIP message:\n" << *ev->getMsgSip();
ev->restartProcessing();
SLOGD << "Injecting request event after " << ev->mCurrModule->getModuleName();
......@@ -1114,6 +1105,7 @@ void Agent::injectRequestEvent(shared_ptr<RequestSipEvent> ev) {
}
void Agent::injectResponseEvent(shared_ptr<ResponseSipEvent> ev) {
SipLogContext ctx(ev->getMsgSip());
SLOGD << "Inject Response SIP message:\n" << *ev->getMsgSip();
list<Module *>::iterator it;
ev->restartProcessing();
......@@ -1124,7 +1116,6 @@ void Agent::injectResponseEvent(shared_ptr<ResponseSipEvent> ev) {
break;
}
}
doSendEvent(ev, it, mModules.end());
}
......
......@@ -127,6 +127,14 @@ void CommandLineInterface::handle_config_list_command(unsigned int socket, const
answer(socket, printEntry(entry, true));
}
string CommandLineInterface::agregate(const std::vector<std::string> &args, size_t from_pos){
ostringstream ostr;
for (size_t i = from_pos; i < args.size(); ++i){
ostr << args[i] << " ";
}
return ostr.str();
}
void CommandLineInterface::handle_config_set_command(unsigned int socket, const std::vector<std::string> &args) {
if (args.size() < 2) {
answer(socket, "Error: at least 2 arguments are expected for the CONFIG_SET command");
......@@ -144,16 +152,25 @@ void CommandLineInterface::handle_config_set_command(unsigned int socket, const
ConfigValue *config_value = dynamic_cast<ConfigValue *>(entry);
if (config_value && (arg == "global/debug")) {
config_value->set(value);
updateLogsVerbosity();
LogManager::get().setLogLevel(BCTBX_LOG_DEBUG);
answer(socket, "debug : " + value);
} else if (config_value && (arg == "global/log-level")) {
config_value->set(value);
updateLogsVerbosity();
LogManager::get().setLogLevel(LogManager::get().logLevelFromName(value));
answer(socket, "log-level : " + value);
} else if (config_value && (arg == "global/syslog-level")) {
config_value->set(value);
updateLogsVerbosity();
LogManager::get().setSyslogLevel(LogManager::get().logLevelFromName(value));
answer(socket, "syslog-level : " + value);
} else if (config_value && (arg == "global/contextual-log-level")) {
config_value->set(value);
LogManager::get().setContextualLevel(LogManager::get().logLevelFromName(value));
answer(socket, "contextual-log-level : " + value);
}else if (config_value && (arg == "global/contextual-log-filter")) {
value = agregate(args, 1);
config_value->set(value);
LogManager::get().setContextualFilter(value);
answer(socket, "contextual-log-filter : " + value);
} else {
answer(socket, "Only debug, log-level and syslog-level from global can be updated while flexisip is running");
}
......@@ -294,14 +311,6 @@ std::string CommandLineInterface::printSection(GenericStruct *gstruct, bool prin
return answer;
}
void CommandLineInterface::updateLogsVerbosity() {
GenericManager *manager = GenericManager::get();
std::string loglevel = manager->getGlobal()->get<ConfigString>("log-level")->read();
std::string sysloglevel = manager->getGlobal()->get<ConfigString>("syslog-level")->read();
bool user_errors = manager->getGlobal()->get<ConfigBoolean>("user-errors-logs")->read();
flexisip::log::initLogs(flexisip_sUseSyslog, loglevel, sysloglevel, user_errors, false);
}
void *CommandLineInterface::threadfunc(void *arg) {
CommandLineInterface *thiz = reinterpret_cast<CommandLineInterface *>(arg);
thiz->run();
......
......@@ -49,7 +49,7 @@ private:
static GenericEntry* find(GenericStruct *root, std::vector<std::string> &path);
static std::string printEntry(GenericEntry *entry, bool printHelpInsteadOfValue);
static std::string printSection(GenericStruct *gstruct, bool printHelpInsteadOfValue);
static void updateLogsVerbosity();
std::string agregate(const std::vector<std::string> &args, size_t from_pos);
static void *threadfunc(void *arg);
......
......@@ -24,6 +24,7 @@
#include <flexisip/configmanager.hh>
#include <flexisip/common.hh>
#include <flexisip/logmanager.hh>
#include "flexisip/sip-boolean-expressions.hh"
#include "configdumper.hh"
#include <functional>
......@@ -769,8 +770,8 @@ ConfigBooleanExpression::ConfigBooleanExpression(const string &name, const strin
: ConfigValue(name, BooleanExpr, help, default_value, oid_index) {
}
shared_ptr<BooleanExpression> ConfigBooleanExpression::read() const {
return BooleanExpression::parse(get());
shared_ptr<SipBooleanExpression> ConfigBooleanExpression::read() const {
return SipBooleanExpressionBuilder::get().parse(get());
}
GenericManager *GenericManager::sInstance = 0;
......@@ -826,16 +827,27 @@ RootConfigStruct::~RootConfigStruct() {
}
oid company_id = SNMP_COMPANY_OID;
#ifndef DEFAULT_LOG_DIR
#define DEFAULT_LOG_DIR "/var/opt/belledonne-communications/log/flexisip"
#endif
GenericManager::GenericManager()
: mNeedRestart(false), mDirtyConfig(false),
mConfigRoot("flexisip", "This is the default Flexisip configuration file", {1, 3, 6, 1, 4, 1, company_id}),
mReader(&mConfigRoot), mNotifier(NULL) {
// to make sure global_conf is instanciated first
static ConfigItemDescriptor global_conf[] = {
{String, "log-directory", "Directory where to create log files.", DEFAULT_LOG_DIR },
{String, "log-level", "Verbosity of logs to output. Possible values are debug, message, warning and error", "error"},
{String, "syslog-level", "Verbosity of logs to put in syslog. Possible values are debug, message, warning and error", "error"},
{ByteSize, "max-log-size", "Max size of a log file before switching to a new log file, expressed with units. For example: 10G, 100M. If -1 then there is no maximum size", "100M"},
{Boolean, "user-errors-logs", "Log (on a different log domain) user errors like authentication, registration, routing, etc...", "false"},
{String, "contextual-log-filter", "A boolean expression applied to current SIP message being processed. When matched, logs are output"
" provided that there level is greater than the value defined in contextual-log-level."
" The definition of the SIP boolean expression is the same as for entry filters of modules, which is "
"documented here: https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/Configuration/Filter%20syntax/", ""},
{String, "contextual-log-level", "Verbosity of contextual logs to output when the condition defined in 'contextual-log-filter' is met.", "debug"},
{Boolean, "dump-corefiles", "Generate a corefile when crashing. "
"Note that by default linux will generate coredumps in '/' which is not so convenient. The following shell command can be added to"
" /etc/rc.local in order to write core dumps a in specific directory, for example /home/cores:\n"
......@@ -991,9 +1003,6 @@ GenericManager::GenericManager()
}
bool GenericManager::doIsValidNextConfig(const ConfigValue &cv) {
if (cv.getName() == "log-filter") {
return flexisip::log::validateFilter(cv.getNextValue());
}
return true;
}
......@@ -1008,9 +1017,7 @@ bool GenericManager::doOnConfigStateChanged(const ConfigValue &conf, ConfigState
mDirtyConfig = false;
break;
case ConfigState::Commited:
if (conf.getName() == "log-filter") {
flexisip::log::updateFilter(conf.getNextValue());
} else if (mDirtyConfig) {
if (mDirtyConfig) {
LOGI("Scheduling server restart to apply new config.");
mDirtyConfig = false;
mNeedRestart = true;
......
......@@ -17,7 +17,8 @@
*/
#include "entryfilter.hh"
#include <flexisip/module.hh>
#include "flexisip/module.hh"
#include "flexisip/sip-boolean-expressions.hh"
#include <stdexcept>
using namespace std;
......@@ -65,28 +66,24 @@ void ConfigEntryFilter::loadConfig(const GenericStruct *mc) {
}
}
mEnabled = mc->get<ConfigBoolean>("enabled")->read();
mBooleanExprFilter = BooleanExpression::parse(filter);
try{
mBooleanExprFilter = SipBooleanExpressionBuilder::get().parse(filter);
} catch (exception &e){
LOGF("Could not parse entry filter for module '%s': %s", mc->getName().c_str(), e.what());
}
mEntryName = mc->getName();
}
bool ConfigEntryFilter::canEnter(const shared_ptr<MsgSip> &ms) {
if (!mEnabled)
return false;
auto attr = ms->getSipAttr();
try {
bool e = mBooleanExprFilter->eval(attr.get());
if (e)
++*mCountEvalTrue;
else
++*mCountEvalFalse;
return e;
} catch (FlexisipException &e) {
SLOGD << "Cannot evaluate entry filter [" << mEntryName << "] filter: " << e.what() << "returning false";
return false;
} catch (invalid_argument &e) {
throw FLEXISIP_EXCEPTION << "Fix your " << mEntryName << " filter: " << e.what();
}
bool e = mBooleanExprFilter->eval(*ms->getSip());
if (e)
++*mCountEvalTrue;
else
++*mCountEvalFalse;
return e;
}
bool ConfigEntryFilter::isEnabled() {
......
......@@ -56,7 +56,7 @@ class ConfigEntryFilter : public EntryFilter {
private:
bool mEnabled;
std::shared_ptr<BooleanExpression> mBooleanExprFilter;
std::shared_ptr<SipBooleanExpression> mBooleanExprFilter;
std::string mEntryName;
};
......
......@@ -24,14 +24,12 @@
#include <sofia-sip/sip_protos.h>
#include <sofia-sip/su_tagarg.h>
#include <sofia-sip/msg_addr.h>
#include "sipattrextractor.hh"
using namespace std;
using namespace flexisip;
void MsgSip::assignMsg(msg_t *msg) {
mMsg = msg_ref_create(msg);
mSipAttr = make_shared<SipAttributes>(getSip());
}
MsgSip::MsgSip(msg_t *msg) {
......
This diff is collapsed.
......@@ -107,6 +107,7 @@ static std::shared_ptr<flexisip::PresenceServer> presenceServer;
static std::shared_ptr<flexisip::ConferenceServer> conferenceServer;
#endif // ENABLE_CONFERENCE
using namespace std;
using namespace flexisip;
......@@ -807,18 +808,26 @@ int main(int argc, char *argv[]) {
std::string syslog_level = cfg->getGlobal()->get<ConfigString>("syslog-level")->read();
if (!user_errors) user_errors = cfg->getGlobal()->get<ConfigBoolean>("user-errors-logs")->read();
ortp_set_log_handler(NULL); /*remove ortp's default log handler that logs to stdout*/
ortp_init();
// in case we don't plan to launch flexisip, don't setup the logs.
if (!dumpDefault.getValue().length() && !listOverrides.getValue().length() && !listModules && !dumpMibs &&
!dumpAll) {
uint64_t max_size = cfg->getGlobal()->get<ConfigByteSize>("max-log-size")->read();
flexisip::log::preinit(useSyslog.getValue(), debug, max_size, fName);
LogManager::Parameters logParams;
logParams.logDirectory = cfg->getGlobal()->get<ConfigString>("log-directory")->read();
logParams.logFilename = "flexisip-" + fName + ".log";
logParams.fileMaxSize = cfg->getGlobal()->get<ConfigByteSize>("max-log-size")->read();
logParams.level = debug ? BCTBX_LOG_DEBUG : LogManager::get().logLevelFromName(log_level);
logParams.enableSyslog = useSyslog;
logParams.syslogLevel = LogManager::get().logLevelFromName(syslog_level);
logParams.enableStdout = debug;
logParams.enableUserErrors = user_errors;
LogManager::get().initialize(logParams);
LogManager::get().setContextualFilter(cfg->getGlobal()->get<ConfigString>("contextual-log-filter")->read());
LogManager::get().setContextualLevel(LogManager::get().logLevelFromName(cfg->getGlobal()->get<ConfigString>("contextual-log-level")->read()));
} else {
flexisip::log::disableGlobally();
LogManager::get().disable();
}
flexisip::log::initLogs(useSyslog, debug ? "debug" : log_level, syslog_level, user_errors, useDebug.getValue());
//flexisip::log::updateFilter(cfg->getGlobal()->get<ConfigString>("log-filter")->read());
signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, flexisip_stop);
signal(SIGINT, flexisip_stop);
......@@ -838,9 +847,6 @@ int main(int argc, char *argv[]) {
/*tell parser to support extra headers */
sip_update_default_mclass(sip_extend_mclass(NULL));
log_boolean_expression_evaluation(boolExprEval.getValue());
log_boolean_expression_parsing(boolParseEval.getValue());
if (hostsOverride.getValue().size() != 0) {
auto hosts = hostsOverride.getValue();
auto etcResolver = EtcHostsResolver::get();
......
......@@ -452,7 +452,7 @@ void Authentication::onRequest(shared_ptr<RequestSipEvent> &ev) {
as->body(sip->sip_payload->pl_data);
as->bodyLen(sip->sip_payload->pl_len);
}
as->no403(mNo403Expr->eval(ev->getSip()));
as->no403(mNo403Expr->eval(*ev->getSip()));
as->usedAlgo() = mAlgorithms;
// Attention: the auth_mod_verify method should not send by itself any message but
......
......@@ -30,7 +30,7 @@ private:
static ModuleInfo<ModulePresence> sInfo;
unique_ptr<SipUri> mDestRoute;
su_home_t mHome;
shared_ptr<BooleanExpression> mOnlyListSubscription;
shared_ptr<SipBooleanExpression> mOnlyListSubscription;
void onDeclare(GenericStruct *module_config) {
ConfigItemDescriptor configs[] = {
......@@ -96,7 +96,7 @@ private:
support_list_subscription = true;
}
}
return (!mOnlyListSubscription->eval(ev->getSip()) || support_list_subscription) &&
return (!mOnlyListSubscription->eval(*ev->getSip()) || support_list_subscription) &&
sip->sip_event && strcmp(sip->sip_event->o_type, "presence") == 0;
} else if (sip->sip_request->rq_method == sip_method_publish) {
return !sip->sip_content_type || (
......
......@@ -126,7 +126,6 @@ void Module::reload() {
void Module::processRequest(shared_ptr<RequestSipEvent> &ev) {
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
LOG_SCOPED_THREAD("Module", getModuleName());
try {
if (mFilter->canEnter(ms)) {
......@@ -149,7 +148,6 @@ void Module::processRequest(shared_ptr<RequestSipEvent> &ev) {
void Module::processResponse(shared_ptr<ResponseSipEvent> &ev) {
const shared_ptr<MsgSip> &ms = ev->getMsgSip();
LOG_SCOPED_THREAD("Module", getModuleName());
try {
if (mFilter->canEnter(ms)) {
......
/*
Flexisip, a flexible SIP proxy server with media capabilities.
Copyright (C) 2010 Belledonne Communications SARL.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "flexisip/sip-boolean-expressions.hh"
#include "flexisip/expressionparser-impl.cc"
#include "sofia-sip/sip.h"
using namespace std;
namespace flexisip{
shared_ptr<SipBooleanExpressionBuilder> SipBooleanExpressionBuilder::sInstance;