diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-10-20 10:46:47 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-10-20 10:46:47 +1300 |
commit | 9870844b38c84e7446b15909758497cecb26301e (patch) | |
tree | abb86d6ff64934ec274e5cf2cd5634e92480623a /netlib/utils.py | |
parent | e0f3cce14cb26d10bc259d431f688fb0d10ab3f5 (diff) | |
download | mitmproxy-9870844b38c84e7446b15909758497cecb26301e.tar.gz mitmproxy-9870844b38c84e7446b15909758497cecb26301e.tar.bz2 mitmproxy-9870844b38c84e7446b15909758497cecb26301e.zip |
netlib.utils -> netlib.check
Now only contains is_valid_[host,port]
Intermediate step - this will be in mitproxy.net soon.
Diffstat (limited to 'netlib/utils.py')
-rw-r--r-- | netlib/utils.py | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/netlib/utils.py b/netlib/utils.py deleted file mode 100644 index 7b007cb5..00000000 --- a/netlib/utils.py +++ /dev/null @@ -1,22 +0,0 @@ -import re - -_label_valid = re.compile(b"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE) - - -def is_valid_host(host: bytes) -> bool: - """ - Checks if a hostname is valid. - """ - try: - host.decode("idna") - except ValueError: - return False - if len(host) > 255: - return False - if host and host[-1:] == b".": - host = host[:-1] - return all(_label_valid.match(x) for x in host.split(b".")) - - -def is_valid_port(port): - return 0 <= port <= 65535 |