diff --git a/Makefile b/Makefile
index 07aa2729..46722351 100755
--- a/Makefile
+++ b/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:
diff --git a/onionr/communicator/__init__.py b/onionr/communicator/__init__.py
index 92fe6fb2..fb650205 100755
--- a/onionr/communicator/__init__.py
+++ b/onionr/communicator/__init__.py
@@ -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)
diff --git a/onionr/communicatorutils/downloadblocks/__init__.py b/onionr/communicatorutils/downloadblocks/__init__.py
index 18abd423..e47a3cc0 100755
--- a/onionr/communicatorutils/downloadblocks/__init__.py
+++ b/onionr/communicatorutils/downloadblocks/__init__.py
@@ -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):
diff --git a/onionr/netcontroller/netcontrol.py b/onionr/netcontroller/netcontrol.py
index f561c937..f7b0746d 100644
--- a/onionr/netcontroller/netcontrol.py
+++ b/onionr/netcontroller/netcontrol.py
@@ -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,))
diff --git a/onionr/onionrcommands/parser/arguments.py b/onionr/onionrcommands/parser/arguments.py
index 2eb87862..487aa95b 100644
--- a/onionr/onionrcommands/parser/arguments.py
+++ b/onionr/onionrcommands/parser/arguments.py
@@ -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
diff --git a/onionr/onionrcommands/softreset.py b/onionr/onionrcommands/softreset.py
new file mode 100644
index 00000000..4dfcb273
--- /dev/null
+++ b/onionr/onionrcommands/softreset.py
@@ -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 .
+"""
+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."
\ No newline at end of file
diff --git a/onionr/onionrstorage/setdata.py b/onionr/onionrstorage/setdata.py
index 6558d3f9..d6cdc9e9 100644
--- a/onionr/onionrstorage/setdata.py
+++ b/onionr/onionrstorage/setdata.py
@@ -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:
diff --git a/onionr/static-data/default-plugins/chat/controlapi.py b/onionr/static-data/default-plugins/chat/controlapi.py
index 4c765f7a..7718c36a 100755
--- a/onionr/static-data/default-plugins/chat/controlapi.py
+++ b/onionr/static-data/default-plugins/chat/controlapi.py
@@ -29,6 +29,7 @@ def ping():
@flask_blueprint.route('/chatapi/send/', 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/')
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/', 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/')
def get_messages(peer):
+ """Get received messages for the peer"""
key_store.refresh()
existing = key_store.get('r' + peer)
if existing is None:
diff --git a/onionr/static-data/default-plugins/chat/settings.py b/onionr/static-data/default-plugins/chat/settings.py
new file mode 100644
index 00000000..e69de29b
diff --git a/onionr/static-data/www/chat/index.html b/onionr/static-data/www/chat/index.html
index e2ee745d..633a7621 100755
--- a/onionr/static-data/www/chat/index.html
+++ b/onionr/static-data/www/chat/index.html
@@ -18,6 +18,7 @@
+
diff --git a/onionr/static-data/www/chat/js/change-convo.js b/onionr/static-data/www/chat/js/change-convo.js
new file mode 100644
index 00000000..c35de6bb
--- /dev/null
+++ b/onionr/static-data/www/chat/js/change-convo.js
@@ -0,0 +1,6 @@
+var conversationListElements = document.getElementsByClassName('conversationList')
+for (i = 0; i < conversationListElements.length; i++){
+ conversationListElements[i].onclick = function(e){
+
+ }
+}
\ No newline at end of file
diff --git a/onionr/static-data/www/chat/js/main.js b/onionr/static-data/www/chat/js/main.js
index 17d24d53..13e1c943 100755
--- a/onionr/static-data/www/chat/js/main.js
+++ b/onionr/static-data/www/chat/js/main.js
@@ -19,6 +19,7 @@
friendList = {}
convoListElement = document.getElementsByClassName('conversationList')[0]
firstConvoLoad = true
+activeConvo = null;
function createConvoList(){
convoListElement.innerHTML = ""
diff --git a/onionr/static-data/www/shared/about.html b/onionr/static-data/www/shared/about.html
index 8926cf72..1ca7843d 100644
--- a/onionr/static-data/www/shared/about.html
+++ b/onionr/static-data/www/shared/about.html
@@ -22,7 +22,9 @@
Flask - Lightweight Python web framework - 3-clause BSD license
Gevent - For the thread-safe WSGI servers - MIT license
Requests - HTTP requests for humans - Apache 2.0 license
-
+ PyNaCl - Python libsodium binding - Apache 2.0 license
+ libsodium - modern crypto library - ISC license
+ Font Awesome - Icon set and toolkit - MIT license & CC-By 4.0