startTLS: separate not-supported messages for client and server

This commit is contained in:
Alberto Sottile 2019-02-05 20:26:44 +01:00
parent ff3e49b87d
commit e6912dc659
6 changed files with 14 additions and 9 deletions

View File

@ -716,9 +716,10 @@ class SyncplayClient(object):
self._endpoint = HostnameEndpoint(reactor, host, port)
try:
self.protocolFactory.options = optionsForClientTLS(hostname=host)
self._clientSupportsTLS = True
except Exception as e:
self.protocolFactory.options = None
self._serverSupportsTLS = False
self._clientSupportsTLS = False
def retry(retries):
self._lastGlobalUpdate = None

View File

@ -313,7 +313,7 @@ de = {
# startTLS messages - TODO: Translate
"startTLS-initiated": "Attempting secure connection",
"startTLS-secure-connection-ok": "Secure connection established ({})",
"startTLS-not-supported-client": "TLS is not supported",
"startTLS-not-supported-client": "This client does not support TLS",
"startTLS-not-supported-server": "This server does not support TLS",
# About dialog - TODO: Translate

View File

@ -314,7 +314,7 @@ en = {
"startTLS-initiated": "Attempting secure connection",
"startTLS-secure-connection-ok": "Secure connection established ({})",
"startTLS-not-supported-client": "TLS is not supported",
"startTLS-not-supported-client": "This client does not support TLS",
"startTLS-not-supported-server": "This server does not support TLS",
# About dialog

View File

@ -314,7 +314,7 @@ it = {
"startTLS-initiated": "Tentativo di connessione sicura in corso",
"startTLS-secure-connection-ok": "Connessione sicura stabilita ({})",
"startTLS-not-supported-client": "TLS non è supportato",
"startTLS-not-supported-client": "Questo client non supporta TLS",
"startTLS-not-supported-server": "Questo server non supporta TLS",
# About dialog

View File

@ -316,7 +316,7 @@ ru = {
# startTLS messages - TODO: Translate
"startTLS-initiated": "Attempting secure connection",
"startTLS-secure-connection-ok": "Secure connection established ({})",
"startTLS-not-supported-client": "TLS is not supported",
"startTLS-not-supported-client": "This client does not support TLS",
"startTLS-not-supported-server": "This server does not support TLS",
# About dialog - TODO: Translate

View File

@ -77,11 +77,15 @@ class SyncClientProtocol(JSONCommandProtocol):
def connectionMade(self):
self._client.initProtocol(self)
if self._client._serverSupportsTLS:
self.sendTLS({"startTLS": "send"})
self._client.ui.showMessage(getMessage("startTLS-initiated"))
if self._client._clientSupportsTLS:
if self._client._serverSupportsTLS:
self.sendTLS({"startTLS": "send"})
self._client.ui.showMessage(getMessage("startTLS-initiated"))
else:
self._client.ui.showErrorMessage(getMessage("startTLS-not-supported-server"))
self.sendHello()
else:
self._client.ui.showErrorMessage(getMessage("startTLS-not-supported-client"))
self._client.ui.showMessage(getMessage("startTLS-not-supported-client"))
self.sendHello()
def connectionLost(self, reason):