mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 14:53:15 -05:00
- Fix #1350: make cachedb backend configurable (from JINMEI Tatuya).
git-svn-id: file:///svn/unbound/trunk@4275 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
554ff98fd5
commit
c52c07c086
10 changed files with 2801 additions and 2693 deletions
|
|
@ -170,16 +170,17 @@ cachedb_find_backend(const char* str)
|
|||
static int
|
||||
cachedb_apply_cfg(struct cachedb_env* cachedb_env, struct config_file* cfg)
|
||||
{
|
||||
const char* backend_str = "testframe"; /* TODO get from cfg */
|
||||
(void)cfg; /* need this until the TODO is implemented */
|
||||
if(backend_str && backend_str[0]) {
|
||||
cachedb_env->backend = cachedb_find_backend(backend_str);
|
||||
if(!cachedb_env->backend) {
|
||||
log_err("cachedb: cannot find backend name '%s",
|
||||
backend_str);
|
||||
return 0;
|
||||
}
|
||||
const char* backend_str = cfg->cachedb_backend;
|
||||
|
||||
/* If unspecified we use the in-memory test DB. */
|
||||
if(!backend_str)
|
||||
backend_str = "testframe";
|
||||
cachedb_env->backend = cachedb_find_backend(backend_str);
|
||||
if(!cachedb_env->backend) {
|
||||
log_err("cachedb: cannot find backend name '%s'", backend_str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* TODO see if more configuration needs to be applied or not */
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
17 July 2017: Wouter
|
||||
- Fix #1350: make cachedb backend configurable (from JINMEI Tatuya).
|
||||
|
||||
11 July 2017: Wouter
|
||||
- Fix #1344: RFC6761-reserved domains: test. and invalid.
|
||||
- Redirect all localhost names to localhost address for RFC6761.
|
||||
|
|
|
|||
|
|
@ -840,3 +840,11 @@ remote-control:
|
|||
# dnscrypt-secret-key: /path/unbound-conf/keys2/1.key
|
||||
# dnscrypt-provider-cert: /path/unbound-conf/keys1/1.cert
|
||||
# dnscrypt-provider-cert: /path/unbound-conf/keys2/1.cert
|
||||
|
||||
# CacheDB
|
||||
# Enable external backend DB as auxiliary cache. Specify the backend name
|
||||
# (default is "testframe", which has no use other than for debugging and
|
||||
# testing) and backend-specific options. The 'cachedb' module must be
|
||||
# included in module-config.
|
||||
# cachedb:
|
||||
# backend: "testframe"
|
||||
|
|
|
|||
|
|
@ -289,6 +289,9 @@ config_create(void)
|
|||
cfg->ipsecmod_max_ttl = 3600;
|
||||
cfg->ipsecmod_whitelist = NULL;
|
||||
cfg->ipsecmod_strict = 0;
|
||||
#endif
|
||||
#ifdef USE_CACHEDB
|
||||
cfg->cachedb_backend = NULL;
|
||||
#endif
|
||||
return cfg;
|
||||
error_exit:
|
||||
|
|
@ -957,6 +960,9 @@ config_get_option(struct config_file* cfg, const char* opt,
|
|||
else O_DEC(opt, "ipsecmod-max-ttl", ipsecmod_max_ttl)
|
||||
else O_LST(opt, "ipsecmod-whitelist", ipsecmod_whitelist)
|
||||
else O_YNO(opt, "ipsecmod-strict", ipsecmod_strict)
|
||||
#endif
|
||||
#ifdef USE_CACHEDB
|
||||
else O_STR(opt, "backend", cachedb_backend)
|
||||
#endif
|
||||
/* not here:
|
||||
* outgoing-permit, outgoing-avoid - have list of ports
|
||||
|
|
@ -1258,6 +1264,9 @@ config_delete(struct config_file* cfg)
|
|||
#ifdef USE_IPSECMOD
|
||||
free(cfg->ipsecmod_hook);
|
||||
config_delstrlist(cfg->ipsecmod_whitelist);
|
||||
#endif
|
||||
#ifdef USE_CACHEDB
|
||||
free(cfg->cachedb_backend);
|
||||
#endif
|
||||
free(cfg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -480,6 +480,12 @@ struct config_file {
|
|||
/** false to proceed even when ipsecmod_hook fails */
|
||||
int ipsecmod_strict;
|
||||
#endif
|
||||
|
||||
/* cachedb module */
|
||||
#ifdef USE_CACHEDB
|
||||
/** backend DB name */
|
||||
char* cachedb_backend;
|
||||
#endif
|
||||
};
|
||||
|
||||
/** from cfg username, after daemonise setup performed */
|
||||
|
|
|
|||
3263
util/configlexer.c
3263
util/configlexer.c
File diff suppressed because it is too large
Load diff
|
|
@ -423,6 +423,8 @@ ipsecmod-hook{COLON} { YDVAR(1, VAR_IPSECMOD_HOOK) }
|
|||
ipsecmod-max-ttl{COLON} { YDVAR(1, VAR_IPSECMOD_MAX_TTL) }
|
||||
ipsecmod-whitelist{COLON} { YDVAR(1, VAR_IPSECMOD_WHITELIST) }
|
||||
ipsecmod-strict{COLON} { YDVAR(1, VAR_IPSECMOD_STRICT) }
|
||||
cachedb{COLON} { YDVAR(0, VAR_CACHEDB) }
|
||||
backend{COLON} { YDVAR(1, VAR_CACHEDB_BACKEND) }
|
||||
<INITIAL,val>{NEWLINE} { LEXOUT(("NL\n")); cfg_parser->line++; }
|
||||
|
||||
/* Quoted strings. Strip leading and ending quotes */
|
||||
|
|
|
|||
2148
util/configparser.c
2148
util/configparser.c
File diff suppressed because it is too large
Load diff
|
|
@ -257,7 +257,9 @@ extern int yydebug;
|
|||
VAR_IPSECMOD_IGNORE_BOGUS = 467,
|
||||
VAR_IPSECMOD_MAX_TTL = 468,
|
||||
VAR_IPSECMOD_WHITELIST = 469,
|
||||
VAR_IPSECMOD_STRICT = 470
|
||||
VAR_IPSECMOD_STRICT = 470,
|
||||
VAR_CACHEDB = 471,
|
||||
VAR_CACHEDB_BACKEND = 472
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
|
|
@ -474,6 +476,8 @@ extern int yydebug;
|
|||
#define VAR_IPSECMOD_MAX_TTL 468
|
||||
#define VAR_IPSECMOD_WHITELIST 469
|
||||
#define VAR_IPSECMOD_STRICT 470
|
||||
#define VAR_CACHEDB 471
|
||||
#define VAR_CACHEDB_BACKEND 472
|
||||
|
||||
/* Value type. */
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
|
|
@ -484,7 +488,7 @@ union YYSTYPE
|
|||
|
||||
char* str;
|
||||
|
||||
#line 488 "util/configparser.h" /* yacc.c:1909 */
|
||||
#line 492 "util/configparser.h" /* yacc.c:1909 */
|
||||
};
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ extern struct config_parser_state* cfg_parser;
|
|||
%token VAR_DNSCRYPT_SECRET_KEY VAR_DNSCRYPT_PROVIDER_CERT
|
||||
%token VAR_IPSECMOD_ENABLED VAR_IPSECMOD_HOOK VAR_IPSECMOD_IGNORE_BOGUS
|
||||
%token VAR_IPSECMOD_MAX_TTL VAR_IPSECMOD_WHITELIST VAR_IPSECMOD_STRICT
|
||||
%token VAR_CACHEDB VAR_CACHEDB_BACKEND
|
||||
|
||||
%%
|
||||
toplevelvars: /* empty */ | toplevelvars toplevelvar ;
|
||||
|
|
@ -153,7 +154,8 @@ toplevelvar: serverstart contents_server | stubstart contents_stub |
|
|||
forwardstart contents_forward | pythonstart contents_py |
|
||||
rcstart contents_rc | dtstart contents_dt | viewstart
|
||||
contents_view |
|
||||
dnscstart contents_dnsc
|
||||
dnscstart contents_dnsc |
|
||||
cachedbstart contents_cachedb
|
||||
;
|
||||
|
||||
/* server: declaration */
|
||||
|
|
@ -2364,6 +2366,30 @@ dnsc_dnscrypt_secret_key: VAR_DNSCRYPT_SECRET_KEY STRING_ARG
|
|||
fatal_exit("out of memory adding dnscrypt-secret-key");
|
||||
}
|
||||
;
|
||||
|
||||
cachedbstart: VAR_CACHEDB
|
||||
{
|
||||
OUTYY(("\nP(cachedb:)\n"));
|
||||
}
|
||||
;
|
||||
contents_cachedb: contents_cachedb content_cachedb
|
||||
| ;
|
||||
content_cachedb: cachedb_backend_name
|
||||
;
|
||||
cachedb_backend_name: VAR_CACHEDB_BACKEND STRING_ARG
|
||||
{
|
||||
#ifdef USE_CACHEDB
|
||||
OUTYY(("P(backend:%s)\n", $2));
|
||||
if(cfg_parser->cfg->cachedb_backend)
|
||||
yyerror("cachedb backend override, there must be one "
|
||||
"backend");
|
||||
free(cfg_parser->cfg->cachedb_backend);
|
||||
cfg_parser->cfg->cachedb_backend = $2;
|
||||
#else
|
||||
OUTYY(("P(Compiled without cachedb, ignoring)\n"));
|
||||
#endif
|
||||
}
|
||||
;
|
||||
%%
|
||||
|
||||
/* parse helper routines could be here */
|
||||
|
|
|
|||
Loading…
Reference in a new issue