diff --git a/requirements.in b/requirements.in index 2c886a9e..7cb053c3 100644 --- a/requirements.in +++ b/requirements.in @@ -1,4 +1,4 @@ -urllib3==1.25.7 +urllib3==1.25.8 requests==2.22.0 PyNaCl==1.3.0 gevent==1.4.0 @@ -8,7 +8,7 @@ stem==1.8.0 deadsimplekv==0.2.0 unpaddedbase32==0.2.0 streamedrequests==1.0.0 -jinja2==2.10.3 +jinja2==2.11.0 toomanyobjs==1.1.0 niceware==0.2.1 psutil==5.6.7 diff --git a/requirements.txt b/requirements.txt index ad8f91f1..f760e012 100644 --- a/requirements.txt +++ b/requirements.txt @@ -104,9 +104,9 @@ itsdangerous==1.1.0 \ --hash=sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19 \ --hash=sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749 \ # via flask -jinja2==2.10.3 \ - --hash=sha256:74320bb91f31270f9551d46522e33af46a80c3d619f4a4bf42b3164d30b5911f \ - --hash=sha256:9fe95f19286cfefaa917656583d020be14e7859c6b0252588391e47db34527de +jinja2==2.11.0 \ + --hash=sha256:6e7a3c2934694d59ad334c93dd1b6c96699cf24c53fdb8ec848ac6b23e685734 \ + --hash=sha256:d6609ae5ec3d56212ca7d802eda654eaf2310000816ce815361041465b108be4 markupsafe==1.1.1 \ --hash=sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473 \ --hash=sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161 \ @@ -195,9 +195,9 @@ toomanyobjs==1.1.0 \ unpaddedbase32==0.2.0 \ --hash=sha256:4aacee75f8fd6c8cf129842ecba45ca59c11bfb13dae19d86f32b48fa3715403 \ --hash=sha256:b7b780c31d27d55e66abf6c221216a35690ee8892c2daacff7f2528e229bd9c3 -urllib3==1.25.7 \ - --hash=sha256:a8a318824cc77d1fd4b2bec2ded92646630d7fe8619497b142c84a9e6f5a7293 \ - --hash=sha256:f3c5fd51747d450d4dcf6f923c81f78f811aab8205fda64b0aba34a4e48b0745 +urllib3==1.25.8 \ + --hash=sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc \ + --hash=sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc werkzeug==0.15.5 \ --hash=sha256:87ae4e5b5366da2347eb3116c0e6c681a0e939a33b2805e2c0cbd282664932c4 \ --hash=sha256:a13b74dd3c45f758d4ebdb224be8f1ab8ef58b3c0ffc1783a8c7d9f4f50227e6 \ diff --git a/src/communicatorutils/uploadblocks/__init__.py b/src/communicatorutils/uploadblocks/__init__.py index 7be780e7..9bbc2509 100755 --- a/src/communicatorutils/uploadblocks/__init__.py +++ b/src/communicatorutils/uploadblocks/__init__.py @@ -15,7 +15,6 @@ import onionrcrypto from communicator import onlinepeers if TYPE_CHECKING: from communicator import OnionrCommunicatorDaemon - """ 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 diff --git a/src/etc/onionrvalues.py b/src/etc/onionrvalues.py index 294de91f..6db86b4b 100755 --- a/src/etc/onionrvalues.py +++ b/src/etc/onionrvalues.py @@ -43,6 +43,7 @@ DATABASE_LOCK_TIMEOUT = 60 # Block creation anonymization requirements MIN_BLOCK_UPLOAD_PEER_PERCENT = 0.1 +MIN_SHARE_WAIT_DELAY_SECS = 5 WSGI_SERVER_REQUEST_TIMEOUT_SECS = 120 diff --git a/src/httpapi/miscclientapi/endpoints.py b/src/httpapi/miscclientapi/endpoints.py index 5a15f48c..2f0581b8 100644 --- a/src/httpapi/miscclientapi/endpoints.py +++ b/src/httpapi/miscclientapi/endpoints.py @@ -6,6 +6,8 @@ import os import subprocess from flask import Response, Blueprint, request, send_from_directory, abort +from gevent import spawn +from gevent import sleep import unpaddedbase32 from httpapi import apiutils @@ -71,8 +73,8 @@ class PrivateEndpoints: raise ValueError('block hash needs to be alpha numeric') name = reconstructhash.reconstruct_hash(name) if name in client_api.publicAPI.hideBlocks: - client_api.publicAPI.hideBlocks.remove(name) - return Response("removed") + spawn(_delay_wait_for_share_block_removal) + return Response("will be removed") else: client_api.publicAPI.hideBlocks.append(name) return Response("added") diff --git a/src/onionrblocks/__init__.py b/src/onionrblocks/__init__.py index 93e9fd3f..91a6b1a1 100644 --- a/src/onionrblocks/__init__.py +++ b/src/onionrblocks/__init__.py @@ -1,3 +1,5 @@ from . import insert +from .insert import time_insert -insert = insert.insert_block \ No newline at end of file +insert = insert.insert_block +time_insert = time_insert \ No newline at end of file diff --git a/src/onionrblocks/insert/__init__.py b/src/onionrblocks/insert/__init__.py new file mode 100644 index 00000000..e516f6b6 --- /dev/null +++ b/src/onionrblocks/insert/__init__.py @@ -0,0 +1,4 @@ +from . import main, timeinsert + +insert_block = main.insert_block +time_insert = timeinsert.time_insert \ No newline at end of file diff --git a/src/onionrblocks/insert.py b/src/onionrblocks/insert/main.py similarity index 99% rename from src/onionrblocks/insert.py rename to src/onionrblocks/insert/main.py index 4676cafb..d60d5f68 100644 --- a/src/onionrblocks/insert.py +++ b/src/onionrblocks/insert/main.py @@ -24,7 +24,7 @@ from gevent import spawn from onionrutils import bytesconverter, epoch import filepaths, onionrstorage -from . import storagecounter +from .. import storagecounter from onionrplugins import onionrevents as events from etc import powchoice, onionrvalues import config, onionrcrypto as crypto, onionrexceptions diff --git a/src/onionrblocks/insert/timeinsert.py b/src/onionrblocks/insert/timeinsert.py new file mode 100644 index 00000000..41d8fcaa --- /dev/null +++ b/src/onionrblocks/insert/timeinsert.py @@ -0,0 +1,51 @@ +"""Onionr - Private P2P Communication. + +Wrapper to insert blocks with variable delay +""" +from . import main +""" + 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 . +""" + + +def time_insert(*args, **kwargs): + """Block insert wrapper to allow for insertions independent of mixmate. + + Takes exact args as insert_block, with additional keyword: + delay=n; where n=seconds to tell initial nodes to delay share for. + + defaults to 0 or previously set value in current block meta + """ + try: + kwargs['meta'] + except KeyError: + kwargs['meta'] = {} + + try: + delay = int(kwargs['meta']['dly']) + except KeyError: + delay = 0 + try: + delay = kwargs['delay'] + del kwargs['delay'] + except KeyError: + delay = 0 + + # Ensure delay >=0 + if delay < 0: + raise ValueError('delay cannot be less than 0') + + kwargs['meta']['dly'] = delay + + return main.insert_block(*args, **kwargs) diff --git a/static-data/www/friends/index.html b/static-data/www/friends/index.html index 15b09c71..d2d42711 100755 --- a/static-data/www/friends/index.html +++ b/static-data/www/friends/index.html @@ -8,6 +8,7 @@ Friends + @@ -61,7 +62,9 @@

- Identity + + +

diff --git a/static-data/www/mail/index.html b/static-data/www/mail/index.html index eb52fa9e..5695aa50 100755 --- a/static-data/www/mail/index.html +++ b/static-data/www/mail/index.html @@ -65,7 +65,9 @@

- Identity + + +

diff --git a/tests/test_timeinsert.py b/tests/test_timeinsert.py new file mode 100644 index 00000000..3d637020 --- /dev/null +++ b/tests/test_timeinsert.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +import unittest, sys +sys.path.append(".") +sys.path.append("src/") + +from onionrblocks import time_insert +from onionrblocks import onionrblockapi + +class TestTimeInsert(unittest.TestCase): + def test_time_insert_none(self): + bl = time_insert('test') + self.assertTrue(bl) + bl = onionrblockapi.Block(bl) + self.assertIs(bl.bmetadata['dly'], 0) + + def test_time_insert_10(self): + bl = time_insert('test', delay=10) + self.assertTrue(bl) + bl = onionrblockapi.Block(bl) + self.assertIs(bl.bmetadata['dly'], 10) + + def test_negative(self): + self.assertRaises(ValueError, time_insert, 'test', delay=-1) + self.assertRaises(ValueError, time_insert, 'test', delay=-10) + + + +unittest.main()