proxy: properly catch ZeroReturnError
This commit is contained in:
parent
80f208fb2a
commit
89603e5e6f
|
@ -254,7 +254,11 @@ class _TLSLayer(tunnel.TunnelLayer):
|
|||
yield from super().receive_close()
|
||||
|
||||
def send_data(self, data: bytes) -> layer.CommandGenerator[None]:
|
||||
self.tls.sendall(data)
|
||||
try:
|
||||
self.tls.sendall(data)
|
||||
except SSL.ZeroReturnError:
|
||||
# The other peer may still be trying to send data over, which we discard here.
|
||||
pass
|
||||
yield from self.tls_interact()
|
||||
|
||||
def send_close(self, half_close: bool) -> layer.CommandGenerator[None]:
|
||||
|
|
|
@ -75,7 +75,7 @@ class TunnelLayer(layer.Layer):
|
|||
if self.tunnel_state is TunnelState.OPEN:
|
||||
yield from self.receive_close()
|
||||
elif self.tunnel_state is TunnelState.ESTABLISHING:
|
||||
err = "connection closed without notice"
|
||||
err = "connection closed"
|
||||
yield from self.on_handshake_error(err)
|
||||
yield from self._handshake_finished(err)
|
||||
self.tunnel_state = TunnelState.CLOSED
|
||||
|
|
|
@ -509,6 +509,6 @@ class TestClientTLS:
|
|||
<< commands.SendData(tctx.client, tutils.Placeholder())
|
||||
>> events.ConnectionClosed(tctx.client)
|
||||
<< commands.Log("Client TLS handshake failed. The client may not trust the proxy's certificate "
|
||||
"for wrong.host.mitmproxy.org (connection closed without notice)", "warn")
|
||||
"for wrong.host.mitmproxy.org (connection closed)", "warn")
|
||||
<< commands.CloseConnection(tctx.client)
|
||||
)
|
||||
|
|
|
@ -245,7 +245,7 @@ def test_disconnect_during_handshake_command(tctx: Context, disconnect):
|
|||
>> ConnectionClosed(tctx.client)
|
||||
>> ConnectionClosed(server) # proxyserver will cancel all other connections as well.
|
||||
<< CloseConnection(server)
|
||||
<< Log("Opened: err='connection closed without notice'. Server state: CLOSED")
|
||||
<< Log("Opened: err='connection closed'. Server state: CLOSED")
|
||||
<< Log("Got client close.")
|
||||
<< CloseConnection(tctx.client)
|
||||
)
|
||||
|
@ -254,7 +254,7 @@ def test_disconnect_during_handshake_command(tctx: Context, disconnect):
|
|||
playbook
|
||||
>> ConnectionClosed(server)
|
||||
<< CloseConnection(server)
|
||||
<< Log("Opened: err='connection closed without notice'. Server state: CLOSED")
|
||||
<< Log("Opened: err='connection closed'. Server state: CLOSED")
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue