diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-07-03 18:59:32 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-07-03 18:59:32 +0400 |
commit | 27360c622541db1cf27dc5bef39524ca912b0e3d (patch) | |
tree | 7dd4d737853d4fe393f8dfaa094a24da204997a2 /src/cfg_file.y | |
parent | ad56efc14e371b6a452c1ccc46aa68d800125468 (diff) | |
download | rspamd-27360c622541db1cf27dc5bef39524ca912b0e3d.tar.gz rspamd-27360c622541db1cf27dc5bef39524ca912b0e3d.zip |
* Add autolearn config options
* Fix parsing of invalid urls in html parser
* Add ability to specify symbols in view parameter as comma-separated list
Diffstat (limited to 'src/cfg_file.y')
-rw-r--r-- | src/cfg_file.y | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/cfg_file.y b/src/cfg_file.y index 17854f22b..1fdc7275f 100644 --- a/src/cfg_file.y +++ b/src/cfg_file.y @@ -24,6 +24,7 @@ GList *cur_module_opt = NULL; struct metric *cur_metric = NULL; struct statfile *cur_statfile = NULL; struct statfile_section *cur_section = NULL; +struct statfile_autolearn_params *cur_autolearn = NULL; struct worker_conf *cur_worker = NULL; struct rspamd_view *cur_view = NULL; @@ -55,6 +56,7 @@ struct rspamd_view *cur_view = NULL; %token STATFILE ALIAS PATTERN WEIGHT STATFILE_POOL_SIZE SIZE TOKENIZER CLASSIFIER %token DELIVERY LMTP ENABLED AGENT SECTION LUACODE RAW_MODE PROFILE_FILE COUNT %token VIEW IP FROM SYMBOLS +%token AUTOLEARN MIN_MARK MAX_MARK %type <string> STRING %type <string> VARIABLE @@ -672,6 +674,7 @@ statfilecmd: | statfilemetric | statfiletokenizer | statfilesection + | statfileautolearn ; statfilealias: @@ -807,6 +810,80 @@ sectionweight: } ; +statfileautolearn: + AUTOLEARN OBRACE autolearnbody EBRACE { + if (cur_statfile == NULL) { + cur_statfile = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile)); + } + if (cur_autolearn == NULL) { + yyerror ("yyparse: error in autolearn definition"); + YYERROR; + } + cur_statfile->autolearn = cur_autolearn; + cur_autolearn = NULL; + } + ; + +autolearnbody: + autolearncmd SEMICOLON + | autolearnbody autolearncmd SEMICOLON + ; + +autolearncmd: + autolearnmetric + | autolearnmin + | autolearnmax + | autolearnsymbols + ; + +autolearnmetric: + METRIC EQSIGN QUOTEDSTRING { + if (cur_autolearn == NULL) { + cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params)); + } + cur_autolearn->metric = memory_pool_strdup (cfg->cfg_pool, $3); + } + ; + +autolearnmin: + MIN_MARK EQSIGN NUMBER { + if (cur_autolearn == NULL) { + cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params)); + } + cur_autolearn->threshold_min = $3; + } + | MIN_MARK EQSIGN FRACT { + if (cur_autolearn == NULL) { + cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params)); + } + cur_autolearn->threshold_min = $3; + } + ; + +autolearnmax: + MAX_MARK EQSIGN NUMBER { + if (cur_autolearn == NULL) { + cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params)); + } + cur_autolearn->threshold_max = $3; + } + | MAX_MARK EQSIGN FRACT { + if (cur_autolearn == NULL) { + cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params)); + } + cur_autolearn->threshold_max = $3; + } + ; + +autolearnsymbols: + SYMBOLS EQSIGN QUOTEDSTRING { + if (cur_autolearn == NULL) { + cur_autolearn = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct statfile_autolearn_params)); + } + cur_autolearn->symbols = parse_comma_list (cfg->cfg_pool, $3); + } + ; + statfile_pool_size: STATFILE_POOL_SIZE EQSIGN SIZELIMIT { cfg->max_statfile_size = $3; |