diff --git a/phpipam-hosts b/phpipam-hosts index 5c2ef2c..6603e4f 100755 --- a/phpipam-hosts +++ b/phpipam-hosts @@ -274,6 +274,16 @@ def listSubnets(): sys.exit(0) +# check if hostname is a valid DNS hostname (DNS names requirements RFC952+RFC1123) +def is_valid_hostname(hostname): + if len(hostname) > 255: + return False + if hostname[-1] == ".": + hostname = hostname[:-1] # strip exactly one dot from the right, if present + allowed = re.compile("(?!-)[A-Z\d-]{1,63}(?