Finish timeOffsetWrongCount

- now notifies in status bar
- fixes #1433
This commit is contained in:
Peter Šurda 2020-08-31 11:25:53 +02:00
parent 39d28b9b0f
commit 95fc981ae2
Signed by: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -2,6 +2,7 @@
TCP protocol handler TCP protocol handler
""" """
# pylint: disable=too-many-ancestors # pylint: disable=too-many-ancestors
import l10n
import logging import logging
import math import math
import random import random
@ -29,11 +30,13 @@ from network.socks5 import Socks5Connection
from network.tls import TLSDispatcher from network.tls import TLSDispatcher
from node import Peer from node import Peer
from queues import invQueue, receiveDataQueue, UISignalQueue from queues import invQueue, receiveDataQueue, UISignalQueue
from tr import _translate
logger = logging.getLogger('default') logger = logging.getLogger('default')
maximumAgeOfNodesThatIAdvertiseToOthers = 10800 #: Equals three hours maximumAgeOfNodesThatIAdvertiseToOthers = 10800 #: Equals three hours
maximumTimeOffsetWrongCount = 3 #: Connections with wrong time offset
class TCPConnection(BMProto, TLSDispatcher): class TCPConnection(BMProto, TLSDispatcher):
@ -124,6 +127,22 @@ class TCPConnection(BMProto, TLSDispatcher):
' for %.2fs', delay) ' for %.2fs', delay)
self.skipUntil = time.time() + delay self.skipUntil = time.time() + delay
def checkTimeOffsetNotification(self):
"""
Check if we have connected to too many nodes which have too high
time offset from us
"""
if BMProto.timeOffsetWrongCount > \
maximumTimeOffsetWrongCount and \
not self.fullyEstablished:
UISignalQueue.put((
'updateStatusBar',
_translate(
"MainWindow",
"The time on your computer, %1, may be wrong. "
"Please verify your settings."
).arg(l10n.formatTimestamp())))
def state_connection_fully_established(self): def state_connection_fully_established(self):
""" """
State after the bitmessage protocol handshake is completed State after the bitmessage protocol handshake is completed
@ -275,8 +294,10 @@ class TCPConnection(BMProto, TLSDispatcher):
knownnodes.addKnownNode( knownnodes.addKnownNode(
self.streams, self.destination, time.time()) self.streams, self.destination, time.time())
Dandelion().maybeRemoveStem(self) Dandelion().maybeRemoveStem(self)
elif host_is_global: else:
knownnodes.decreaseRating(self.destination) self.checkTimeOffsetNotification()
if host_is_global:
knownnodes.decreaseRating(self.destination)
BMProto.handle_close(self) BMProto.handle_close(self)