renamed old block api due to namespace conflict
fix onboarding not using optimize cpu option
This commit is contained in:
parent
9e2d374270
commit
a3ce191ed3
@ -2,5 +2,5 @@ Blockio wraps safedb, the new key value database module
|
||||
|
||||
This is how the keys are setup and what they are for:
|
||||
|
||||
bl-{type}: list of hashes for blocks for every stored block type
|
||||
bl-{type}: bytes of hashes for each block type
|
||||
{block hash}: block data
|
||||
|
@ -11,7 +11,7 @@ import os
|
||||
if not os.path.exists('onionr.sh'):
|
||||
os.chdir('../')
|
||||
sys.path.append("src/")
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
|
||||
|
||||
amount = int(input("Number of blocks:"))
|
||||
@ -24,8 +24,8 @@ else:
|
||||
|
||||
for i in range(amount):
|
||||
if expire:
|
||||
print(onionrblocks.insert(data=os.urandom(32), expire=expire))
|
||||
print(oldblocks.insert(data=os.urandom(32), expire=expire))
|
||||
else:
|
||||
print(onionrblocks.insert(data=os.urandom(32)))
|
||||
print(oldblocks.insert(data=os.urandom(32)))
|
||||
print(i, "done")
|
||||
|
||||
|
@ -6,7 +6,7 @@ if not os.path.exists('onionr.sh'):
|
||||
os.chdir('../')
|
||||
sys.path.append("src/")
|
||||
from coredb.blockmetadb import get_block_list
|
||||
from onionrblocks.onionrblockapi import Block
|
||||
from oldblocks.onionrblockapi import Block
|
||||
|
||||
for bl in get_block_list():
|
||||
bl_obj = Block(bl, decrypt=False)
|
||||
|
@ -5,8 +5,8 @@ import os
|
||||
if not os.path.exists('onionr.sh'):
|
||||
os.chdir('../')
|
||||
sys.path.append("src/")
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
|
||||
expire = 600
|
||||
print(onionrblocks.insert(data=os.urandom(32), expire=expire))
|
||||
print(oldblocks.insert(data=os.urandom(32), expire=expire))
|
||||
|
||||
|
@ -70,7 +70,7 @@ createdirs.create_dirs()
|
||||
import bigbrother # noqa
|
||||
from onionrcommands import parser # noqa
|
||||
from onionrplugins import onionrevents as events # noqa
|
||||
from onionrblocks.deleteplaintext import delete_plaintext_no_blacklist # noqa
|
||||
from oldblocks.deleteplaintext import delete_plaintext_no_blacklist # noqa
|
||||
|
||||
setup.setup_config()
|
||||
|
||||
|
@ -2,7 +2,13 @@
|
||||
|
||||
Store blocks and cache meta info such as block type
|
||||
"""
|
||||
import safedb
|
||||
from typing import TYPE_CHECKING, Union, NewType
|
||||
|
||||
from safedb import DBProtectionOpeningModeError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kasten import Kasten
|
||||
from safedb import SafeDB
|
||||
"""
|
||||
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
|
||||
@ -18,9 +24,10 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
RawBlock = NewType('RawBlock', bytes)
|
||||
|
||||
def store_block(block_data):
|
||||
|
||||
# If Onionr daemon is running, we should use the client
|
||||
# API server to store blocks, if not we can
|
||||
def store_block(block: Kasten, safe_db: SafeDB):
|
||||
|
||||
safe_db.put(block.id, block.get_packed())
|
||||
|
||||
|
@ -5,7 +5,7 @@ Use the communicator to insert fake mail messages
|
||||
import secrets
|
||||
|
||||
from etc import onionrvalues
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
"""
|
||||
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
|
||||
@ -30,6 +30,6 @@ def insert_deniable_block():
|
||||
# This assumes on the libsodium primitives to have key-privacy
|
||||
fakePeer = onionrvalues.DENIABLE_PEER_ADDRESS
|
||||
data = secrets.token_hex(secrets.randbelow(5120) + 1)
|
||||
onionrblocks.insert(data, header='pm', encryptType='asym',
|
||||
oldblocks.insert(data, header='pm', encryptType='asym',
|
||||
asymPeer=fakePeer, disableForward=True,
|
||||
meta={'subject': 'foo'})
|
||||
|
@ -17,14 +17,14 @@ import onionrpeers
|
||||
|
||||
from communicator import peeraction
|
||||
from communicator import onlinepeers
|
||||
from onionrblocks import blockmetadata
|
||||
from oldblocks import blockmetadata
|
||||
from onionrutils import validatemetadata
|
||||
from coredb import blockmetadb
|
||||
from onionrutils.localcommand import local_command
|
||||
import onionrcrypto
|
||||
import onionrstorage
|
||||
from onionrblocks import onionrblacklist
|
||||
from onionrblocks import storagecounter
|
||||
from oldblocks import onionrblacklist
|
||||
from oldblocks import storagecounter
|
||||
from . import shoulddownload
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -4,7 +4,7 @@ Check if a block should be downloaded
|
||||
(if we already have it or its blacklisted or not)
|
||||
"""
|
||||
from coredb import blockmetadb
|
||||
from onionrblocks import onionrblacklist
|
||||
from oldblocks import onionrblacklist
|
||||
"""
|
||||
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
|
||||
|
@ -15,8 +15,8 @@ from onionrutils import epoch
|
||||
from coredb import blockmetadb, dbfiles
|
||||
import onionrstorage
|
||||
from onionrstorage import removeblock
|
||||
from onionrblocks import onionrblacklist
|
||||
from onionrblocks.storagecounter import StorageCounter
|
||||
from oldblocks import onionrblacklist
|
||||
from oldblocks.storagecounter import StorageCounter
|
||||
from etc.onionrvalues import DATABASE_LOCK_TIMEOUT
|
||||
from onionrproofs import hashMeetsDifficulty
|
||||
"""
|
||||
|
@ -15,11 +15,11 @@ from onionrutils import stringvalidators, epoch
|
||||
from communicator import peeraction, onlinepeers
|
||||
from coredb.blockmetadb import get_block_list
|
||||
from utils import reconstructhash
|
||||
from onionrblocks import onionrblacklist
|
||||
from oldblocks import onionrblacklist
|
||||
import onionrexceptions
|
||||
import config
|
||||
from etc import onionrvalues
|
||||
from onionrblocks.storagecounter import StorageCounter
|
||||
from oldblocks.storagecounter import StorageCounter
|
||||
"""
|
||||
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
|
||||
|
@ -13,8 +13,8 @@ from onionrtypes import UserID
|
||||
import logger
|
||||
from communicatorutils import proxypicker
|
||||
import onionrexceptions
|
||||
from onionrblocks import onionrblockapi as block
|
||||
from onionrblocks.blockmetadata.fromdata import get_block_metadata_from_data
|
||||
from oldblocks import onionrblockapi as block
|
||||
from oldblocks.blockmetadata.fromdata import get_block_metadata_from_data
|
||||
from onionrutils import stringvalidators, basicrequests
|
||||
from onionrutils.validatemetadata import validate_metadata
|
||||
from communicator import onlinepeers
|
||||
|
@ -6,7 +6,7 @@ import time
|
||||
from typing import List
|
||||
|
||||
import onionrtypes
|
||||
from onionrblocks import onionrblockapi
|
||||
from oldblocks import onionrblockapi
|
||||
|
||||
from .pool import UploadPool
|
||||
from .pool import PoolFullException
|
||||
|
@ -5,7 +5,7 @@ Add an entry to the block metadata database
|
||||
import sqlite3
|
||||
import secrets
|
||||
from onionrutils import epoch
|
||||
from onionrblocks import blockmetadata
|
||||
from oldblocks import blockmetadata
|
||||
from etc import onionrvalues
|
||||
from .. import dbfiles
|
||||
from onionrexceptions import BlockMetaEntryExists
|
||||
|
@ -1,6 +1,6 @@
|
||||
import ujson as json
|
||||
|
||||
from onionrblocks import onionrblockapi
|
||||
from oldblocks import onionrblockapi
|
||||
from onionrutils import bytesconverter, stringvalidators
|
||||
import onionrexceptions
|
||||
class GetBlockData:
|
||||
|
@ -11,7 +11,7 @@ from flask import Blueprint, Response, request, g
|
||||
if TYPE_CHECKING:
|
||||
from deadsimplekv import DeadSimpleKV
|
||||
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
from onionrcrypto import hashers
|
||||
from onionrutils import bytesconverter
|
||||
from onionrutils import mnemonickeys
|
||||
@ -84,7 +84,7 @@ def client_api_insert_block():
|
||||
disable_forward_secrecy = False
|
||||
|
||||
threading.Thread(
|
||||
target=onionrblocks.insert, args=(message,),
|
||||
target=oldblocks.insert, args=(message,),
|
||||
kwargs={'header': bType, 'encryptType': encrypt_type,
|
||||
'sign': sign, 'asymPeer': to, 'meta': meta,
|
||||
'disableForward': disable_forward_secrecy}).start()
|
||||
|
@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
from flask import Blueprint, Response, abort
|
||||
from onionrblocks import onionrblockapi
|
||||
from oldblocks import onionrblockapi
|
||||
from .. import apiutils
|
||||
from onionrutils import stringvalidators
|
||||
from coredb import blockmetadb
|
||||
|
@ -3,7 +3,7 @@ from flask import Response
|
||||
import unpaddedbase32
|
||||
|
||||
from coredb import blockmetadb
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
from etc import onionrvalues
|
||||
import config
|
||||
from onionrutils import bytesconverter
|
||||
@ -18,7 +18,7 @@ def get_motd()->Response:
|
||||
newest_time = 0
|
||||
message = "No MOTD currently present."
|
||||
for x in motds:
|
||||
bl = onionrblocks.onionrblockapi.Block(x)
|
||||
bl = oldblocks.onionrblockapi.Block(x)
|
||||
if not bl.verifySig() or bl.signer != bytesconverter.bytes_to_str(unpaddedbase32.repad(bytesconverter.str_to_bytes(signer))): continue
|
||||
if not bl.isSigner(signer): continue
|
||||
if bl.claimedTime > newest_time:
|
||||
|
@ -8,8 +8,8 @@ import config
|
||||
from onionrutils import bytesconverter, stringvalidators
|
||||
from coredb import blockmetadb
|
||||
from utils import reconstructhash
|
||||
from onionrblocks import BlockList
|
||||
from onionrblocks.onionrblockapi import Block
|
||||
from oldblocks import BlockList
|
||||
from oldblocks.onionrblockapi import Block
|
||||
from .. import apiutils
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -10,7 +10,7 @@ from flask import abort
|
||||
from flask import g
|
||||
|
||||
from onionrutils import localcommand
|
||||
from onionrblocks import blockimporter
|
||||
from oldblocks import blockimporter
|
||||
import onionrexceptions
|
||||
import logger
|
||||
import config
|
||||
|
@ -10,7 +10,7 @@ import unpaddedbase32
|
||||
|
||||
from flask import Blueprint, Response, request, abort
|
||||
|
||||
from onionrblocks import onionrblockapi
|
||||
from oldblocks import onionrblockapi
|
||||
import onionrexceptions
|
||||
from onionrutils import stringvalidators
|
||||
from onionrutils import mnemonickeys
|
||||
|
@ -10,7 +10,7 @@ import onionrexceptions
|
||||
from onionrutils import mnemonickeys
|
||||
from onionrutils import stringvalidators
|
||||
from coredb import blockmetadb
|
||||
from onionrblocks.onionrblockapi import Block
|
||||
from oldblocks.onionrblockapi import Block
|
||||
from onionrtypes import BlockHash
|
||||
|
||||
"""
|
||||
|
@ -10,8 +10,8 @@ import os
|
||||
import unpaddedbase32
|
||||
|
||||
from coredb import blockmetadb
|
||||
from onionrblocks import onionrblockapi
|
||||
from onionrblocks import insert
|
||||
from oldblocks import onionrblockapi
|
||||
from oldblocks import insert
|
||||
|
||||
# Import types. Just for type hiting
|
||||
from onionrtypes import UserID, DeterministicKeyPassphrase, BlockHash
|
||||
|
@ -9,7 +9,7 @@ from gevent import sleep
|
||||
import gevent
|
||||
import ujson
|
||||
|
||||
from onionrblocks.onionrblockapi import Block
|
||||
from oldblocks.onionrblockapi import Block
|
||||
from coredb.dbfiles import block_meta_db
|
||||
from coredb.blockmetadb import get_block_list
|
||||
from onionrutils.epoch import get_epoch
|
||||
|
@ -9,7 +9,7 @@ from typing import Set
|
||||
from onionrtypes import LANIP
|
||||
import logger
|
||||
from coredb.blockmetadb import get_block_list
|
||||
from onionrblocks.blockimporter import import_block_from_data
|
||||
from oldblocks.blockimporter import import_block_from_data
|
||||
import onionrexceptions
|
||||
from ..server import ports
|
||||
from onionrproofs import hashMeetsDifficulty
|
||||
|
@ -12,7 +12,7 @@ from flask import Response
|
||||
from flask import request
|
||||
from flask import abort
|
||||
|
||||
from onionrblocks.onionrblockapi import Block
|
||||
from oldblocks.onionrblockapi import Block
|
||||
from httpapi.fdsafehandler import FDSafeHandler
|
||||
from netcontroller import get_open_port
|
||||
import config
|
||||
|
@ -10,7 +10,7 @@ import logger
|
||||
from onionrutils import validatemetadata
|
||||
from onionrutils import bytesconverter
|
||||
from coredb import blockmetadb
|
||||
from onionrblocks import blockmetadata
|
||||
from oldblocks import blockmetadata
|
||||
import onionrstorage
|
||||
import onionrcrypto as crypto
|
||||
from . import onionrblacklist
|
@ -3,7 +3,7 @@
|
||||
Process block metadata with relevant actions
|
||||
"""
|
||||
from etc import onionrvalues
|
||||
from onionrblocks import onionrblockapi
|
||||
from oldblocks import onionrblockapi
|
||||
from onionrutils import epoch, bytesconverter
|
||||
from coredb import blockmetadb
|
||||
import logger
|
@ -1,6 +1,6 @@
|
||||
"""Onionr - P2P Anonymous Storage Network.
|
||||
|
||||
OnionrBlocks class for abstraction of blocks
|
||||
oldblocks class for abstraction of blocks
|
||||
"""
|
||||
import datetime
|
||||
import onionrstorage
|
||||
@ -15,7 +15,7 @@ from onionrusers import onionrusers
|
||||
from onionrutils import stringvalidators, epoch
|
||||
from coredb import blockmetadb
|
||||
from onionrutils import bytesconverter
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
from onionrcrypto import encryption, cryptoutils as cryptoutils, signing
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
@ -7,7 +7,7 @@ import logger
|
||||
from onionrutils import stringvalidators
|
||||
from onionrstorage import removeblock
|
||||
from onionrstorage import deleteBlock
|
||||
from onionrblocks import onionrblacklist
|
||||
from oldblocks import onionrblacklist
|
||||
from utils import reconstructhash
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -12,6 +12,7 @@ from communicatorutils import uploadblocks
|
||||
from communicatorutils import announcenode, deniableinserts
|
||||
from communicatorutils import netcheck
|
||||
import onionrpeers
|
||||
|
||||
import config
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -6,11 +6,11 @@ and getting files from the Onionr network
|
||||
import sys
|
||||
import os
|
||||
import logger
|
||||
from onionrblocks.onionrblockapi import Block
|
||||
from oldblocks.onionrblockapi import Block
|
||||
import onionrexceptions
|
||||
from onionrutils import stringvalidators
|
||||
from etc import onionrvalues
|
||||
from onionrblocks import insert
|
||||
from oldblocks import insert
|
||||
"""
|
||||
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
|
||||
|
@ -3,7 +3,7 @@
|
||||
Dumb listing of Onionr sites
|
||||
"""
|
||||
from coredb.blockmetadb import get_blocks_by_type
|
||||
from onionrblocks.onionrblockapi import Block
|
||||
from oldblocks.onionrblockapi import Block
|
||||
import logger
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -3,7 +3,7 @@
|
||||
Command to make new network-wide MOTD message. Only network admin can do this
|
||||
The key is set in onionrvalues
|
||||
"""
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
"""
|
||||
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
|
||||
@ -29,7 +29,7 @@ def motd_creator():
|
||||
new = input() # nosec B323
|
||||
if new != 'quit':
|
||||
motd += new
|
||||
bl = onionrblocks.insert(motd, header='motd', sign=True)
|
||||
bl = oldblocks.insert(motd, header='motd', sign=True)
|
||||
print(f"inserted in {bl}")
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ This module defines commands to show stats/details about the local node
|
||||
"""
|
||||
import os
|
||||
import logger
|
||||
from onionrblocks import onionrblacklist
|
||||
from oldblocks import onionrblacklist
|
||||
from onionrutils import mnemonickeys
|
||||
from utils import sizeutils, gethostname, getconsolewidth, identifyhome
|
||||
from coredb import blockmetadb, keydb
|
||||
|
@ -21,7 +21,7 @@ import sqlite3
|
||||
import logger
|
||||
from onionrutils import epoch
|
||||
from . import scoresortedpeerlist, peerprofiles
|
||||
from onionrblocks import onionrblacklist
|
||||
from oldblocks import onionrblacklist
|
||||
import config
|
||||
from coredb import keydb
|
||||
def peer_cleanup():
|
||||
|
@ -20,7 +20,7 @@
|
||||
from coredb import keydb
|
||||
from onionrutils import epoch
|
||||
from onionrutils import stringvalidators
|
||||
from onionrblocks import onionrblacklist
|
||||
from oldblocks import onionrblacklist
|
||||
import onionrexceptions
|
||||
|
||||
UPDATE_DELAY = 300
|
||||
|
@ -7,7 +7,7 @@ import nacl.encoding, nacl.hash, nacl.utils
|
||||
|
||||
import config
|
||||
import logger
|
||||
from onionrblocks import onionrblockapi
|
||||
from oldblocks import onionrblockapi
|
||||
from onionrutils import bytesconverter
|
||||
from onionrcrypto import hashers
|
||||
|
||||
|
@ -9,7 +9,7 @@ import onionrexceptions
|
||||
import onionrstorage
|
||||
from onionrutils import stringvalidators
|
||||
from coredb import dbfiles
|
||||
from onionrblocks import storagecounter
|
||||
from oldblocks import storagecounter
|
||||
from etc.onionrvalues import DATABASE_LOCK_TIMEOUT
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -9,7 +9,7 @@ import onionrstorage
|
||||
import onionrexceptions
|
||||
import onionrcrypto as crypto
|
||||
import filepaths
|
||||
from onionrblocks import storagecounter, blockmetadata
|
||||
from oldblocks import storagecounter, blockmetadata
|
||||
from coredb import dbfiles
|
||||
from onionrutils import bytesconverter
|
||||
from etc.onionrvalues import DATABASE_LOCK_TIMEOUT
|
||||
|
@ -5,7 +5,7 @@ import new blocks from disk, providing transport agnosticism
|
||||
import glob
|
||||
|
||||
import logger
|
||||
from onionrblocks import blockmetadata
|
||||
from oldblocks import blockmetadata
|
||||
from coredb import blockmetadb
|
||||
import filepaths
|
||||
import onionrcrypto as crypto
|
||||
|
@ -2,7 +2,7 @@ import os
|
||||
|
||||
from gevent import sleep
|
||||
|
||||
from onionrblocks import insert
|
||||
from oldblocks import insert
|
||||
import logger
|
||||
from coredb.blockmetadb import get_block_list
|
||||
from onionrutils import epoch
|
||||
|
@ -1,7 +1,7 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
import logger
|
||||
import coredb
|
||||
from communicator import peeraction
|
||||
@ -11,7 +11,7 @@ def _check_remote_node(testmanager):
|
||||
|
||||
def insert_bin_test(testmanager):
|
||||
data = os.urandom(32)
|
||||
b_hash = onionrblocks.insert(data)
|
||||
b_hash = oldblocks.insert(data)
|
||||
time.sleep(0.3)
|
||||
if b_hash not in testmanager._too_many.get_by_string("PublicAPI").hideBlocks:
|
||||
raise ValueError("Block not hidden")
|
||||
|
@ -2,7 +2,7 @@ import requests
|
||||
|
||||
from lan.getip import best_ip
|
||||
|
||||
from onionrblocks import insert, onionrblockapi
|
||||
from oldblocks import insert, onionrblockapi
|
||||
from gevent import sleep
|
||||
from coredb import blockmetadb
|
||||
from onionrutils.epoch import get_epoch
|
||||
|
@ -1,7 +1,7 @@
|
||||
import os
|
||||
from shutil import move
|
||||
|
||||
from onionrblocks import insert
|
||||
from oldblocks import insert
|
||||
from onionrstorage import deleteBlock
|
||||
from onionrcommands.exportblocks import export_block
|
||||
from filepaths import export_location, block_data_location, data_nonce_file
|
||||
|
@ -1,6 +1,6 @@
|
||||
import os
|
||||
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
import logger
|
||||
import coredb
|
||||
from onionrutils import epoch
|
||||
@ -10,7 +10,7 @@ def stress_test_block_insert(testmanager):
|
||||
start = epoch.get_epoch()
|
||||
count = 100
|
||||
max_insert_speed = 120
|
||||
for x in range(count): onionrblocks.insert(os.urandom(32))
|
||||
for x in range(count): oldblocks.insert(os.urandom(32))
|
||||
speed = epoch.get_epoch() - start
|
||||
if speed < max_insert_speed:
|
||||
raise ValueError(f'{count} blocks inserted too fast, {max_insert_speed}, got {speed}')
|
||||
|
@ -22,6 +22,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
class DBProtectionOpeningModeError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class SafeDB:
|
||||
"""Wrapper around dbm to optionally encrypt db values."""
|
||||
|
||||
@ -31,7 +35,8 @@ class SafeDB:
|
||||
return unprotect_string(self.db_conn[key])
|
||||
|
||||
def put(
|
||||
self, key: [str, bytes, bytearray], value: [bytes, bytearray]):
|
||||
self,
|
||||
key: Union[str, bytes, bytearray], value: Union[bytes, bytearray]):
|
||||
if self.protected:
|
||||
self.db_conn[key] = protect_string(value)
|
||||
else:
|
||||
@ -47,10 +52,10 @@ class SafeDB:
|
||||
try:
|
||||
existing_protected_mode = self.db_conn['enc']
|
||||
if protected and existing_protected_mode != b'1':
|
||||
raise ValueError(
|
||||
raise DBProtectionOpeningModeError(
|
||||
"Cannot open unencrypted database with protected=True")
|
||||
elif not protected and existing_protected_mode != b'0':
|
||||
raise ValueError(
|
||||
raise DBProtectionOpeningModeError(
|
||||
"Cannot open encrypted database in protected=False")
|
||||
except KeyError:
|
||||
if protected:
|
||||
|
@ -10,7 +10,7 @@ from watchdog.events import FileSystemEventHandler
|
||||
import config
|
||||
from filepaths import block_data_location
|
||||
from etc.onionrvalues import BLOCK_EXPORT_FILE_EXT
|
||||
from onionrblocks.blockimporter import import_block_from_data
|
||||
from oldblocks.blockimporter import import_block_from_data
|
||||
import onionrexceptions
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -20,7 +20,7 @@
|
||||
import logger
|
||||
from coredb import keydb
|
||||
import config
|
||||
from onionrblocks import onionrblacklist
|
||||
from oldblocks import onionrblacklist
|
||||
from utils import gettransports
|
||||
def mergeAdders(newAdderList):
|
||||
'''
|
||||
|
@ -11,9 +11,9 @@ from coredb import blockmetadb
|
||||
import threading
|
||||
import time
|
||||
import locale
|
||||
from onionrblocks.onionrblockapi import Block
|
||||
from oldblocks.onionrblockapi import Block
|
||||
import logger
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
from onionrutils import escapeansi, epoch, bytesconverter
|
||||
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
@ -79,7 +79,7 @@ class OnionrFlow:
|
||||
expireTime = epoch.get_epoch() + EXPIRE_TIME
|
||||
if len(message) > 0:
|
||||
logger.info('Inserting message as block...', terminal=True)
|
||||
onionrblocks.insert(message, header='brd',
|
||||
oldblocks.insert(message, header='brd',
|
||||
expire=expireTime,
|
||||
meta = {
|
||||
'ch': self.channel})
|
||||
@ -132,7 +132,7 @@ def on_circlesend_cmd(api, data=None):
|
||||
except IndexError:
|
||||
logger.error(err_msg, terminal=True)
|
||||
|
||||
bl = onionrblocks.insert(sys.argv[3], header='brd',
|
||||
bl = oldblocks.insert(sys.argv[3], header='brd',
|
||||
expire=(EXPIRE_TIME + epoch.get_epoch()),
|
||||
meta={'ch': sys.argv[2]})
|
||||
print(bl)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Load the user's inbox and return it as a list
|
||||
"""
|
||||
from onionrblocks import onionrblockapi
|
||||
from oldblocks import onionrblockapi
|
||||
from coredb import blockmetadb
|
||||
from utils import reconstructhash, identifyhome
|
||||
import deadsimplekv as simplekv
|
||||
|
@ -56,6 +56,7 @@ document.getElementById('onboardingForm').onsubmit = function(e){
|
||||
submitInfo.mail = getCheckValue('useMail')
|
||||
submitInfo.circles = getCheckValue('useCircles')
|
||||
submitInfo.useDark = getCheckValue('useDarkTheme')
|
||||
submitInfo.optimize = getCheckValue('optimize')
|
||||
|
||||
if (submitInfo.donate){
|
||||
openDonateModal(submitInfo)
|
||||
|
@ -19,7 +19,7 @@ import config
|
||||
config.set("general.minimum_block_pow", 2)
|
||||
config.set('general.minimum_send_pow', 2)
|
||||
config.save()
|
||||
from onionrblocks import BlockList, insert
|
||||
from oldblocks import BlockList, insert
|
||||
|
||||
|
||||
class TestBlockList(unittest.TestCase):
|
||||
|
@ -14,7 +14,7 @@ createdirs.create_dirs()
|
||||
import onionrstorage
|
||||
from onionrutils import bytesconverter
|
||||
import onionrcrypto
|
||||
from onionrblocks import onionrblockapi
|
||||
from oldblocks import onionrblockapi
|
||||
|
||||
from onionrsetup import setup_config, setup_default_plugins
|
||||
|
||||
@ -25,20 +25,20 @@ import config
|
||||
config.set("general.minimum_block_pow", 2)
|
||||
config.set('general.minimum_send_pow', 2)
|
||||
config.save()
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
|
||||
class OnionrBlockTests(unittest.TestCase):
|
||||
def test_plaintext_insert(self):
|
||||
|
||||
message = 'hello world'
|
||||
bl = onionrblocks.insert(message)
|
||||
bl = oldblocks.insert(message)
|
||||
self.assertTrue(bl.startswith('0'))
|
||||
self.assertIn(bytesconverter.str_to_bytes(message), onionrstorage.getData(bl))
|
||||
|
||||
def test_encrypted_insert(self):
|
||||
|
||||
message = 'hello world2'
|
||||
bl = onionrblocks.insert(message, asymPeer=onionrcrypto.pub_key)
|
||||
bl = oldblocks.insert(message, asymPeer=onionrcrypto.pub_key)
|
||||
self.assertIn(bytesconverter.str_to_bytes(message), onionrblockapi.Block(bl, decrypt=True).bcontent)
|
||||
|
||||
unittest.main()
|
||||
|
@ -10,7 +10,7 @@ createdirs.create_dirs()
|
||||
from onionrcrypto import getourkeypair
|
||||
getourkeypair.get_keypair()
|
||||
from utils import readstatic
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
class OnionrConfig(unittest.TestCase):
|
||||
def test_default_file(self):
|
||||
json.loads(readstatic.read_static('default_config.json'))
|
||||
|
@ -31,7 +31,7 @@ class TestSafeDB(unittest.TestCase):
|
||||
with dbm.open(db_path) as db:
|
||||
self.assertEqual(db['enc'], b'0')
|
||||
|
||||
def test_db_create_proteced(self):
|
||||
def test_db_create_protected(self):
|
||||
_remove_db()
|
||||
db = safedb.SafeDB(db_path, protected=True)
|
||||
db.close()
|
||||
@ -46,7 +46,7 @@ class TestSafeDB(unittest.TestCase):
|
||||
db.close()
|
||||
self.assertRaises(ValueError, safedb.SafeDB, db_path, protected=False)
|
||||
|
||||
def test_db_open_unproteced(self):
|
||||
def test_db_open_unprotected(self):
|
||||
_remove_db()
|
||||
with dbm.open(db_path, 'c') as db:
|
||||
db['enc'] = b'0'
|
||||
@ -54,6 +54,14 @@ class TestSafeDB(unittest.TestCase):
|
||||
db.close()
|
||||
self.assertRaises(ValueError, safedb.SafeDB, db_path, protected=True)
|
||||
|
||||
def test_db_put_unprotected(self):
|
||||
_remove_db()
|
||||
db = safedb.SafeDB(db_path, protected=False)
|
||||
db.put("test", b"Test")
|
||||
db.close()
|
||||
with dbm.open(db_path, 'c') as db:
|
||||
self.assertEqual(db['test', b"Test"])
|
||||
|
||||
|
||||
|
||||
unittest.main()
|
||||
|
@ -25,9 +25,9 @@ import config
|
||||
config.set("general.minimum_block_pow", 2)
|
||||
config.set('general.minimum_send_pow', 2)
|
||||
config.save()
|
||||
import onionrblocks
|
||||
import oldblocks
|
||||
|
||||
from onionrblocks import storagecounter
|
||||
from oldblocks import storagecounter
|
||||
import onionrstorage
|
||||
|
||||
def _test_setup():
|
||||
@ -47,13 +47,13 @@ class TestStorageCounter(unittest.TestCase):
|
||||
def test_insert_too_much(self):
|
||||
_test_setup()
|
||||
config.set('allocations.disk', 1000)
|
||||
self.assertRaises(onionrexceptions.DiskAllocationReached, onionrblocks.insert, "test")
|
||||
self.assertRaises(onionrexceptions.DiskAllocationReached, oldblocks.insert, "test")
|
||||
|
||||
def test_count(self):
|
||||
_test_setup()
|
||||
counter = storagecounter.StorageCounter()
|
||||
start_value = counter.amount
|
||||
b_hash = onionrblocks.insert("test")
|
||||
b_hash = oldblocks.insert("test")
|
||||
sleep(0.1)
|
||||
self.assertGreater(counter.amount, start_value)
|
||||
onionrstorage.removeblock.remove_block(b_hash)
|
||||
|
@ -10,8 +10,8 @@ from utils import createdirs
|
||||
createdirs.create_dirs()
|
||||
from onionrcrypto import getourkeypair
|
||||
getourkeypair.get_keypair()
|
||||
from onionrblocks import time_insert
|
||||
from onionrblocks import onionrblockapi
|
||||
from oldblocks import time_insert
|
||||
from oldblocks import onionrblockapi
|
||||
from onionrsetup import setup_config, setup_default_plugins
|
||||
|
||||
setup_config()
|
||||
|
Loading…
Reference in New Issue
Block a user