Fix _lookup_host to make it work when server specified

Looking at _host_ source code, split with two new lines is proper.

From https://ftp.isc.org/isc/bind9/9.13.5/bind-9.13.5.tar.gz

$ grep -A10 listed_server.*printed_server bin/dig/host.c
        if (listed_server && !printed_server) {
                char sockstr[ISC_SOCKADDR_FORMATSIZE];

                printf("Using domain server:\n");
                printf("Name: %s\n", query->userarg);
                isc_sockaddr_format(&query->sockaddr, sockstr,
                                    sizeof(sockstr));
                printf("Address: %s\n", sockstr);
                printf("Aliases: \n\n");
                printed_server = true;
        }
This commit is contained in:
Ty Hahn 2019-01-24 21:12:50 +09:00
parent af867e14dc
commit 9498fdc8bc

View File

@ -382,7 +382,8 @@ def _lookup_host(name, rdtype, timeout=None, server=None):
return []
res = []
for line in cmd['stdout'].splitlines():
_stdout = cmd['stdout'] if server is None else cmd['stdout'].split('\n\n')[-1]
for line in _stdout.splitlines():
if rdtype != 'CNAME' and 'is an alias' in line:
continue
line = line.split(' ', 3)[-1]