Commit 2b4294fd authored by Chen Wei's avatar Chen Wei

support --address=/#/1.2.3.4

parent 80f0f442
......@@ -263,6 +263,9 @@ struct dict_node * match_domain(struct dict_node *root, char *domain)
int len = strlen (domain);
struct dict_node *node, *res;
if (root == NULL)
return NULL;
memset(buf, 0, sizeof(buf));
memcpy_lower (buf, domain, len);
/*
......
......@@ -144,7 +144,13 @@ search_servers (time_t now, struct all_addr **addrpp,
struct special_domain *obj;
*type = 0;
np = match_domain (daemon->dh_special_domains, qdomain);
/* label of root node is "#", means --address=/#/1.2.3.4 */
if (daemon->dh_special_domains && daemon->dh_special_domains->label &&
*daemon->dh_special_domains->label == '#')
np = daemon->dh_special_domains;
else
np = match_domain (daemon->dh_special_domains, qdomain);
if (np != NULL)
{
obj = (struct special_domain *) np->obj;
......
......@@ -2280,7 +2280,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
}
else
{
/* --xxxx=/example.org/8.8.8.8#53@source-ip|interface#port */
/* --xxxx=/example.org/8.8.8.8#53@source-ip|interface#port
* --xxxx=8.8.8.8 */
err =
parse_server (start_addr, &newserv.addr, &newserv.source_addr,
newserv.interface, &newserv.flags);
......@@ -2318,13 +2319,22 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
while (*arg == '.')
arg++;
//TODO --address=/#/1.2.3.4
// --address=/#/1.2.3.4
// use label in the root node to mark #(match all domains)
if (strcmp (arg, "#") == 0)
domain = "";
{
np = daemon->dh_special_domains;
free(np->label);
np->label = strdup("#");
}
else if (strlen (arg) != 0 && !(domain = canonicalise_opt (arg)))
option = '?';
np = add_or_lookup_domain (daemon->dh_special_domains, domain);
{
option = '?';
}
else if (domain != NULL)
{
np = add_or_lookup_domain(daemon->dh_special_domains, domain);
}
if (np->obj == NULL)
{
......@@ -2374,6 +2384,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
break;
}
}
// --server=8.8.8.8
else if ((strchr (arg, '/') == NULL && option == 'S'))
{
lookup_or_install_new_server (&newserv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment