浏览代码

New script directive to allow specifying the modules' path. This is equivalent
to the command line parameter -L.

Example:

loadpath "/usr/lib/ser/modules/"
loadmodule "maxfwd"



Closes issue #SER-364.

Bogdan Pintea 17 年之前
父节点
当前提交
6c8f8d5bb2
共有 3 个文件被更改,包括 12 次插入0 次删除
  1. 3 0
      NEWS
  2. 2 0
      cfg.lex
  3. 7 0
      cfg.y

+ 3 - 0
NEWS

@@ -136,6 +136,9 @@ core:
                between the short name and long name in cache as CNAME record
 
 new config variables:
+  loadpath = <modules path> - directory where to load the modules from (-L
+     equivalent); modules can be loaded simply by specifying their name
+     (loadmodule "maxfwd")
   tcp_fd_cache = yes | no (default yes) - if enabled FDs used for sending
      will be cached inside the process calling tcp_send (performance increase
      for sending over tcp at the cost of slightly slower connection closing and

+ 2 - 0
cfg.lex

@@ -346,6 +346,7 @@ STUN_ALLOW_FP "stun_allow_fp"
 CFG_DESCRIPTION		"description"|"descr"|"desc"
 
 LOADMODULE	loadmodule
+LOADPATH	loadpath
 MODPARAM        modparam
 
 /* values */
@@ -653,6 +654,7 @@ EAT_ABLE	[\ \t\b\r]
 									return KILL_TIMEOUT; }
 <INITIAL>{CFG_DESCRIPTION}	{ count(); yylval.strval=yytext; return CFG_DESCRIPTION; }
 <INITIAL>{LOADMODULE}	{ count(); yylval.strval=yytext; return LOADMODULE; }
+<INITIAL>{LOADPATH}		{ count(); yylval.strval=yytext; return LOADPATH; }
 <INITIAL>{MODPARAM}     { count(); yylval.strval=yytext; return MODPARAM; }
 
 <INITIAL>{STUN_REFRESH_INTERVAL} { count(); yylval.strval=yytext; return STUN_REFRESH_INTERVAL;}

+ 7 - 0
cfg.y

@@ -321,6 +321,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
 %token SERVER_SIGNATURE
 %token REPLY_TO_VIA
 %token LOADMODULE
+%token LOADPATH
 %token MODPARAM
 %token MAXBUFFER
 %token USER
@@ -1145,6 +1146,12 @@ module_stm:
 			}
 	}
 	| LOADMODULE error	{ yyerror("string expected"); }
+	| LOADPATH STRING {
+		DBG("loading modules under %s\n", $2);
+		printf("loading modules under %s\n", $2);
+		mods_dir = $2;
+	}
+	| LOADPATH error	{ yyerror("string expected"); }
 	| MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
 		if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
 			 yyerror("Can't set module parameter");