Skip to content

Commit

Permalink
add domain rule "root or sub"
Browse files Browse the repository at this point in the history
  • Loading branch information
coflery authored and pymumu committed Sep 12, 2023
1 parent 1ff7829 commit 1a492f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/dns_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,10 @@ static int _config_domain_rule_add(const char *domain, enum domain_rule type, vo
len--;
if (domain[1] == '.') {
sub_rule_only = 1;
} else if ((domain[1] == '-') && (domain[2] == '.')) {
len--;
sub_rule_only = 1;
root_rule_only = 1;
}
} else if (domain[0] == '-') {
/* root match only */
Expand Down
16 changes: 9 additions & 7 deletions src/dns_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -4046,14 +4046,16 @@ static int _dns_server_get_rules(unsigned char *key, uint32_t key_len, int is_su
return 0;
}

/* only subkey rule */
if (domain_rule->sub_rule_only == 1 && is_subkey == 0) {
return 0;
}
if (domain_rule->sub_rule_only != domain_rule->root_rule_only) {
/* only subkey rule */
if (domain_rule->sub_rule_only == 1 && is_subkey == 0) {
return 0;
}

/* only root key rule */
if (domain_rule->root_rule_only == 1 && is_subkey == 1) {
return 0;
/* only root key rule */
if (domain_rule->root_rule_only == 1 && is_subkey == 1) {
return 0;
}
}

for (i = 0; i < DOMAIN_RULE_MAX; i++) {
Expand Down

0 comments on commit 1a492f7

Please sign in to comment.