From 466e8533d625d22d37b2da43faa0df55764d41cf Mon Sep 17 00:00:00 2001 From: Etoh Date: Thu, 14 Feb 2019 23:03:53 +0000 Subject: [PATCH] Add secure connection icon to press for cert details --- buildPy2exe.py | 1 + resources/green_lock.png | Bin 0 -> 791 bytes syncplay/__init__.py | 2 +- syncplay/client.py | 5 +++++ syncplay/messages_de.py | 5 +++++ syncplay/messages_en.py | 7 ++++++- syncplay/messages_it.py | 7 ++++++- syncplay/messages_ru.py | 7 ++++++- syncplay/protocols.py | 7 ++++++- syncplay/ui/consoleUI.py | 3 +++ syncplay/ui/gui.py | 35 ++++++++++++++++++++++++++++++++--- 11 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 resources/green_lock.png diff --git a/buildPy2exe.py b/buildPy2exe.py index 0dfe4af..975484f 100644 --- a/buildPy2exe.py +++ b/buildPy2exe.py @@ -658,6 +658,7 @@ guiIcons = [ 'resources/mpv.png', 'resources/vlc.png', 'resources/house.png', 'resources/film_link.png', 'resources/eye.png', 'resources/comments.png', 'resources/cog_delete.png', 'resources/chevrons_right.png', 'resources/user_key.png', 'resources/lock.png', 'resources/key_go.png', 'resources/page_white_key.png', + 'resources/green_lock.png', 'resources/tick.png', 'resources/lock_open.png', 'resources/empty_checkbox.png', 'resources/tick_checkbox.png', 'resources/world_explore.png', 'resources/application_get.png', 'resources/cog.png', 'resources/arrow_switch.png', 'resources/film_go.png', 'resources/world_go.png', 'resources/arrow_refresh.png', 'resources/bullet_right_grey.png', diff --git a/resources/green_lock.png b/resources/green_lock.png new file mode 100644 index 0000000000000000000000000000000000000000..61197400c24ecc9bb8cf268cb243eeeef4d1ac45 GIT binary patch literal 791 zcmV+y1L*vTP)N2bZe?^J zG%hhNHDpIvQUCw~l}SWFR5(v%QtL~TaTGpO)+D1Sx)XLUE6C_VMECksbiXHRSx`iM zh|)5cu`!s_;nc}CryIKo8*8he0_WUv&RJ{HA0YXyzvJoo`BJ{-hr@Z__nh-Q&w0)( z0OrKNz(7Sf95w|4ft1hZD|x-%lH2W0_4M?ZIy*Zn^u4nNRYW3@>QE>&l}@KoEEZ8J zm8NqpmqQ|vfZcANve|6afBXL*t_TK$llgoenM?+JhRfxG)9C~iAel@~hs9!d2kTYZ~*dn59IBt8FUHmf_%TtxC1HG zGU_13ddNhB7C-Jm#_vM%Hz2udTD)1I1Mrhk0SxYkWT+&23Nm~aGIpLr=OF1bkPocI zcJN2p0vWkVrOR{xeJqUMf_&Kr>DvzJ=So=u*j7VYH$jF@Xlt~tg@l;DUV%Jcq62Vq zR|W8CFPjgsfdeCCwQ$cD^kV23nz3Aq%m#je!LgMSH%nF_RsoTCH%gd#j%g<=klXA$TMVjOWvewUs)N;5+@CT>x VKThU?(8>S+002ovPDHLkV1l4xWRU;> literal 0 HcmV?d00001 diff --git a/syncplay/__init__.py b/syncplay/__init__.py index 7eefcf6..3932bf1 100755 --- a/syncplay/__init__.py +++ b/syncplay/__init__.py @@ -1,5 +1,5 @@ version = '1.6.3' revision = ' beta' milestone = 'Yoitsu' -release_number = '72' +release_number = '73' projectURL = 'https://syncplay.pl/' diff --git a/syncplay/client.py b/syncplay/client.py index 4d91049..33a1d90 100755 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -398,6 +398,7 @@ class SyncplayClient(object): self.ui.showMessage(getMessage("current-offset-notification").format(self._userOffset)) def onDisconnect(self): + self.ui.setSSLMode(False) if self._config['pauseOnLeave']: self.setPaused(True) self.lastPausedOnLeaveTime = time.time() @@ -727,6 +728,7 @@ class SyncplayClient(object): def retry(retries): self._lastGlobalUpdate = None + self.ui.setSSLMode(False) if retries == 0: self.onDisconnect() if retries > constants.RECONNECT_RETRIES: @@ -1476,6 +1478,9 @@ class UiManager(object): self.showOSDMessage(messageString, duration=constants.OSD_DURATION) self.__ui.showMessage(messageString) + def setSSLMode(self, sslMode, sslInformation=""): + self.__ui.setSSLMode(sslMode, sslInformation) + def showMessage(self, message, noPlayer=False, noTimestamp=False, OSDType=constants.OSD_NOTIFICATION, mood=constants.MESSAGE_NEUTRAL): if not noPlayer: self.showOSDMessage(message, duration=constants.OSD_DURATION, OSDType=OSDType, mood=mood) diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index 1c2e149..78e2f68 100755 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -71,6 +71,9 @@ de = { "syncplay-uptodate-notification": "Syncplay ist aktuell", "syncplay-updateavailable-notification": "Eine neuere Version von Syncplay ist verfügbar. Soll die Download-Seite geöffnet werden?", + "ssl-information-title": "SSL Certificate Details", # TODO: Translate + "ssl-information-message": "Subject: {}\nIssuer: {}\nExpiration Date: {}\nConnection Version: {}\nCipher: {}", # TODO: Translate + "mplayer-file-required-notification": "Syncplay für mplayer benötigt eine Dateiangabe beim Start", "mplayer-file-required-notification/example": "Anwendungsbeispiel: syncplay [optionen] [url|pfad/]Dateiname", "mplayer2-required": "Syncplay ist inkompatibel zu MPlayer 1.x, bitte nutze MPlayer2 oder mpv", @@ -410,6 +413,8 @@ de = { "reset-tooltip": "Alle Einstellungen auf Standardwerte zurücksetzen.", "update-server-list-tooltip": "Mit syncplay.pl verbinden um die Liste öffentlicher Server zu aktualisieren.", + "sslconnection-tooltip": "Securely connected to server. Press button for certificate details", # TODO: Translate + "joinroom-tooltip": "Den aktuellen Raum verlassen und stattdessen den angegebenen betreten.", "seektime-msgbox-label": "Springe zur angegebenen Zeit (in Sekunden oder min:sek). Verwende +/- zum relativen Springen.", "ready-tooltip": "Zeigt an, ob du bereit zum anschauen bist", diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index eb7a71c..b7bc8d4 100755 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -71,6 +71,9 @@ en = { "syncplay-uptodate-notification": "Syncplay is up to date", "syncplay-updateavailable-notification": "A new version of Syncplay is available. Do you want to visit the release page?", + "ssl-information-title": "SSL Certificate Details", + "ssl-information-message": "Subject: {}\nIssuer: {}\nExpiration Date: {}\nConnection Version: {}\nCipher: {}", + "mplayer-file-required-notification": "Syncplay using mplayer requires you to provide file when starting", "mplayer-file-required-notification/example": "Usage example: syncplay [options] [url|path/]filename", "mplayer2-required": "Syncplay is incompatible with MPlayer 1.x, please use mplayer2 or mpv", @@ -267,7 +270,7 @@ en = { "run-label": "Run Syncplay", "storeandrun-label": "Store configuration and run Syncplay", - "contact-label": "Feel free to e-mail dev@syncplay.pl, chat via the #Syncplay IRC channel on irc.freenode.net, raise an issue via GitHub, like us on Facebook, follow us on Twitter, or visit https://syncplay.pl/. NOTE: Chat messages are not encrypted so do not use Syncplay to send sensitive information.", + "contact-label": "Feel free to e-mail dev@syncplay.pl, chat via the #Syncplay IRC channel on irc.freenode.net, raise an issue via GitHub, like us on Facebook, follow us on Twitter, or visit https://syncplay.pl/. Do not use Syncplay to send sensitive information.", "joinroom-label": "Join room", "joinroom-menu-label": "Join room {}", @@ -409,6 +412,8 @@ en = { "reset-tooltip": "Reset all settings to the default configuration.", "update-server-list-tooltip": "Connect to syncplay.pl to update list of public servers.", + "sslconnection-tooltip": "Securely connected to server. Press button for certificate details", + "joinroom-tooltip": "Leave current room and joins specified room.", "seektime-msgbox-label": "Jump to specified time (in seconds / min:sec). Use +/- for relative seek.", "ready-tooltip": "Indicates whether you are ready to watch.", diff --git a/syncplay/messages_it.py b/syncplay/messages_it.py index 6415810..d94db60 100755 --- a/syncplay/messages_it.py +++ b/syncplay/messages_it.py @@ -71,6 +71,9 @@ it = { "syncplay-uptodate-notification": "Syncplay è aggiornato", "syncplay-updateavailable-notification": "Una nuova versione di Syncplay è disponibile. Vuoi visitare la pagina delle release?", + "ssl-information-title": "SSL Certificate Details", # TODO: Translate + "ssl-information-message": "Subject: {}\nIssuer: {}\nExpiration Date: {}\nConnection Version: {}\nCipher: {}", # TODO: Translate + "mplayer-file-required-notification": "Utilizzare Syncplay con mplayer di selezionare il file all'avvio", "mplayer-file-required-notification/example": "Esempio di utilizzo: syncplay [opzioni] [url|percorso/]nomefile", "mplayer2-required": "Syncplay non è compatibile con MPlayer 1.x, per favore utilizza mplayer2 or mpv", @@ -267,7 +270,7 @@ it = { "run-label": "Avvia Syncplay", "storeandrun-label": "Salva la configurazione e avvia Syncplay", - "contact-label": "Sentiti libero di inviare un'e-mail a dev@syncplay.pl, chattare tramite il canale IRC #Syncplay su irc.freenode.net, segnalare un problema su GitHub, lasciare un like sulla nostra pagina Facebook, seguirci su Twitter, o visitare https://syncplay.pl/. NOTA: i messaggi di chat non sono cifrati, quindi non usare Syncplay per inviare dati sensibili.", + "contact-label": "Sentiti libero di inviare un'e-mail a dev@syncplay.pl, chattare tramite il canale IRC #Syncplay su irc.freenode.net, segnalare un problema su GitHub, lasciare un like sulla nostra pagina Facebook, seguirci su Twitter, o visitare https://syncplay.pl/. Non usare Syncplay per inviare dati sensibili.", # TODO: Check translation "joinroom-label": "Entra nella stanza", "joinroom-menu-label": "Entra nella stanza {}", @@ -409,6 +412,8 @@ it = { "reset-tooltip": "Ripristina le impostazioni iniziali di Syncplay.", "update-server-list-tooltip": "Scarica la lista dei server pubblici da syncplay.pl.", + "sslconnection-tooltip": "Securely connected to server. Press button for certificate details", # TODO: Translate + "joinroom-tooltip": "Lascia la stanza attuale e entra in quella specificata.", "seektime-msgbox-label": "Salta all'istante di tempo specificato (in secondi / min:sec). Usa +/- per una ricerca relativa.", "ready-tooltip": "Indica quando sei pronto a guardare.", diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index 038daa1..4ab13bf 100755 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -71,6 +71,9 @@ ru = { "syncplay-uptodate-notification": "У вас последняя версия Syncplay", "syncplay-updateavailable-notification": "Доступна новая версия Syncplay. Хотите открыть страницу релиза?", + "ssl-information-title": "SSL Certificate Details", # TODO: Translate + "ssl-information-message": "Subject: {}\nIssuer: {}\nExpiration Date: {}\nConnection Version: {}\nCipher: {}", # TODO: Translate + "mplayer-file-required-notification": "Для использования Syncplay с mplayer необходимо передать файл в качестве параметра", "mplayer-file-required-notification/example": "Пример использования: syncplay [options] [url|path/]filename", "mplayer2-required": "Syncplay не совместим с MPlayer 1.x, пожалуйста, используйте mplayer2 или mpv", @@ -269,7 +272,7 @@ ru = { "run-label": "Запустить", "storeandrun-label": "Сохранить и запустить", - "contact-label": "Есть идея, нашли ошибку или хотите оставить отзыв? Пишите на dev@syncplay.pl, в IRC канал #Syncplay на irc.freenode.net или задавайте вопросы через GitHub. Кроме того, заходите на www.syncplay.pl за инорфмацией, помощью и обновлениями! NOTE: Chat messages are not encrypted so do not use Syncplay to send sensitive information.", # TODO: Translate last sentence + "contact-label": "Есть идея, нашли ошибку или хотите оставить отзыв? Пишите на dev@syncplay.pl, в IRC канал #Syncplay на irc.freenode.net или задавайте вопросы через GitHub. Кроме того, заходите на www.syncplay.pl за инорфмацией, помощью и обновлениями! Do not use Syncplay to send sensitive information.", # TODO: Translate last sentence "joinroom-label": "Зайти в комнату", "joinroom-menu-label": "Зайти в комнату {}", @@ -411,6 +414,8 @@ ru = { "reset-tooltip": "Сбрасывает все настройки Syncplay в начальное состояние.", "update-server-list-tooltip": "Обновить список публичных серверов от syncplay.pl.", + "sslconnection-tooltip": "Securely connected to server. Press button for certificate details", # TODO: Translate + "joinroom-tooltip": "Покинуть комнату и зайти в другую, указанную комнату.", "seektime-msgbox-label": "Перемотать к определенному моменту времени (указывать в секундах или мин:сек). Используйте +/-, чтобы перемотать вперед/назад относительно настоящего момента.", "ready-tooltip": "Показывает, готовы ли Вы к просмотру или нет.", diff --git a/syncplay/protocols.py b/syncplay/protocols.py index b1dbef2..0d75de0 100755 --- a/syncplay/protocols.py +++ b/syncplay/protocols.py @@ -339,17 +339,22 @@ class SyncClientProtocol(JSONCommandProtocol): 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 self._expiredTLS =self._serverCertificateTLS.has_expired() - self._expireDateTLS = self._serverCertificateTLS.get_notAfter() + self._expireDateTLS = datetime.strptime(self._serverCertificateTLS.get_notAfter().decode('ascii'), '%Y%m%d%H%M%SZ') self._encryptedConnectionTLS = self.transport.protocol._tlsConnection self._connVersionTLS = self._encryptedConnectionTLS.get_protocol_version_name() self._cipherNameTLS = self._encryptedConnectionTLS.get_cipher_name() self._client.ui.showMessage(getMessage("startTLS-secure-connection-ok").format(self._connVersionTLS)) + self._client.ui.setSSLMode( + True, + getMessage("ssl-information-message") + .format(self._subjectTLS,self._issuerTLS, self._expireDateTLS, self._connVersionTLS, self._cipherNameTLS)) class SyncServerProtocol(JSONCommandProtocol): diff --git a/syncplay/ui/consoleUI.py b/syncplay/ui/consoleUI.py index 38f10ff..3063ff3 100755 --- a/syncplay/ui/consoleUI.py +++ b/syncplay/ui/consoleUI.py @@ -108,6 +108,9 @@ class ConsoleUI(threading.Thread): def showErrorMessage(self, message, criticalerror=False): print("ERROR:\t" + message) + def setSSLMode(self, sslMode, sslInformation): + pass + def _extractSign(self, m): if m: if m == "-": diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index cfaf161..814fcd9 100755 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -120,6 +120,7 @@ class AboutDialog(QtWidgets.QDialog): self.setWindowTitle(getMessage("about-dialog-title")) if isWindows(): self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) + self.setWindowIcon(QtGui.QPixmap(resourcespath + 'syncplay.png')) nameLabel = QtWidgets.QLabel("
Syncplay
") nameLabel.setFont(QtGui.QFont("Helvetica", 18)) linkLabel = QtWidgets.QLabel("
syncplay.pl
") @@ -172,6 +173,8 @@ class MainWindow(QtWidgets.QMainWindow): playlistState = [] updatingPlaylist = False playlistIndex = None + sslInformation = "N/A" + sslMode = False def setPlaylistInsertPosition(self, newPosition): if not self.playlist.isEnabled(): @@ -427,6 +430,14 @@ class MainWindow(QtWidgets.QMainWindow): self.chatInput.setMaxLength(constants.MAX_CHAT_MESSAGE_LENGTH) self.roomInput.setMaxLength(constants.MAX_ROOM_NAME_LENGTH) + def setSSLMode(self, sslMode, sslInformation): + self.sslMode = sslMode + self.sslInformation = sslInformation + self.sslButton.setVisible(sslMode) + + def getSSLInformation(self): + return self.sslInformation + def showMessage(self, message, noTimestamp=False): message = str(message) username = None @@ -1201,6 +1212,7 @@ class MainWindow(QtWidgets.QMainWindow): window.outputbox.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) window.outputlabel = QtWidgets.QLabel(getMessage("notifications-heading-label")) + window.outputlabel.setMinimumHeight(27) window.chatInput = QtWidgets.QLineEdit() window.chatInput.setMaxLength(constants.MAX_CHAT_MESSAGE_LENGTH) window.chatInput.returnPressed.connect(self.sendChatMessage) @@ -1237,21 +1249,29 @@ class MainWindow(QtWidgets.QMainWindow): self.listTreeView.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.listTreeView.customContextMenuRequested.connect(self.openRoomMenu) window.listlabel = QtWidgets.QLabel(getMessage("userlist-heading-label")) + window.listlabel.setMinimumHeight(27) + window.sslButton = QtWidgets.QPushButton(QtGui.QPixmap(resourcespath + 'green_lock.png'),"") + window.sslButton.setVisible(False) + window.sslButton.setFixedHeight(27) + window.sslButton.setFixedWidth(27) + window.sslButton.pressed.connect(self.openSSLDetails) + window.sslButton.setToolTip(getMessage("sslconnection-tooltip")) window.listFrame = QtWidgets.QFrame() window.listFrame.setLineWidth(0) window.listFrame.setMidLineWidth(0) window.listFrame.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) window.listLayout.setContentsMargins(0, 0, 0, 0) - window.userlistLayout = QtWidgets.QVBoxLayout() + window.userlistLayout = QtWidgets.QGridLayout() window.userlistFrame = QtWidgets.QFrame() window.userlistFrame.setLineWidth(0) window.userlistFrame.setMidLineWidth(0) window.userlistFrame.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) window.userlistLayout.setContentsMargins(0, 0, 0, 0) window.userlistFrame.setLayout(window.userlistLayout) - window.userlistLayout.addWidget(window.listlabel) - window.userlistLayout.addWidget(window.listTreeView) + window.userlistLayout.addWidget(window.listlabel, 0, 0, Qt.AlignLeft) + window.userlistLayout.addWidget(window.sslButton, 0, 2, Qt.AlignRight) + window.userlistLayout.addWidget(window.listTreeView, 1, 0, 1, 3) window.listSplit = QtWidgets.QSplitter(Qt.Vertical, self) window.listSplit.addWidget(window.userlistFrame) @@ -1510,6 +1530,15 @@ class MainWindow(QtWidgets.QMainWindow): if not isMacOS(): window.mainLayout.setMenuBar(window.menuBar) + @needsClient + def openSSLDetails(self): + QtWidgets.QMessageBox.information( + self, + getMessage("ssl-information-title"), + "[{}]\n{}".format(getMessage("ssl-information-title"),self.getSSLInformation()) + ) + + def openAbout(self): aboutMsgBox = AboutDialog() aboutMsgBox.exec_()