code review: getHostname can return ''

pull/1758/head
sebres 2017-04-24 21:32:40 +02:00
parent f75c3d8a02
commit e4ccbe7286
1 changed files with 3 additions and 3 deletions

View File

@ -147,9 +147,9 @@ class DNSUtils:
names = DNSUtils.CACHE_ipToName.get(key)
# get it using different ways (a set with names of localhost, hostname, fully qualified):
if names is None:
names = set(['localhost'])
for fqdn in (False, True):
names.add(DNSUtils.getHostname(fqdn=fqdn))
names = set([
'localhost', DNSUtils.getHostname(False), DNSUtils.getHostname(True)
]) - set(['']) # getHostname can return ''
# cache and return :
DNSUtils.CACHE_ipToName.set(key, names)
return names