bumped network version and main version, lots of test work and some stability improvements
This commit is contained in:
		
							parent
							
								
									e77d422fc2
								
							
						
					
					
						commit
						572e29f5d5
					
				
					 24 changed files with 243 additions and 33 deletions
				
			
		|  | @ -68,6 +68,7 @@ setup.setup_config() | |||
| 
 | ||||
| import config  # noqa | ||||
| from utils import identifyhome  # noqa | ||||
| import filepaths  # noqa | ||||
| 
 | ||||
| if config.get('advanced.security_auditing', True): | ||||
|     try: | ||||
|  | @ -93,7 +94,10 @@ if ran_as_script: | |||
| 
 | ||||
|     # If the setting is there, shred log file on exit | ||||
|     if config.get('log.file.remove_on_exit', True): | ||||
|         nuke.clean(config.get_config_file()) | ||||
|         try: | ||||
|             nuke.clean(filepaths.log_file) | ||||
|         except FileNotFoundError: | ||||
|             pass | ||||
| 
 | ||||
|     # Cleanup standard out/err because Python refuses to do it itsself | ||||
|     try: | ||||
|  |  | |||
|  | @ -72,7 +72,7 @@ def block_exec(event, info): | |||
|         if info[0].co_filename.endswith(source): | ||||
|             return | ||||
| 
 | ||||
|     if home + 'plugins/' in info[0].co_filename: | ||||
|     if 'plugins/' in info[0].co_filename: | ||||
|         return | ||||
| 
 | ||||
|     logger.warn('POSSIBLE EXPLOIT DETECTED, SEE LOGS', terminal=True) | ||||
|  |  | |||
|  | @ -23,10 +23,10 @@ import filepaths | |||
| DENIABLE_PEER_ADDRESS = "OVPCZLOXD6DC5JHX4EQ3PSOGAZ3T24F75HQLIUZSDSMYPEOXCPFA" | ||||
| PASSWORD_LENGTH = 25 | ||||
| ONIONR_TAGLINE = 'Private P2P Communication - GPLv3 - https://Onionr.net' | ||||
| ONIONR_VERSION = '2.0.0' | ||||
| ONIONR_VERSION = '3.0.0' | ||||
| ONIONR_VERSION_CODENAME = 'Genesis' | ||||
| 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. | ||||
| API_VERSION = '1' # 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 | ||||
| DEVELOPMENT_MODE = False | ||||
| """limit type length for a block (soft enforced, ignored if invalid but block still stored).""" | ||||
|  | @ -48,6 +48,8 @@ WSGI_SERVER_REQUEST_TIMEOUT_SECS = 120 | |||
| 
 | ||||
| MAX_NEW_PEER_QUEUE = 1000 | ||||
| 
 | ||||
| BLOCK_EXPORT_FILE_EXT = '.dat' | ||||
| 
 | ||||
| # Begin OnionrValues migrated values | ||||
| 
 | ||||
| """30 days is plenty of time for someone to decide to renew a block""" | ||||
|  |  | |||
|  | @ -32,3 +32,5 @@ data_nonce_file = home + 'block-nonces.dat' | |||
| keys_file = home + 'keys.txt' | ||||
| 
 | ||||
| onboarding_mark_file = home + 'onboarding-completed' | ||||
| 
 | ||||
| log_file = home + 'onionr.log' | ||||
|  |  | |||
|  | @ -19,6 +19,7 @@ | |||
| ''' | ||||
| import os | ||||
| from utils import identifyhome | ||||
| import filepaths | ||||
| 
 | ||||
| data_home = os.environ.get('ONIONR_LOG_DIR', identifyhome.identify_home()) | ||||
| # Use the bitwise operators to merge these settings | ||||
|  | @ -39,7 +40,8 @@ MAX_LOG_FILE_LINES = 10000 | |||
| 
 | ||||
| _type = OUTPUT_TO_CONSOLE | USE_ANSI # the default settings for logging | ||||
| _level = LEVEL_DEBUG # the lowest level to log | ||||
| _outputfile = '%s/onionr.log' % (data_home,) # the file to log to | ||||
| # the file to log to | ||||
| _outputfile = filepaths.log_file | ||||
| 
 | ||||
| def set_settings(type): | ||||
|     ''' | ||||
|  |  | |||
|  | @ -9,6 +9,9 @@ import onionrstorage | |||
| from utils import createdirs | ||||
| from onionrutils import stringvalidators | ||||
| import filepaths | ||||
| 
 | ||||
| import os | ||||
| from coredb import blockmetadb | ||||
| """ | ||||
|     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 | ||||
|  |  | |||
|  | @ -1,9 +1,8 @@ | |||
| ''' | ||||
|     Onionr - Private P2P Communication | ||||
| """Onionr - Private P2P Communication. | ||||
| 
 | ||||
|     DBCreator, creates sqlite3 databases used by Onionr | ||||
| ''' | ||||
| ''' | ||||
| DBCreator, creates sqlite3 databases used by Onionr | ||||
| """ | ||||
| """ | ||||
|     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 | ||||
|  | @ -16,7 +15,7 @@ | |||
| 
 | ||||
|     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 sqlite3, os | ||||
| from coredb import dbfiles | ||||
| import filepaths | ||||
|  |  | |||
|  | @ -22,13 +22,19 @@ import os, shutil | |||
| import onionrplugins as plugins | ||||
| import logger | ||||
| import filepaths | ||||
| from utils.readstatic import get_static_dir | ||||
| 
 | ||||
| def setup_default_plugins(): | ||||
|     # Copy default plugins into plugins folder | ||||
|     if not os.path.exists(plugins.get_plugins_folder()): | ||||
|         if os.path.exists('../static-data/default-plugins/'): | ||||
|             names = [f for f in os.listdir("../static-data/default-plugins/")] | ||||
|             shutil.copytree('../static-data/default-plugins/', plugins.get_plugins_folder()) | ||||
|         if os.path.exists(get_static_dir() + '/default-plugins/'): | ||||
|             names = [f for f in os.listdir(get_static_dir() + '/default-plugins/')] | ||||
|             try: | ||||
|                 shutil.copytree( | ||||
|                     get_static_dir() + '/default-plugins/', | ||||
|                     plugins.get_plugins_folder()) | ||||
|             except FileExistsError: | ||||
|                 pass | ||||
| 
 | ||||
|             # Enable plugins | ||||
|             for name in names: | ||||
|  | @ -39,6 +45,8 @@ def setup_default_plugins(): | |||
|         if not os.path.exists(plugins.get_plugin_data_folder(name)): | ||||
|             try: | ||||
|                 os.mkdir(plugins.get_plugin_data_folder(name)) | ||||
|             except FileExistsError: | ||||
|                 pass | ||||
|             except Exception as e: | ||||
|                 #logger.warn('Error enabling plugin: ' + str(e), terminal=True) | ||||
|                 plugins.disable(name, stop_event = False) | ||||
|  |  | |||
|  | @ -77,7 +77,7 @@ def store(data, blockHash=''): | |||
|             raise ValueError('Hash specified does not meet internal hash check') | ||||
|     else: | ||||
|         blockHash = ourHash | ||||
|      | ||||
| 
 | ||||
|     if DB_ENTRY_SIZE_LIMIT >= sys.getsizeof(data): | ||||
|         _dbInsert(blockHash, data) | ||||
|     else: | ||||
|  | @ -86,21 +86,23 @@ def store(data, blockHash=''): | |||
| 
 | ||||
| 
 | ||||
| def getData(bHash): | ||||
| 
 | ||||
|     if not stringvalidators.validate_hash(bHash): raise ValueError | ||||
| 
 | ||||
|     bHash = bytesconverter.bytes_to_str(bHash) | ||||
| 
 | ||||
|     bHash = bHash.strip() | ||||
|     # First check DB for data entry by hash | ||||
|     # if no entry, check disk | ||||
|     # If no entry in either, raise an exception | ||||
|     retData = None | ||||
|     fileLocation = '%s/%s.dat' % (filepaths.block_data_location, bHash) | ||||
|     not_found_msg = "Flock data not found for: " | ||||
|     not_found_msg = "Block data not found for: " | ||||
|     if os.path.exists(fileLocation): | ||||
|         with open(fileLocation, 'rb') as block: | ||||
|             retData = block.read() | ||||
|     else: | ||||
|         retData = _dbFetch(bHash) | ||||
| 
 | ||||
|         if retData is None: | ||||
|             raise onionrexceptions.NoDataAvailable(not_found_msg + str(bHash)) | ||||
|     return retData | ||||
|  |  | |||
|  | @ -1,13 +1,31 @@ | |||
| import sys, sqlite3 | ||||
| """Onionr - Private P2P Communication. | ||||
| 
 | ||||
| Test Onionr as it is running | ||||
| """ | ||||
| import sys | ||||
| import sqlite3 | ||||
| 
 | ||||
| import onionrstorage, onionrexceptions, onionrcrypto as crypto | ||||
| import filepaths | ||||
| from onionrblocks import storagecounter | ||||
| from coredb import dbfiles | ||||
| from onionrutils import blockmetadata, bytesconverter | ||||
| """ | ||||
|     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 <https://www.gnu.org/licenses/>. | ||||
| """ | ||||
| def set_data(data)->str: | ||||
|     ''' | ||||
|         Set the data assciated with a hash | ||||
|     ''' | ||||
|     """Set the data assciated with a hash.""" | ||||
|     storage_counter = storagecounter.StorageCounter() | ||||
|     data = data | ||||
|     dataSize = sys.getsizeof(data) | ||||
|  |  | |||
|  | @ -11,6 +11,7 @@ from . import uicheck, inserttest, stresstest | |||
| from . import ownnode | ||||
| from .webpasstest import webpass_test | ||||
| from .osver import test_os_ver_endpoint | ||||
| from .clearnettor import test_clearnet_tor_request | ||||
| """ | ||||
|     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 | ||||
|  | @ -32,7 +33,8 @@ RUN_TESTS = [uicheck.check_ui, | |||
|              ownnode.test_own_node, | ||||
|              stresstest.stress_test_block_insert, | ||||
|              webpass_test, | ||||
|              test_os_ver_endpoint | ||||
|              test_os_ver_endpoint, | ||||
|              test_clearnet_tor_request | ||||
|              ] | ||||
| 
 | ||||
| SUCCESS_FILE = os.path.dirname(os.path.realpath(__file__)) + '/../../tests/runtime-result.txt' | ||||
|  |  | |||
							
								
								
									
										61
									
								
								src/runtests/clearnettor.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								src/runtests/clearnettor.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,61 @@ | |||
| """Onionr - Private P2P Communication. | ||||
| 
 | ||||
| Ensure that clearnet cannot be reached | ||||
| """ | ||||
| from threading import Thread | ||||
| 
 | ||||
| from onionrutils.basicrequests import do_get_request | ||||
| from onionrutils import localcommand | ||||
| import logger | ||||
| import config | ||||
| 
 | ||||
| """ | ||||
|     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 <https://www.gnu.org/licenses/>. | ||||
| """ | ||||
| 
 | ||||
| 
 | ||||
| def test_clearnet_tor_request(testmanager): | ||||
|     """Ensure that Tor cannot request clearnet address. | ||||
| 
 | ||||
|     Does not run if Tor is being reused | ||||
|     """ | ||||
|      | ||||
|     config.reload() | ||||
|     leak_result = "" | ||||
| 
 | ||||
|     if config.get('tor.use_existing_tor', False): | ||||
|         logger.warn( | ||||
|             "Can't ensure Tor reqs to clearnet won't happen when reusing Tor") | ||||
|         return | ||||
| 
 | ||||
| 
 | ||||
|     socks_port = localcommand.local_command('/gettorsocks') | ||||
| 
 | ||||
|     # Don't worry, this request isn't meant to go through, | ||||
|     # but if it did it would be through Tor | ||||
| 
 | ||||
|     try: | ||||
|         leak_result: str = do_get_request( | ||||
|             'https://onionr.net/404', | ||||
|             port=socks_port, ignoreAPI=True).lower() | ||||
|     except AttributeError: | ||||
|         leak_result = "" | ||||
|     except Exception as e: | ||||
|         logger.warn(str(e)) | ||||
|     try: | ||||
|         if 'not found' in leak_result: | ||||
|             logger.error('Tor was able to request a clearnet site') | ||||
|             raise ValueError('Tor was able to request a clearnet site') | ||||
|     except TypeError: | ||||
|         pass | ||||
|  | @ -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 = onionrblocks.insert(data) | ||||
| 
 | ||||
|     if not b_hash in coredb.blockmetadb.get_block_list(): | ||||
|         logger.error(str(b_hash) + 'is not in bl') | ||||
|  |  | |||
|  | @ -25,14 +25,16 @@ from onionrutils import localcommand | |||
| 
 | ||||
| 
 | ||||
| def test_own_node(test_manager): | ||||
|     return | ||||
|     socks_port = localcommand.local_command('/gettorsocks') | ||||
|     if config.get('general.security_level', 0) > 0: | ||||
|         return | ||||
|     own_tor_address = gettransports.get()[0] | ||||
|     if 'this is an onionr node' \ | ||||
|             not in basicrequests.do_get_request('http://' + own_tor_address, | ||||
|                                                 port=socks_port, ignoreAPI=True).lower(): | ||||
|         logger.warn('Own node not reachable in test') | ||||
|                                                 port=socks_port, | ||||
|                                                 ignoreAPI=True).lower(): | ||||
|         logger.warn(f'Own node not reachable in test {own_tor_address}') | ||||
|         raise ValueError | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue