diff --git a/make-release.sh b/make-release.sh index b6cdef0b..894e6c4b 100755 --- a/make-release.sh +++ b/make-release.sh @@ -2,7 +2,7 @@ rm -rf dist mkdir dist mkdir dist/onionr/ -cp -t dist/onionr/ -r docs static-data install src onionr.sh start-daemon.sh setprofile.sh +cp -t dist/onionr/ -r docs static-data install src onionr.sh start-daemon.sh setprofile.sh requirements.txt requirements-notifications.txt cp *.md dist/onionr/ PIP_USER=false export PIP_USER diff --git a/src/etc/onionrvalues.py b/src/etc/onionrvalues.py index 1aa3757a..6a878202 100755 --- a/src/etc/onionrvalues.py +++ b/src/etc/onionrvalues.py @@ -23,7 +23,7 @@ import filepaths DENIABLE_PEER_ADDRESS = "OVPCZLOXD6DC5JHX4EQ3PSOGAZ3T24F75HQLIUZSDSMYPEOXCPFA" PASSWORD_LENGTH = 25 ONIONR_TAGLINE = 'Private P2P Communication - GPLv3 - https://Onionr.net' -ONIONR_VERSION = '1.0.0' +ONIONR_VERSION = '1.1.0' ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION) API_VERSION = '0' # increments of 1; only change when something fundamental about how the API works changes. This way other nodes know how to communicate without learning too much information about you. MIN_PY_VERSION = 7 # min version of 7 so we can take advantage of non-cyclic type hints diff --git a/src/httpapi/onionrsitesapi/findsite.py b/src/httpapi/onionrsitesapi/findsite.py index 28c2f4db..6811ae4c 100644 --- a/src/httpapi/onionrsitesapi/findsite.py +++ b/src/httpapi/onionrsitesapi/findsite.py @@ -39,7 +39,7 @@ def find_site(user_id: str) -> Union[BlockHash, None]: raise onionrexceptions.InvalidPubkey found_site = None - sites = blockmetadb.get_blocks_by_type('zsite') + sites = blockmetadb.get_blocks_by_type('osite') # Find site by searching all site blocks. eww O(N) ☹️, TODO: event based for site in sites: diff --git a/src/onionrcommands/listsites.py b/src/onionrcommands/listsites.py new file mode 100644 index 00000000..3f874cfe --- /dev/null +++ b/src/onionrcommands/listsites.py @@ -0,0 +1,37 @@ +"""Onionr - Private P2P Communication. + +Dumb listing of Onionr sites +""" +from coredb.blockmetadb import get_blocks_by_type +from onionrblocks.onionrblockapi import Block +import logger +""" + 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 print_site_list(): + """Create a new MOTD message for the Onionr network.""" + block_list = get_blocks_by_type('osite') + if not block_list: + logger.info('No sites saved right now', terminal=True) + for block in block_list: + block = Block(block) + if block.isSigned(): + logger.info(block.signer.replace('=', ''), terminal=True) + else: + logger.info(block.hash, terminal=True) + + +print_site_list.onionr_help = "Dumbly list all Onionr sites currently saved" # type: ignore diff --git a/src/onionrcommands/parser/arguments.py b/src/onionrcommands/parser/arguments.py index 6fca7921..e8fc50b5 100644 --- a/src/onionrcommands/parser/arguments.py +++ b/src/onionrcommands/parser/arguments.py @@ -18,6 +18,7 @@ from .. import runtimetestcmd # cmd to execute the runtime integration tests from .. import motdcreator # cmd to generate new Onionr MOTDs from .. import sitecreator # cmd to create multi-page sites from .. import togglebootstrap # cmd to toggle bootstrap file usage +from ..listsites import print_site_list # cmd to list list ids import onionrexceptions from onionrutils import importnewblocks # func to import new blocks @@ -59,6 +60,7 @@ def get_arguments() -> dict: ('addhtml', 'add-html'): filecommands.add_html, ('addsite', 'add-site', 'update-site', 'updatesite'): sitecreator.create_multipage_site, + ('listsites', 'list-sites'): print_site_list, ('addfile', 'add-file'): filecommands.add_file, ('get-file', 'getfile'): filecommands.get_file, ('export-block', 'exportblock'): exportblocks.export_block, diff --git a/tests/runtime-result.txt b/tests/runtime-result.txt index 8fca0832..b2e7f967 100644 --- a/tests/runtime-result.txt +++ b/tests/runtime-result.txt @@ -1 +1 @@ -1580861160 \ No newline at end of file +1580888911 \ No newline at end of file diff --git a/tests/test_commands_basic.py b/tests/test_commands_basic.py index c07e059f..931c7925 100644 --- a/tests/test_commands_basic.py +++ b/tests/test_commands_basic.py @@ -16,5 +16,9 @@ class OnionrTests(unittest.TestCase): testargs = ["onionr.py", "version"] with patch.object(sys, 'argv', testargs): parser.register() + def test_site_list(self): + testargs = ["onionr.py", "list-sites"] + with patch.object(sys, 'argv', testargs): + parser.register() unittest.main()