Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log connections dropped due to a security error #175

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pysyncobj/tcp_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import socket
import zlib
import struct
import logging

import pysyncobj.pickle as pickle
import pysyncobj.win_inet_pton
Expand Down Expand Up @@ -235,16 +236,18 @@ def __processParseMessage(self):
try:
if self.encryptor:
dataTimestamp = self.encryptor.extract_timestamp(data)
assert dataTimestamp >= self.recvLastTimestamp
assert dataTimestamp >= self.recvLastTimestamp, "Replay - timestamp"
self.recvLastTimestamp = dataTimestamp
# Unfortunately we can't get a timestamp and data in one go
data = self.encryptor.decrypt(data)
message = pickle.loads(zlib.decompress(data))
if self.recvRandKey:
randKey, message = message
assert randKey == self.recvRandKey
except:
# Why no logging of security errors?
assert randKey == self.recvRandKey, "Replay - recvRandKey"
except Exception as e:
try: peername = self.__socket.getpeername()[0]
Sandwichs-del marked this conversation as resolved.
Show resolved Hide resolved
except Exception as e2: peername = "(%s)" % repr(e2)
logging.info('Invalid message from %s, connection closing due to %s.' % (peername, repr(e)))
self.disconnect()
return None
self.__readBuffer = self.__readBuffer[4 + l:]
Expand Down