Skip to content

Commit

Permalink
dns_conf: add -enable-cache for domain-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
pymumu committed Jan 10, 2024
1 parent a75495b commit 422f982
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/dns_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4393,6 +4393,11 @@ static int _conf_domain_rule_no_cache(const char *domain)
return _config_domain_rule_flag_set(domain, DOMAIN_FLAG_NO_CACHE, 0);
}

static int _conf_domain_rule_enable_cache(const char *domain)
{
return _config_domain_rule_flag_set(domain, DOMAIN_FLAG_ENABLE_CACHE, 0);
}

static int _conf_domain_rule_no_ipalias(const char *domain)
{
return _config_domain_rule_flag_set(domain, DOMAIN_FLAG_NO_IPALIAS, 0);
Expand Down Expand Up @@ -4427,6 +4432,7 @@ static int _conf_domain_rules(void *data, int argc, char *argv[])
{"delete", no_argument, NULL, 255},
{"no-cache", no_argument, NULL, 256},
{"no-ip-alias", no_argument, NULL, 257},
{"enable-cache", no_argument, NULL, 258},
{NULL, no_argument, NULL, 0}
};
/* clang-format on */
Expand Down Expand Up @@ -4616,6 +4622,14 @@ static int _conf_domain_rules(void *data, int argc, char *argv[])

break;
}
case 258: {
if (_conf_domain_rule_enable_cache(domain) != 0) {
tlog(TLOG_ERROR, "set enable-cache rule failed.");
goto errout;
}

break;
}
default:
tlog(TLOG_WARN, "unknown domain-rules option: %s at '%s:%d'.", argv[optind - 1], conf_get_conf_file(),
conf_get_current_lineno());
Expand Down
1 change: 1 addition & 0 deletions src/dns_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ typedef enum {
#define DOMAIN_FLAG_NO_CACHE (1 << 17)
#define DOMAIN_FLAG_NO_IPALIAS (1 << 18)
#define DOMAIN_FLAG_GROUP_IGNORE (1 << 19)
#define DOMAIN_FLAG_ENABLE_CACHE (1 << 20)

#define IP_RULE_FLAG_BLACKLIST (1 << 0)
#define IP_RULE_FLAG_WHITELIST (1 << 1)
Expand Down
4 changes: 4 additions & 0 deletions src/dns_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -4792,6 +4792,10 @@ static int _dns_server_pre_process_rule_flags(struct dns_request *request)
request->no_cache = 1;
}

if (flags & DOMAIN_FLAG_ENABLE_CACHE) {
request->no_cache = 0;
}

if (flags & DOMAIN_FLAG_NO_IPALIAS) {
request->no_ipalias = 1;
}
Expand Down

0 comments on commit 422f982

Please sign in to comment.