mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-06-21 21:10:55 +00:00
Parse IPv6 correctly
Added ipaddress module to parse the IP addresses received from DNS to RFC1924 compliant strings.
This commit is contained in:
parent
18c253eeda
commit
b519db2f77
management
@ -6,6 +6,7 @@ import os, os.path, re, shutil
|
||||
from utils import shell, safe_domain_name, sort_domains
|
||||
|
||||
import idna
|
||||
import ipaddress
|
||||
|
||||
# SELECTING SSL CERTIFICATES FOR USE IN WEB
|
||||
|
||||
@ -249,6 +250,7 @@ def get_certificates_to_provision(env, show_extended_problems=True, force_domain
|
||||
s = r.to_text()
|
||||
if isinstance(s, bytes):
|
||||
s = s.decode('utf-8')
|
||||
s = str(ipaddress.ip_address(s))
|
||||
return s
|
||||
# END HOTFIX
|
||||
|
||||
|
@ -10,6 +10,7 @@ import dns.reversename, dns.resolver
|
||||
import dateutil.parser, dateutil.tz
|
||||
import idna
|
||||
import psutil
|
||||
import ipaddress
|
||||
|
||||
from dns_update import get_dns_zones, build_tlsa_record, get_custom_dns_config, get_secondary_dns, get_custom_dns_records
|
||||
from web_update import get_web_domains, get_domains_with_a_records
|
||||
@ -700,10 +701,11 @@ def query_dns(qname, rtype, nxdomain='[Not Set]', at=None):
|
||||
# BEGIN HOTFIX
|
||||
response_new = []
|
||||
for r in response:
|
||||
if isinstance(r.to_text(), bytes):
|
||||
response_new.append(r.to_text().decode('utf-8'))
|
||||
else:
|
||||
response_new.append(r)
|
||||
s = r.to_text()
|
||||
if isinstance(s, bytes):
|
||||
s = s.decode('utf-8')
|
||||
s = str(ipaddress.ip_address(s))
|
||||
response_new.append(s)
|
||||
response = response_new
|
||||
# END HOTFIX
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user