simplity the connection close for reverse proxy

This commit is contained in:
waldek 2023-03-06 09:50:39 +11:00
parent c420cd90d7
commit ca56b974b8
1 changed files with 19 additions and 0 deletions

View File

@ -329,3 +329,22 @@ class ReverseProxyGeminiProtocol(GeminiProtocol):
"client_certificate": None, "client_certificate": None,
} }
return environ return environ
def finish_connection(self) -> None:
"""
Send the TLS "close_notify" alert and then immediately close the TCP
connection without waiting for the client to respond with it's own
"close_notify" alert.
> It is acceptable for an application to only send its shutdown alert
> and then close the underlying connection without waiting for the
> peer's response. This way resources can be saved, as the process can
> already terminate or serve another connection. This should only be
> done when it is known that the other side will not send more data,
> otherwise there is a risk of a truncation attack.
References:
https://github.com/michael-lazar/jetforce/issues/32
https://www.openssl.org/docs/man1.1.1/man3/SSL_shutdown.html
"""
self.transport.loseConnection()