convert hostnames to lowercase

This commit is contained in:
Gilles Grandou 2019-12-16 18:27:32 +01:00
parent 79eb79f46c
commit 0616e22e0c

View File

@ -28,16 +28,16 @@ def load_conf():
zone_filename = conf['Files']['zonefile'] zone_filename = conf['Files']['zonefile']
log_filename = conf['Files']['logfile'] log_filename = conf['Files']['logfile']
wan_hostname = conf['Wan']['hostname'] wan_hostname = conf['Wan']['hostname'].lower()
zone_domain = conf['Zone']['domain'] zone_domain = conf['Zone']['domain'].lower()
zone_subdomain = conf['Zone']['subdomain'] zone_subdomain = conf['Zone']['subdomain'].lower()
mail_from = conf['Mail']['from'] mail_from = conf['Mail']['from']
mail_to = conf['Mail']['to'] mail_to = conf['Mail']['to']
mail_ignore_list = [ host for host in conf['MailIgnore'] ] mail_ignore_list = [ host for host in conf['MailIgnore'] ]
hosts_list = [ host for host in conf['Hosts'] ] hosts_list = [ host.lower() for host in conf['Hosts'] ]
hosts_ipv4_nat_list = [ host for host in conf['NatHosts'] ] hosts_ipv4_nat_list = [ host.lower() for host in conf['NatHosts'] ]
hosts_alias_list = conf['Aliases'] hosts_alias_list = [ h.lower() for h in conf['Aliases'] ]
def ping(hostname): def ping(hostname):
@ -53,7 +53,7 @@ def get_ipv6_hosts():
for h in r['status']: for h in r['status']:
if not 'IPv6Address' in h or not h['IPv6Address']: if not 'IPv6Address' in h or not h['IPv6Address']:
continue continue
hostname = h['Name'] hostname = h['Name'].lower()
if hostname in hosts_alias_list: if hostname in hosts_alias_list:
hostname = hosts_alias_list[hostname] hostname = hosts_alias_list[hostname]
for a in h['IPv6Address']: for a in h['IPv6Address']:
@ -105,7 +105,7 @@ def read_zone_list_from_file(zone_filename):
for host in config: for host in config:
for p in config[host]: for p in config[host]:
for target in config[host][p].split('\n'): for target in config[host][p].split('\n'):
zone_list.append([host, p.upper(), target]) zone_list.append([host.lower(), p.upper(), target])
return zone_list return zone_list