* do not reinsert blocks

* warn mail about bad sigs
master
Kevin Froman 2018-08-17 23:42:30 -05:00
parent cfbc834eb5
commit 9655bfd872
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
3 changed files with 23 additions and 15 deletions

View File

@ -624,6 +624,18 @@ class Core:
''' '''
retData = False retData = False
# check nonce
dataNonce = self._utils.bytesToStr(self._crypto.sha3Hash(data))
try:
with open(self.dataNonceFile, 'r') as nonces:
if dataNonce in nonces:
return retData
except FileNotFoundError:
pass
# record nonce
with open(self.dataNonceFile, 'a') as nonceFile:
nonceFile.write(dataNonce + '\n')
if meta is None: if meta is None:
meta = dict() meta = dict()
@ -683,13 +695,7 @@ class Core:
metadata['sig'] = signature metadata['sig'] = signature
metadata['signer'] = signer metadata['signer'] = signer
metadata['time'] = str(self._utils.getEpoch()) metadata['time'] = str(self._utils.getEpoch())
nonce = self._utils.bytesToStr(self._crypto.sha3Hash(data))
# TODO check in advance
with open(self.dataNonceFile, 'a') as nonceFile:
nonceFile.write(nonce + '\n')
# send block data (and metadata) to POW module to get tokenized block data # send block data (and metadata) to POW module to get tokenized block data
proof = onionrproofs.POW(metadata, data) proof = onionrproofs.POW(metadata, data)
payload = proof.waitForResult() payload = proof.waitForResult()

View File

@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
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 core, config, logger import core, config, logger, sqlite3
class PeerProfiles: class PeerProfiles:
''' '''
PeerProfiles PeerProfiles
@ -89,7 +89,10 @@ def peerCleanup(coreInst):
# Remove peers that go below the negative score # Remove peers that go below the negative score
if PeerProfiles(address, coreInst).score < minScore: if PeerProfiles(address, coreInst).score < minScore:
coreInst.removeAddress(address) coreInst.removeAddress(address)
coreInst._blacklist.addToDB(address, dataType=1, expire=300) try:
coreInst._blacklist.addToDB(address, dataType=1, expire=300)
except sqlite3.IntegrityError: #TODO just make sure its not a unique constraint issue
pass
logger.warn('Removed address ' + address + '.') logger.warn('Removed address ' + address + '.')
# Unban probably not malicious peers TODO improve # Unban probably not malicious peers TODO improve

View File

@ -109,14 +109,13 @@ class OnionrMail:
pass pass
else: else:
readBlock.verifySig() readBlock.verifySig()
print('Message recieved from', readBlock.signer) print('Message recieved from %s' % (readBlock.signer,))
print('Valid signature:', readBlock.validSig) print('Valid signature:', readBlock.validSig)
if not readBlock.validSig: if not readBlock.validSig:
logger.warn('This message has an INVALID signature. Anyone could have sent this message.') logger.warn('This message has an INVALID signature. ANYONE could have sent this message.')
logger.readline('Press enter to continue to message.') cancel = logger.readline('Press enter to continue to message, or -q to not open the message (recommended).')
if cancel != '-q':
print(draw_border(self.myCore._utils.escapeAnsi(readBlock.bcontent.decode().strip()))) print(draw_border(self.myCore._utils.escapeAnsi(readBlock.bcontent.decode().strip())))
return return
def draftMessage(self): def draftMessage(self):