From f929cdb2b5378aca0cecae477151ed631cd2a85c Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 11 Jun 2013 20:47:37 +0200 Subject: [PATCH] remove the last gethostbyname() call that is in use. No need to merge into rel/auth-3.3. --- pdns/nameserver.cc | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/pdns/nameserver.cc b/pdns/nameserver.cc index a343dfd02d..95dbd3f7dd 100644 --- a/pdns/nameserver.cc +++ b/pdns/nameserver.cc @@ -114,26 +114,18 @@ void UDPNameserver::bindIPv4() if(localname=="0.0.0.0") { int val=1; setsockopt(s, IPPROTO_IP, GEN_IP_PKTINFO, &val, sizeof(val)); - locala.sin4.sin_addr.s_addr = INADDR_ANY; - } - else - { - struct hostent *h=0; - h=gethostbyname(localname.c_str()); - if(!h) - throw AhuException("Unable to resolve local address"); - - locala.sin4.sin_addr.s_addr=*(int*)h->h_addr; } + locala=ComboAddress(localname, ::arg().asNum("local-port")); + if(locala.sin4.sin_family != AF_INET) + throw AhuException("Attempting to bind IPv4 socket to IPv6 address"); - locala.sin4.sin_port=htons(::arg().asNum("local-port")); g_localaddresses.push_back(locala); if(::bind(s, (sockaddr*)&locala, locala.getSocklen()) < 0) { - L<(ntohs(locala.sin4.sin_port))+": "<