From 609a4a92e29a09cee9b026eb4d135fec78de3703 Mon Sep 17 00:00:00 2001 From: f97ada87 <32196103+f97ada87@users.noreply.github.com> Date: Wed, 23 May 2018 03:38:05 +0000 Subject: [PATCH] enable delayed POW checks enable delayed POW checks via optional "receive time" argument --- src/protocol.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/protocol.py b/src/protocol.py index dca4c942..6869903c 100644 --- a/src/protocol.py +++ b/src/protocol.py @@ -168,13 +168,14 @@ def checkSocksIP(host): def isProofOfWorkSufficient(data, nonceTrialsPerByte=0, - payloadLengthExtraBytes=0): + payloadLengthExtraBytes=0, + recvTime=0): if nonceTrialsPerByte < defaults.networkDefaultProofOfWorkNonceTrialsPerByte: nonceTrialsPerByte = defaults.networkDefaultProofOfWorkNonceTrialsPerByte if payloadLengthExtraBytes < defaults.networkDefaultPayloadLengthExtraBytes: payloadLengthExtraBytes = defaults.networkDefaultPayloadLengthExtraBytes endOfLifeTime, = unpack('>Q', data[8:16]) - TTL = endOfLifeTime - int(time.time()) + TTL = endOfLifeTime - (recvTime if recvTime else int(time.time())) if TTL < 300: TTL = 300 POW, = unpack('>Q', hashlib.sha512(hashlib.sha512(data[