diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2014-11-07 15:59:00 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2014-11-07 15:59:00 +1300 |
commit | 9ce2f473f6febf3738dca77b20ab9a7d3092d3d0 (patch) | |
tree | c32840434fe497e8c3e38e452ced2c2202c4d29e /netlib/socks.py | |
parent | ba468f12b8f59f63ce85b221f0cb2d9e004efe6e (diff) | |
download | mitmproxy-9ce2f473f6febf3738dca77b20ab9a7d3092d3d0.tar.gz mitmproxy-9ce2f473f6febf3738dca77b20ab9a7d3092d3d0.tar.bz2 mitmproxy-9ce2f473f6febf3738dca77b20ab9a7d3092d3d0.zip |
Simplify expected_http_body_size signature, fixing a traceback found in fuzzing
Diffstat (limited to 'netlib/socks.py')
-rw-r--r-- | netlib/socks.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/netlib/socks.py b/netlib/socks.py index 5b05b397..a3c4e9a2 100644 --- a/netlib/socks.py +++ b/netlib/socks.py @@ -53,7 +53,10 @@ def _read(f, n): if len(d) == n: return d else: - raise SocksError(REP.GENERAL_SOCKS_SERVER_FAILURE, "Incomplete Read") + raise SocksError( + REP.GENERAL_SOCKS_SERVER_FAILURE, + "Incomplete Read" + ) except socket.error as e: raise SocksError(REP.GENERAL_SOCKS_SERVER_FAILURE, str(e)) @@ -76,6 +79,7 @@ class ClientGreeting(object): f.write(struct.pack("!BB", self.ver, len(self.methods))) f.write(self.methods.tostring()) + class ServerGreeting(object): __slots__ = ("ver", "method") @@ -91,6 +95,7 @@ class ServerGreeting(object): def to_file(self, f): f.write(struct.pack("!BB", self.ver, self.method)) + class Message(object): __slots__ = ("ver", "msg", "atyp", "addr") @@ -108,7 +113,8 @@ class Message(object): "Socks Request: Invalid reserved byte: %s" % rsv) if atyp == ATYP.IPV4_ADDRESS: - host = socket.inet_ntoa(_read(f, 4)) # We use tnoa here as ntop is not commonly available on Windows. + # We use tnoa here as ntop is not commonly available on Windows. + host = socket.inet_ntoa(_read(f, 4)) use_ipv6 = False elif atyp == ATYP.IPV6_ADDRESS: host = socket.inet_ntop(socket.AF_INET6, _read(f, 16)) @@ -135,5 +141,9 @@ class Message(object): f.write(struct.pack("!B", len(self.addr.host))) f.write(self.addr.host) else: - raise SocksError(REP.ADDRESS_TYPE_NOT_SUPPORTED, "Unknown ATYP: %s" % self.atyp) - f.write(struct.pack("!H", self.addr.port))
\ No newline at end of file + raise SocksError( + REP.ADDRESS_TYPE_NOT_SUPPORTED, + "Unknown ATYP: %s" % self.atyp + ) + f.write(struct.pack("!H", self.addr.port)) + |