dyndns: accept and validate both A and AAAA records; default to client address

This commit is contained in:
Andreas Oberritter
2019-02-02 13:28:56 +01:00
parent 5b88ec58ec
commit 98f1e96d1a
3 changed files with 63 additions and 31 deletions

View File

@ -2,6 +2,7 @@ import re
import json
import requests
import hashlib
import ipaddress
from app import app
from distutils.version import StrictVersion
@ -291,3 +292,14 @@ def display_setting_state(value):
return "OFF"
else:
return "UNKNOWN"
def validate_ipaddress(address):
try:
ip = ipaddress.ip_address(address)
except ValueError:
pass
else:
if isinstance(ip, (ipaddress.IPv4Address, ipaddress.IPv6Address)):
return [ip]
return []