mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
dirmngr: Implement a getnameinfo wrapper.
* dirmngr/dns-stuff.h (DNS_NUMERICHOST): New. (DNS_WITHBRACKET): New. * dirmngr/dns-stuff.c (resolve_name_standard): Factor code out to... (map_eai_to_gpg_error): new. (resolve_addr_standard): New. (resolve_dns_addr): New. * dirmngr/ks-engine-hkp.c (is_ip_address): Move to ... * dirmngr/dns-stuff.c (is_ip_address): here. Add support for non bracketed v6 addresses. * dirmngr/t-dns-stuff.c: Remove header netdb.h. (main): Add option --bracket. Use resolve_dns_name instead of getnameinfo. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
7f65e84ac0
commit
816505958a
4 changed files with 221 additions and 60 deletions
|
@ -280,38 +280,6 @@ my_getnameinfo (dns_addrinfo_t ai, char *host, size_t hostlen,
|
|||
}
|
||||
|
||||
|
||||
/* Check whether NAME is an IP address. */
|
||||
static int
|
||||
is_ip_address (const char *name)
|
||||
{
|
||||
int ndots, n;
|
||||
|
||||
if (*name == '[')
|
||||
return 1;
|
||||
/* Check whether it is legacy IP address. */
|
||||
if (*name == '.')
|
||||
return 0; /* No. */
|
||||
ndots = n = 0;
|
||||
for (; *name; name++)
|
||||
{
|
||||
if (*name == '.')
|
||||
{
|
||||
if (name[1] == '.')
|
||||
return 0; /* No. */
|
||||
if (atoi (name+1) > 255)
|
||||
return 0; /* Value too large. */
|
||||
ndots++;
|
||||
n = 0;
|
||||
}
|
||||
else if (!strchr ("012345678", *name))
|
||||
return 0; /* Not a digit. */
|
||||
else if (++n > 3)
|
||||
return 0; /* More than 3 digits. */
|
||||
}
|
||||
return !!(ndots == 3);
|
||||
}
|
||||
|
||||
|
||||
/* Map the host name NAME to the actual to be used host name. This
|
||||
allows us to manage round robin DNS names. We use our own strategy
|
||||
to choose one of the hosts. For example we skip those hosts which
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue