bug fixes
This commit is contained in:
parent
4757bb0963
commit
7f84cd0598
@ -18,7 +18,7 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import sys
|
import sys, getpass
|
||||||
import logger
|
import logger
|
||||||
from onionrusers import onionrusers
|
from onionrusers import onionrusers
|
||||||
def add_ID(o_inst):
|
def add_ID(o_inst):
|
||||||
|
@ -33,7 +33,7 @@ def deleteExpiredKeys(coreInst):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def deleteTheirExpiredKeys(coreInst, pubkey):
|
def deleteTheirExpiredKeys(coreInst, pubkey):
|
||||||
conn = sqlite3.connect(self._core.peerDB, timeout=10)
|
conn = sqlite3.connect(coreInst.peerDB, timeout=10)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
|
||||||
# Prepare the insert
|
# Prepare the insert
|
||||||
@ -44,8 +44,8 @@ def deleteTheirExpiredKeys(coreInst, pubkey):
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
DEFAULT_KEY_EXPIRE = 604800
|
#DEFAULT_KEY_EXPIRE = 604800
|
||||||
#DEFAULT_KEY_EXPIRE = 600
|
DEFAULT_KEY_EXPIRE = 600
|
||||||
|
|
||||||
class OnionrUser:
|
class OnionrUser:
|
||||||
def __init__(self, coreInst, publicKey, saveUser=False):
|
def __init__(self, coreInst, publicKey, saveUser=False):
|
||||||
@ -99,6 +99,7 @@ class OnionrUser:
|
|||||||
return decrypted
|
return decrypted
|
||||||
|
|
||||||
def forwardEncrypt(self, data):
|
def forwardEncrypt(self, data):
|
||||||
|
deleteTheirExpiredKeys(self._core, self.publicKey)
|
||||||
deleteExpiredKeys(self._core)
|
deleteExpiredKeys(self._core)
|
||||||
retData = ''
|
retData = ''
|
||||||
forwardKey = self._getLatestForwardKey()
|
forwardKey = self._getLatestForwardKey()
|
||||||
@ -129,7 +130,7 @@ class OnionrUser:
|
|||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
|
||||||
# TODO: account for keys created at the same time (same epoch)
|
# TODO: account for keys created at the same time (same epoch)
|
||||||
for row in c.execute("SELECT forwardKey, max(DATE) FROM forwardKeys WHERE peerKey = ?", (self.publicKey,)):
|
for row in c.execute("SELECT forwardKey, max(EXPIRE) FROM forwardKeys WHERE peerKey = ? ORDER BY expire DESC", (self.publicKey,)):
|
||||||
key = (row[0], row[1])
|
key = (row[0], row[1])
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -143,7 +144,7 @@ class OnionrUser:
|
|||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
keyList = []
|
keyList = []
|
||||||
|
|
||||||
for row in c.execute("SELECT forwardKey, date FROM forwardKeys WHERE peerKey = ? ORDER BY date DESC", (self.publicKey,)):
|
for row in c.execute("SELECT forwardKey, date FROM forwardKeys WHERE peerKey = ? ORDER BY expire DESC", (self.publicKey,)):
|
||||||
keyList.append((row[0], row[1]))
|
keyList.append((row[0], row[1]))
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
@ -281,9 +281,9 @@ class OnionrUtils:
|
|||||||
break
|
break
|
||||||
elif i == 'expire':
|
elif i == 'expire':
|
||||||
try:
|
try:
|
||||||
assert int(metadata[i]) < self.getEpoch()
|
assert int(metadata[i]) > self.getEpoch()
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
logger.warn('Block is expired')
|
logger.warn('Block is expired: %s greater than %s' % (metadata[i], self.getEpoch()))
|
||||||
break
|
break
|
||||||
elif i == 'encryptType':
|
elif i == 'encryptType':
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user