Commit 6ba392a9 authored by Chen Wei's avatar Chen Wei

enable --server without ip address

--server without ip address means the domain is local and the query should not
be forwarded to upstream servers
parent 5c3b4f2c
......@@ -2278,20 +2278,15 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
else if (*start_addr == '\0')
/* --xxxx=/example.org/here-is-empty */
{
/* give --server domain but no ip means the domain is local and
* it may answer queries from /etc/hosts or DHCP but should
* never be forwarded to upstream servers */
if (!(newserv.flags & SERV_NO_REBIND))
newserv.flags |= SERV_NO_ADDR; /* no server */
if (option == 'S')
{
ret_err ("--server must specify server address");
}
if (option == 'A')
{
ret_err ("--address must specify address");
}
}
else
{
/* --xxxx=/example.org/8.8.8.8#53@source-ip|interface#port
......@@ -2377,15 +2372,24 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
obj->domain_flags |= SERV_LITERAL_ADDRESS;
memcpy (&obj->addr, &newserv.addr, sizeof (union mysockaddr));
}
else if (option == 'S')
else if (option == 'S' || option == LOPT_LOCAL)
{
// pointer to one of servers in daemon->servers link list,
// no memory is leaked if obj->server been overwritten
if (newserv.flags & SERV_NO_ADDR)
{
obj->server = NULL;
obj->domain_flags = SERV_NO_ADDR;
}
else
{
/* pointer to one of servers in daemon->servers link
* list, no memory will be leaked if obj->server been
* overwritten*/
newserv.flags |= SERV_HAS_DOMAIN;
obj->server = lookup_or_install_new_server (&newserv);
obj->server->domain = NULL;
obj->domain_flags |= SERV_HAS_DOMAIN;
}
}
if (option == LOPT_NO_REBIND)
{
......
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