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 | |
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')
-rw-r--r-- | netlib/check.py (renamed from netlib/utils.py) | 0 | ||||
-rw-r--r-- | netlib/http/http1/read.py | 4 | ||||
-rw-r--r-- | netlib/http/url.py | 6 | ||||
-rw-r--r-- | netlib/socks.py | 5 |
4 files changed, 8 insertions, 7 deletions
diff --git a/netlib/utils.py b/netlib/check.py index 7b007cb5..7b007cb5 100644 --- a/netlib/utils.py +++ b/netlib/check.py diff --git a/netlib/http/http1/read.py b/netlib/http/http1/read.py index 4c00a96a..89b73c5a 100644 --- a/netlib/http/http1/read.py +++ b/netlib/http/http1/read.py @@ -6,7 +6,7 @@ from netlib.http import request from netlib.http import response from netlib.http import headers from netlib.http import url -from netlib import utils +from netlib import check from netlib import exceptions @@ -274,7 +274,7 @@ def _parse_authority_form(hostport): try: host, port = hostport.split(b":") port = int(port) - if not utils.is_valid_host(host) or not utils.is_valid_port(port): + if not check.is_valid_host(host) or not check.is_valid_port(port): raise ValueError() except ValueError: raise exceptions.HttpSyntaxException("Invalid host specification: {}".format(hostport)) diff --git a/netlib/http/url.py b/netlib/http/url.py index 67e22efa..3ca58120 100644 --- a/netlib/http/url.py +++ b/netlib/http/url.py @@ -2,7 +2,7 @@ import urllib from typing import Sequence from typing import Tuple -from netlib import utils +from netlib import check # PY2 workaround @@ -62,9 +62,9 @@ def parse(url): if not full_path.startswith(b"/"): full_path = b"/" + full_path - if not utils.is_valid_host(host): + if not check.is_valid_host(host): raise ValueError("Invalid Host") - if not utils.is_valid_port(port): + if not check.is_valid_port(port): raise ValueError("Invalid Port") return parsed.scheme, host, port, full_path diff --git a/netlib/socks.py b/netlib/socks.py index 30fe1c9d..377308a8 100644 --- a/netlib/socks.py +++ b/netlib/socks.py @@ -2,7 +2,8 @@ import struct import array import ipaddress -from netlib import tcp, utils +from netlib import tcp +from netlib import check from mitmproxy.types import bidi @@ -204,7 +205,7 @@ class Message: elif atyp == ATYP.DOMAINNAME: length, = struct.unpack("!B", f.safe_read(1)) host = f.safe_read(length) - if not utils.is_valid_host(host): + if not check.is_valid_host(host): raise SocksError(REP.GENERAL_SOCKS_SERVER_FAILURE, "Invalid hostname: %s" % host) host = host.decode("idna") use_ipv6 = False |