Support /4 and /6 suffixes in interface names in --auth-server

This commit is contained in:
Simon Kelley
2013-11-17 12:23:42 +00:00
parent 587ad4f271
commit f25e6c6d33
3 changed files with 24 additions and 4 deletions

View File

@@ -199,7 +199,12 @@ or
.B --listen-address .B --listen-address
configuration, indeed configuration, indeed
.B --auth-server .B --auth-server
will overide these and provide a different DNS service on the specified interface. The <domain> is the "glue record". It should resolve in the global DNS to a A and/or AAAA record which points to the address dnsmasq is listening on. will overide these and provide a different DNS service on the
specified interface. The <domain> is the "glue record". It should
resolve in the global DNS to a A and/or AAAA record which points to
the address dnsmasq is listening on. When an interface is specified,
it may be qualified with "/4" or "/6" to specify only the IPv4 or IPv6
addresses associated with the interface.
.TP .TP
.B \-2, --no-dhcp-interface=<interface name> .B \-2, --no-dhcp-interface=<interface name>
Do not provide DHCP or TFTP on the specified interface, but do provide DNS service. Do not provide DHCP or TFTP on the specified interface, but do provide DNS service.

View File

@@ -159,7 +159,8 @@ int iface_check(int family, struct all_addr *addr, char *name, int *auth)
for (tmp = daemon->authinterface; tmp; tmp = tmp->next) for (tmp = daemon->authinterface; tmp; tmp = tmp->next)
if (tmp->name) if (tmp->name)
{ {
if (strcmp(tmp->name, name) == 0) if (strcmp(tmp->name, name) == 0 &&
(tmp->addr.sa.sa_family == 0 || tmp->addr.sa.sa_family == family))
break; break;
} }
else if (addr && tmp->addr.sa.sa_family == AF_INET && family == AF_INET && else if (addr && tmp->addr.sa.sa_family == AF_INET && family == AF_INET &&

View File

@@ -1615,8 +1615,22 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
new->addr.sa.sa_family = AF_INET6; new->addr.sa.sa_family = AF_INET6;
#endif #endif
else else
new->name = opt_string_alloc(arg); {
char *fam = split_chr(arg, '/');
new->name = opt_string_alloc(arg);
new->addr.sa.sa_family = 0;
if (fam)
{
if (strcmp(fam, "4") == 0)
new->addr.sa.sa_family = AF_INET;
#ifdef HAVE_IPV6
else if (strcmp(fam, "6") == 0)
new->addr.sa.sa_family = AF_INET6;
#endif
else
ret_err(gen_err);
}
}
new->next = daemon->authinterface; new->next = daemon->authinterface;
daemon->authinterface = new; daemon->authinterface = new;