* improved friend removal
* made restart more reliable * fixed banblock not deleting blocks * somewhat fixed friend endpoints not working with niceware keys * started working on adjusting mail interface to use div instead of inputsmaster
parent
e5fc15acc2
commit
63fced9cff
|
@ -20,7 +20,9 @@
|
|||
import sqlite3
|
||||
from onionrplugins import onionrevents as events
|
||||
from onionrutils import stringvalidators
|
||||
from onionrutils import mnemonickeys
|
||||
from .. import dbfiles
|
||||
|
||||
def remove_address(address):
|
||||
'''
|
||||
Remove an address from the address database
|
||||
|
@ -37,4 +39,21 @@ def remove_address(address):
|
|||
#events.event('address_remove', data = {'address': address}, onionr = core_inst.onionrInst)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def remove_user(pubkey: str)->bool:
|
||||
'''
|
||||
Remove a user from the user database
|
||||
'''
|
||||
pubkey = mnemonickeys.get_base32(pubkey)
|
||||
if stringvalidators.validate_pub_key(pubkey):
|
||||
conn = sqlite3.connect(dbfiles.user_id_info_db, timeout=30)
|
||||
c = conn.cursor()
|
||||
t = (pubkey,)
|
||||
c.execute('Delete from peers where id=?;', t)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import json
|
||||
from onionrusers import contactmanager
|
||||
from flask import Blueprint, Response, request, abort, redirect
|
||||
from coredb import keydb
|
||||
|
||||
friends = Blueprint('friends', __name__)
|
||||
|
||||
|
@ -38,7 +39,9 @@ def add_friend(pubkey):
|
|||
|
||||
@friends.route('/friends/remove/<pubkey>', methods=['POST'])
|
||||
def remove_friend(pubkey):
|
||||
contactmanager.ContactManager(pubkey).setTrust(0)
|
||||
contactmanager.ContactManager(pubkey).delete_contact()
|
||||
keydb.removekeys.remove_user(pubkey)
|
||||
return redirect(request.referrer + '#' + request.form['token'])
|
||||
|
||||
@friends.route('/friends/setinfo/<pubkey>/<key>', methods=['POST'])
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
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 subprocess
|
||||
|
||||
from flask import Response, Blueprint, request, send_from_directory, abort
|
||||
import unpaddedbase32
|
||||
|
||||
|
@ -26,11 +29,14 @@ from netcontroller import NetController
|
|||
from serializeddata import SerializedData
|
||||
from onionrutils import mnemonickeys
|
||||
from onionrutils import bytesconverter
|
||||
from etc import onionrvalues
|
||||
from utils import reconstructhash
|
||||
from onionrcommands import restartonionr
|
||||
|
||||
pub_key = onionrcrypto.pub_key.replace('=', '')
|
||||
|
||||
SCRIPT_NAME = os.path.dirname(os.path.realpath(__file__)) + f'/../../../{onionrvalues.SCRIPT_NAME}'
|
||||
|
||||
class PrivateEndpoints:
|
||||
def __init__(self, client_api):
|
||||
private_endpoints_bp = Blueprint('privateendpoints', __name__)
|
||||
|
@ -94,7 +100,7 @@ class PrivateEndpoints:
|
|||
|
||||
@private_endpoints_bp.route('/restartclean')
|
||||
def restart_clean():
|
||||
restartonionr.restart()
|
||||
subprocess.Popen([SCRIPT_NAME, 'restart'])
|
||||
return Response("bye")
|
||||
|
||||
@private_endpoints_bp.route('/getstats')
|
||||
|
|
|
@ -21,19 +21,26 @@ import sys
|
|||
import logger
|
||||
from onionrutils import stringvalidators
|
||||
from onionrstorage import removeblock
|
||||
from onionrstorage import deleteBlock
|
||||
from onionrblocks import onionrblacklist
|
||||
from utils import reconstructhash
|
||||
|
||||
def ban_block():
|
||||
"""Deletes a block, permanently blacklisting it"""
|
||||
blacklist = onionrblacklist.OnionrBlackList()
|
||||
try:
|
||||
ban = sys.argv[2]
|
||||
except IndexError:
|
||||
ban = logger.readline('Enter a block hash:')
|
||||
# Get the hash if its not provided as a CLI argument
|
||||
ban = logger.readline('Enter a block hash:').strip()
|
||||
# Make sure the hash has no truncated zeroes
|
||||
ban = reconstructhash.reconstruct_hash(ban)
|
||||
if stringvalidators.validate_hash(ban):
|
||||
if not blacklist.inBlacklist(ban):
|
||||
try:
|
||||
blacklist.addToDB(ban)
|
||||
removeblock.remove_block(ban)
|
||||
deleteBlock(ban)
|
||||
except Exception as error:
|
||||
logger.error('Could not blacklist block', error=error, terminal=True)
|
||||
else:
|
||||
|
|
|
@ -36,8 +36,8 @@ def restart():
|
|||
daemonlaunch.kill_daemon()
|
||||
while localcommand.local_command('ping', maxWait=8) == 'pong!':
|
||||
time.sleep(0.3)
|
||||
time.sleep(9)
|
||||
while os.path.exists(filepaths.private_API_host_file):
|
||||
time.sleep(15)
|
||||
while os.path.exists(filepaths.private_API_host_file) or os.path.exists(filepaths.daemon_mark_file):
|
||||
time.sleep(1)
|
||||
subprocess.Popen([SCRIPT_NAME, 'start'])
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ def _dbFetch(blockHash):
|
|||
return None
|
||||
|
||||
def deleteBlock(blockHash):
|
||||
# You should call core.removeBlock if you automatically want to remove storage byte count
|
||||
# You should call removeblock.remove_block if you automatically want to remove storage byte count
|
||||
if os.path.exists('%s/%s.dat' % (filepaths.block_data_location, blockHash)):
|
||||
os.remove('%s/%s.dat' % (filepaths.block_data_location, blockHash))
|
||||
return True
|
||||
|
|
|
@ -20,4 +20,4 @@ def remove_block(block):
|
|||
dataSize = sys.getsizeof(onionrstorage.getData(block))
|
||||
storagecounter.StorageCounter().remove_bytes(dataSize)
|
||||
else:
|
||||
raise onionrexceptions.InvalidHexHash
|
||||
raise onionrexceptions.InvalidHexHash
|
||||
|
|
|
@ -30,7 +30,7 @@ class ContactManager(onionrusers.OnionrUser):
|
|||
def __init__(self, publicKey, saveUser=False, recordExpireSeconds=5):
|
||||
try:
|
||||
if mnemonickeys.DELIMITER in publicKey:
|
||||
publicKey = mnemonickeys.get_base32(publicKey.split(mnemonickeys.DELIMITER))
|
||||
publicKey = mnemonickeys.get_base32(publicKey)
|
||||
#publicKey = unpaddedbase32.b32encode(bytesconverter.str_to_bytes(publicKey))
|
||||
except ValueError:
|
||||
pass
|
||||
|
|
|
@ -40,6 +40,8 @@ def get_human_readable_ID(pub=''):
|
|||
|
||||
def get_base32(words):
|
||||
'''converts mnemonic to base32'''
|
||||
if DELIMITER not in words and not type(words) in (type(list), type(tuple)): return words
|
||||
|
||||
try:
|
||||
return unpaddedbase32.b32encode(niceware.passphrase_to_bytes(words.split(DELIMITER)))
|
||||
except AttributeError:
|
||||
|
|
|
@ -180,6 +180,7 @@ function loadInboxEntries(bHash){
|
|||
var entry = document.createElement('div')
|
||||
var bHashDisplay = document.createElement('span')
|
||||
var senderInput = document.createElement('input')
|
||||
//var senderInput = document.createElement('div')
|
||||
var subjectLine = document.createElement('span')
|
||||
var dateStr = document.createElement('span')
|
||||
var validSig = document.createElement('span')
|
||||
|
|
Loading…
Reference in New Issue