utils.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:public-dns 作者: ssut 项目源码 文件源码
def validate_hostname(hostname):
    hostname = hostname.rstrip('.')

    if not(1 <= len(hostname) <= 253):
        raise InvalidHostname
    for label in hostname.split('.'):
        if not(1 <= len(label) <= 63):
            raise InvalidHostname
    try:
        hostname.encode('ascii')
    except UnicodeEncodeError:
        hostname = encode_idna(hostname)
        if PY3:
            hostname = hostname.decode()
        return validate_hostname(hostname)

    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号