From f8ea2381a6e1dbc2cfca63290e5e1ac0cf9177db Mon Sep 17 00:00:00 2001 From: Alberto Sottile Date: Sun, 24 Feb 2019 16:18:47 +0100 Subject: [PATCH] sendHello only after a successful startTLS handshake, if one is attempted --- syncplay/client.py | 2 +- syncplay/messages_de.py | 2 +- syncplay/messages_en.py | 2 +- syncplay/messages_it.py | 2 +- syncplay/messages_ru.py | 2 +- syncplay/protocols.py | 6 ++++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/syncplay/client.py b/syncplay/client.py index c284e45..2ea0ca3 100755 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -757,7 +757,7 @@ class SyncplayClient(object): def connectedNow(f): hostIP = connectionHandle.result.transport.addr[0] - self.ui.showMessage(getMessage("handshake-successful-notification").format(host, hostIP)) + self.ui.showMessage(getMessage("reachout-successful-notification").format(host, hostIP)) return def failed(f): diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index 999bf35..c2ef7cf 100755 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -16,7 +16,7 @@ de = { "connection-failed-notification": "Verbindung zum Server fehlgeschlagen", "connected-successful-notification": "Erfolgreich mit Server verbunden", "retrying-notification": "%s, versuche erneut in %d Sekunden...", # Seconds - "handshake-successful-notification": "Connection established with {} ({})", # TODO: Translate + "reachout-successful-notification": "Successfully reached {} ({})", # TODO: Translate "rewind-notification": "Zurückgespult wegen Zeitdifferenz mit {}", # User "fastforward-notification": "Vorgespult wegen Zeitdifferenz mit {}", # User diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index 9474452..c135fc1 100755 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -16,7 +16,7 @@ en = { "connection-failed-notification": "Connection with server failed", "connected-successful-notification": "Successfully connected to server", "retrying-notification": "%s, Retrying in %d seconds...", # Seconds - "handshake-successful-notification": "Connection established with {} ({})", + "reachout-successful-notification": "Successfully reached {} ({})", "rewind-notification": "Rewinded due to time difference with {}", # User "fastforward-notification": "Fast-forwarded due to time difference with {}", # User diff --git a/syncplay/messages_it.py b/syncplay/messages_it.py index 2153a38..c6098f2 100755 --- a/syncplay/messages_it.py +++ b/syncplay/messages_it.py @@ -16,7 +16,7 @@ it = { "connection-failed-notification": "Connessione col server fallita", "connected-successful-notification": "Connessione al server effettuata con successo", "retrying-notification": "%s, Nuovo tentativo in %d secondi...", # Seconds - "handshake-successful-notification": "Connessione stabilita con {} ({})", + "reachout-successful-notification": "Collegamento stabilito con {} ({})", "rewind-notification": "Riavvolgo a causa della differenza temporale con {}", # User "fastforward-notification": "Avanzamento rapido a causa della differenza temporale con {}", # User diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index 7452db0..62d1517 100755 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -16,7 +16,7 @@ ru = { "connection-failed-notification": "Не удалось подключиться к серверу", "connected-successful-notification": "Соединение с сервером установлено", "retrying-notification": "%s, следующая попытка через %d секунд(ы)...", # Seconds - "handshake-successful-notification": "Connection established with {} ({})", # TODO: Translate + "reachout-successful-notification": "Successfully reached {} ({})", # TODO: Translate "rewind-notification": "Перемотано из-за разницы во времени с {}", # User "fastforward-notification": "Ускорено из-за разницы во времени с {}", # User diff --git a/syncplay/protocols.py b/syncplay/protocols.py index 7607fad..7e8305e 100755 --- a/syncplay/protocols.py +++ b/syncplay/protocols.py @@ -1,6 +1,7 @@ # coding:utf8 import json import time +from datetime import datetime from functools import wraps from twisted.protocols.basic import LineReceiver @@ -336,10 +337,9 @@ class SyncClientProtocol(JSONCommandProtocol): self.transport.startTLS(self._client.protocolFactory.options) elif "false" in answer: self._client.ui.showErrorMessage(getMessage("startTLS-not-supported-server")) - self.sendHello() + self.sendHello() def handshakeCompleted(self): - from datetime import datetime self._serverCertificateTLS = self.transport.getPeerCertificate() self._subjectTLS = self._serverCertificateTLS.get_subject().CN self._issuerTLS = self._serverCertificateTLS.get_issuer().CN @@ -362,6 +362,8 @@ class SyncClientProtocol(JSONCommandProtocol): 'protocolString': self._connVersionStringTLS, 'protocolVersion': self._connVersionNumberTLS, 'cipher': self._cipherNameTLS}) + self.sendHello() + class SyncServerProtocol(JSONCommandProtocol): def __init__(self, factory):