def METHOD_NAME(host_name: str) -> int:
    """validate_hostname - validate the given hostname uses the proper syntax.
    A host name that follows RFC 952 (amended by RFC 1123) is accepted only.
    Host names are not resolved to IP addresses, and IP addresses are also
    accepted.
    Algorithm taken from: https://stackoverflow.com/questions/2532053/validate-a-hostname-string
    Returns 0 on success, 1 on failure.
    """
    if not host_name or len(host_name) > 255:
        return 1
    if _allowed.fullmatch(host_name):
        return 0
    # It is not a valid host name, but could be a valid IP address.
    try:
        ipaddress.ip_address(host_name)
    except ValueError:
        return 1
    return 0