Added setting to control the maximum depth of regexroute jumps and includes.
git-svn-id: http://voip.null.ro/svn/yate@4457 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
c18e7fae9a
commit
1ee32baee8
|
@ -79,6 +79,10 @@
|
||||||
; prerouteall: bool: Preroute even calls having a context or with empty caller
|
; prerouteall: bool: Preroute even calls having a context or with empty caller
|
||||||
;prerouteall=no
|
;prerouteall=no
|
||||||
|
|
||||||
|
; maxdepth: int: Maximum number of jumps or recursive includes
|
||||||
|
; Values are clamped to interval 5-100
|
||||||
|
;maxdepth=5
|
||||||
|
|
||||||
|
|
||||||
[$once]
|
[$once]
|
||||||
; First-time only global variables initialization.
|
; First-time only global variables initialization.
|
||||||
|
|
|
@ -34,6 +34,7 @@ static Configuration s_cfg;
|
||||||
static bool s_extended;
|
static bool s_extended;
|
||||||
static bool s_insensitive;
|
static bool s_insensitive;
|
||||||
static bool s_prerouteall;
|
static bool s_prerouteall;
|
||||||
|
static int s_maxDepth = 5;
|
||||||
static Mutex s_mutex(true,"RegexRoute");
|
static Mutex s_mutex(true,"RegexRoute");
|
||||||
static ObjList s_extra;
|
static ObjList s_extra;
|
||||||
static NamedList s_vars("");
|
static NamedList s_vars("");
|
||||||
|
@ -448,7 +449,7 @@ static bool oneContext(Message &msg, String &str, const String &context, String
|
||||||
{
|
{
|
||||||
if (context.null())
|
if (context.null())
|
||||||
return false;
|
return false;
|
||||||
if (depth > 5) {
|
if (depth > s_maxDepth) {
|
||||||
Debug("RegexRoute",DebugWarn,"Possible loop detected, current context '%s'",context.c_str());
|
Debug("RegexRoute",DebugWarn,"Possible loop detected, current context '%s'",context.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -719,6 +720,12 @@ void RegexRoutePlugin::initialize()
|
||||||
m_route = new RouteHandler(priority);
|
m_route = new RouteHandler(priority);
|
||||||
Engine::install(m_route);
|
Engine::install(m_route);
|
||||||
}
|
}
|
||||||
|
int depth = s_cfg.getIntValue("priorities","maxdepth",5);
|
||||||
|
if (depth < 5)
|
||||||
|
depth = 5;
|
||||||
|
else if (depth > 100)
|
||||||
|
depth = 100;
|
||||||
|
s_maxDepth = depth;
|
||||||
NamedList* l = s_cfg.getSection("extra");
|
NamedList* l = s_cfg.getSection("extra");
|
||||||
if (l) {
|
if (l) {
|
||||||
unsigned int len = l->length();
|
unsigned int len = l->length();
|
||||||
|
|
Loading…
Reference in New Issue