added soft-reset command, fixed broken nonce cache, work on chat
parent
cc66c3a896
commit
1f757679d9
2
Makefile
2
Makefile
|
@ -25,7 +25,7 @@ test:
|
|||
|
||||
soft-reset:
|
||||
@echo "Soft-resetting Onionr..."
|
||||
rm -f onionr/$(ONIONR_HOME)/blocks/*.dat onionr/data/*.db onionr/$(ONIONR_HOME)/block-nonces.dat | true > /dev/null 2>&1
|
||||
./onionr.sh soft-reset
|
||||
@./onionr.sh version | grep -v "Failed" --color=always
|
||||
|
||||
reset:
|
||||
|
|
|
@ -106,9 +106,9 @@ class OnionrCommunicatorDaemon:
|
|||
OnionrCommunicatorTimers(self, self.runCheck, 2, maxThreads=1)
|
||||
|
||||
# Timers to periodically lookup new blocks and download them
|
||||
OnionrCommunicatorTimers(self, lookupblocks.lookup_blocks_from_communicator, config.get('timers.lookupBlocks', 25), myArgs=[self], requiresPeer=True, maxThreads=1)
|
||||
lookup_blocks_timer = OnionrCommunicatorTimers(self, lookupblocks.lookup_blocks_from_communicator, config.get('timers.lookupBlocks', 25), myArgs=[self], requiresPeer=True, maxThreads=1)
|
||||
# The block download timer is accessed by the block lookup function to trigger faster download starts
|
||||
self.download_blocks_timer = OnionrCommunicatorTimers(self, self.getBlocks, config.get('timers.getBlocks', 30), requiresPeer=True, maxThreads=2)
|
||||
self.download_blocks_timer = OnionrCommunicatorTimers(self, self.getBlocks, config.get('timers.getBlocks', 30), requiresPeer=True, maxThreads=5)
|
||||
|
||||
# Timer to reset the longest offline peer so contact can be attempted again
|
||||
OnionrCommunicatorTimers(self, onlinepeers.clear_offline_peer, 58, myArgs=[self])
|
||||
|
@ -166,6 +166,7 @@ class OnionrCommunicatorDaemon:
|
|||
peerPoolTimer.count = (peerPoolTimer.frequency - 1)
|
||||
cleanupTimer.count = (cleanupTimer.frequency - 60)
|
||||
blockCleanupTimer.count = (blockCleanupTimer.frequency - 2)
|
||||
lookup_blocks_timer = (lookup_blocks_timer.frequency - 2)
|
||||
|
||||
shared_state.add(self)
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ def download_blocks_from_communicator(comm_inst):
|
|||
assert isinstance(comm_inst, communicator.OnionrCommunicatorDaemon)
|
||||
blacklist = onionrblacklist.OnionrBlackList()
|
||||
storage_counter = storagecounter.StorageCounter()
|
||||
LOG_SKIP_COUNT = 10 # for how many iterations we skip logging the counter
|
||||
LOG_SKIP_COUNT = 50 # for how many iterations we skip logging the counter
|
||||
count = 0
|
||||
# Iterate the block queue in the communicator
|
||||
for blockHash in list(comm_inst.blockQueue):
|
||||
|
|
|
@ -184,7 +184,11 @@ HiddenServicePort 80 ''' + self.apiServerIP + ''':''' + str(self.hsPort)
|
|||
pass
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
time.sleep(TOR_KILL_WAIT)
|
||||
|
||||
try:
|
||||
time.sleep(TOR_KILL_WAIT)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
if 'windows' == platform.system().lower():
|
||||
os.system('taskkill /PID %s /F' % (pidN,))
|
||||
|
|
|
@ -24,6 +24,7 @@ from .. import exportblocks # commands to export blocks
|
|||
from .. import pubkeymanager # commands to add or change id
|
||||
from .. import resettor # commands to reset the tor data directory or transport keypair
|
||||
from .. import resetplugins # command to reinstall default plugins
|
||||
from .. import softreset # command to delete onionr blocks
|
||||
import onionrexceptions
|
||||
from onionrutils import importnewblocks # func to import new blocks
|
||||
import onionrevents as events
|
||||
|
@ -47,7 +48,8 @@ def get_arguments():
|
|||
('changeid', 'change-id'): pubkeymanager.change_ID,
|
||||
('resettor', 'reset-tor'): resettor.reset_tor,
|
||||
('resetplugins', 'reset-plugins'): resetplugins.reset,
|
||||
('reset-tor-node-transport'): resettor.reset_tor_key_pair
|
||||
('reset-tor-node-transport',): resettor.reset_tor_key_pair,
|
||||
('soft-reset', 'softreset'): softreset.soft_reset
|
||||
|
||||
}
|
||||
return args
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
"""
|
||||
Onionr - Private P2P Communication
|
||||
|
||||
Command to soft-reset Onionr (deletes blocks)
|
||||
"""
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from onionrutils import localcommand
|
||||
from coredb import dbfiles
|
||||
import filepaths
|
||||
import logger
|
||||
def soft_reset():
|
||||
if localcommand.local_command('/ping') == 'pong!':
|
||||
logger.warn('Cannot soft reset while Onionr is running', terminal=True)
|
||||
return
|
||||
path = filepaths.block_data_location
|
||||
shutil.rmtree(path)
|
||||
os.remove(dbfiles.block_meta_db)
|
||||
logger.info("Soft reset Onionr", terminal=True)
|
||||
|
||||
soft_reset.onionr_help = "Deletes Onionr blocks and their associated metadata, except for any exported block files."
|
|
@ -2,6 +2,7 @@ import sys, sqlite3
|
|||
import onionrstorage, onionrexceptions, onionrcrypto as crypto
|
||||
import filepaths, storagecounter
|
||||
from coredb import dbfiles
|
||||
from onionrutils import blockmetadata, bytesconverter
|
||||
def set_data(data):
|
||||
'''
|
||||
Set the data assciated with a hash
|
||||
|
@ -9,6 +10,8 @@ def set_data(data):
|
|||
storage_counter = storagecounter.StorageCounter()
|
||||
data = data
|
||||
dataSize = sys.getsizeof(data)
|
||||
nonce_hash = crypto.hashers.sha3_hash(bytesconverter.str_to_bytes(blockmetadata.fromdata.get_block_metadata_from_data(data)[2]))
|
||||
nonce_hash = bytesconverter.bytes_to_str(nonce_hash)
|
||||
|
||||
if not type(data) is bytes:
|
||||
data = data.encode()
|
||||
|
@ -29,7 +32,7 @@ def set_data(data):
|
|||
conn.commit()
|
||||
conn.close()
|
||||
with open(filepaths.data_nonce_file, 'a') as nonceFile:
|
||||
nonceFile.write(dataHash + '\n')
|
||||
nonceFile.write(nonce_hash + '\n')
|
||||
else:
|
||||
raise onionrexceptions.DiskAllocationReached
|
||||
else:
|
||||
|
|
|
@ -29,6 +29,7 @@ def ping():
|
|||
|
||||
@flask_blueprint.route('/chatapi/send/<peer>', methods=['POST'])
|
||||
def send_message(peer):
|
||||
"""Send a message to the peer"""
|
||||
data = request.get_json(force=True)
|
||||
key_store.refresh()
|
||||
existing = key_store.get('s' + peer)
|
||||
|
@ -41,6 +42,7 @@ def send_message(peer):
|
|||
|
||||
@flask_blueprint.route('/chatapi/gets/<peer>')
|
||||
def get_sent(peer):
|
||||
"""Get messages sent to peer"""
|
||||
sent = key_store.get('s' + peer)
|
||||
if sent is None:
|
||||
sent = []
|
||||
|
@ -48,6 +50,7 @@ def get_sent(peer):
|
|||
|
||||
@flask_blueprint.route('/chatapi/addrec/<peer>', methods=['POST'])
|
||||
def add_rec(peer):
|
||||
"""Add a received message from the peer"""
|
||||
data = request.get_json(force=True)
|
||||
key_store.refresh()
|
||||
existing = key_store.get('r' + peer)
|
||||
|
@ -60,6 +63,7 @@ def add_rec(peer):
|
|||
|
||||
@flask_blueprint.route('/chatapi/getrec/<peer>')
|
||||
def get_messages(peer):
|
||||
"""Get received messages for the peer"""
|
||||
key_store.refresh()
|
||||
existing = key_store.get('r' + peer)
|
||||
if existing is None:
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<script defer src='/chat/js/messages.js'></script>
|
||||
<script defer src='/chat/js/message-feed.js'></script>
|
||||
<script defer src='/chat/js/resizes.js'></script>
|
||||
<script defer src='/chat/js/change-convo.js'></script>
|
||||
<script defer src='/chat/js/main.js'></script>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
var conversationListElements = document.getElementsByClassName('conversationList')
|
||||
for (i = 0; i < conversationListElements.length; i++){
|
||||
conversationListElements[i].onclick = function(e){
|
||||
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@
|
|||
friendList = {}
|
||||
convoListElement = document.getElementsByClassName('conversationList')[0]
|
||||
firstConvoLoad = true
|
||||
activeConvo = null;
|
||||
|
||||
function createConvoList(){
|
||||
convoListElement.innerHTML = ""
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
<li><a href="https://palletsprojects.com/p/flask/">Flask</a> - Lightweight Python web framework - 3-clause BSD license</li>
|
||||
<li><a href="http://gevent.org">Gevent</a> - For the thread-safe WSGI servers - MIT license</li>
|
||||
<li><a href="https://2.python-requests.org/en/master/">Requests</a> - HTTP requests for humans - Apache 2.0 license</li>
|
||||
|
||||
<li><a href="https://github.com/pyca/pynacl/">PyNaCl</a> - Python libsodium binding - Apache 2.0 license</li>
|
||||
<li><a href="https://download.libsodium.org/doc/">libsodium</a> - modern crypto library - ISC license</li>
|
||||
<li><a href="https://fontawesome.com/license/free">Font Awesome</a> - Icon set and toolkit - MIT license & CC-By 4.0</li>
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
|
|
Loading…
Reference in New Issue