size_t clen = 0;
uint8_t hash[CACHEDB_HASHSIZE/8];
const char* hex = "0123456789ABCDEF";
- const char* secret = "default"; /* TODO: from qstate->env->cfg */
+ const char* secret = qstate->env->cfg->cachedb_secret ?
+ qstate->env->cfg->cachedb_secret : "default";
size_t i;
-
+
/* copy the hash info into the clear buffer */
if(clen + qstate->qinfo.qname_len < sizeof(clear)) {
memmove(clear+clen, qstate->qinfo.qname,
+8 August 2017: Wouter
+ - Fix #1398: make cachedb secret configurable.
+
7 August 2017: Wouter
- Fix #1397: Recursive DS lookups for AS112 zones names should recurse.
# included in module-config.
# cachedb:
# backend: "testframe"
+# # secret seed string to calculate hashed keys
+# secret-seed: "default"
.LP
The
.B dnscrypt:
-clause give the settings of the dnscrypt channel. While those options are
+clause gives the settings of the dnscrypt channel. While those options are
available, they are only meaningful if unbound was compiled with
\fB\-\-enable\-dnscrypt\fR.
Currently certificate and secret/public keys cannot be generated by unbound.
Whitelist the domain so that the module logic will be executed. Can
be given multiple times, for different domains. If the option is not
specified, all domains are treated as being whitelisted (default).
+.SS "Cache DB Module Options"
+.LP
+The Cache DB module must be configured in the \fBmodule\-config:\fR
+"validator cachedb iterator" directive and be compiled into the daemon
+with \fB\-\-enable\-cachedb\fR.
+If this module is enabled and configured, the specified backend database
+works as a second level cache:
+When Unbound cannot find an answer to a query in its built-in in-memory
+cache, it consults the specified backend.
+If it finds a valid answer in the backend, Unbound uses it to respond
+to the query without performing iterative DNS resolution.
+If Unbound cannot even find an answer in the backend, it resolves the
+query as usual, and stores the answer in the backend.
+The
+.B cachedb:
+clause gives custom settings of the cache DB module.
+.TP
+.B backend: \fI<backend name>\fR
+Specify the backend database name.
+Currently, only the in-memory "testframe" backend is supported.
+As the name suggests this backend is not of any practical use.
+This option defaults to "testframe".
+.TP
+.B secret-seed: \fI<"secret string">\fR
+Specify a seed to calculate a hash value from query information.
+This value will be used as the key of the corresponding answer for the
+backend database and can be customized if the hash should not be predictable
+operationally.
+If the backend database is shared by multiple Unbound instances,
+all instances must use the same secret seed.
+This option defaults to "default".
.SH "MEMORY CONTROL EXAMPLE"
In the example config settings below memory usage is reduced. Some service
levels are lower, notable very large data and a high TCP load are no longer
#endif
#ifdef USE_CACHEDB
cfg->cachedb_backend = NULL;
+ cfg->cachedb_secret = NULL;
#endif
return cfg;
error_exit:
#endif
#ifdef USE_CACHEDB
else O_STR(opt, "backend", cachedb_backend)
+ else O_STR(opt, "secret-seed", cachedb_secret)
#endif
/* not here:
* outgoing-permit, outgoing-avoid - have list of ports
#endif
#ifdef USE_CACHEDB
free(cfg->cachedb_backend);
+ free(cfg->cachedb_secret);
#endif
free(cfg);
}
#ifdef USE_CACHEDB
/** backend DB name */
char* cachedb_backend;
+ /** secret seed for hash key calculation */
+ char* cachedb_secret;
#endif
};
ipsecmod-strict{COLON} { YDVAR(1, VAR_IPSECMOD_STRICT) }
cachedb{COLON} { YDVAR(0, VAR_CACHEDB) }
backend{COLON} { YDVAR(1, VAR_CACHEDB_BACKEND) }
+secret-seed{COLON} { YDVAR(1, VAR_CACHEDB_SECRETSEED) }
<INITIAL,val>{NEWLINE} { LEXOUT(("NL\n")); cfg_parser->line++; }
/* Quoted strings. Strip leading and ending quotes */
%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
+%token VAR_CACHEDB VAR_CACHEDB_BACKEND VAR_CACHEDB_SECRETSEED
%%
toplevelvars: /* empty */ | toplevelvars toplevelvar ;
;
contents_cachedb: contents_cachedb content_cachedb
| ;
-content_cachedb: cachedb_backend_name
+content_cachedb: cachedb_backend_name | cachedb_secret_seed
;
cachedb_backend_name: VAR_CACHEDB_BACKEND STRING_ARG
{
#endif
}
;
+cachedb_secret_seed: VAR_CACHEDB_SECRETSEED STRING_ARG
+ {
+ #ifdef USE_CACHEDB
+ OUTYY(("P(secret-seed:%s)\n", $2));
+ if(cfg_parser->cfg->cachedb_secret)
+ yyerror("cachedb secret-seed override, there must be "
+ "only one secret");
+ free(cfg_parser->cfg->cachedb_secret);
+ cfg_parser->cfg->cachedb_secret = $2;
+ #else
+ OUTYY(("P(Compiled without cachedb, ignoring)\n"));
+ free($2);
+ #endif
+ }
+ ;
%%
/* parse helper routines could be here */