Fixes AttributeError in transparent mode (#4951)

If we haven't connected to the upstream host in transparent mode, then the call to `write` on line 74 will raise an `AttributeError` as we haven't initialised `self.wfile`.

If we add `AttributeError` to the `except` line, then we'll catch the exception and call `_connect`, which will in turn initialise `wfile`.
This commit is contained in:
Felix Ingram 2021-11-24 15:49:47 +00:00 committed by GitHub
parent 27e69651f6
commit b1c1cd3f2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,7 +76,7 @@ class Resolver:
if addr is None:
raise RuntimeError("Cannot resolve original destination.")
return tuple(addr)
except (EOFError, OSError):
except (EOFError, OSError, AttributeError):
self._connect()
return self.original_addr(csock)