do not start lan on qubes

This commit is contained in:
Kevin Froman 2020-08-10 01:03:32 -05:00
parent feb8004c95
commit 87b8655b83
6 changed files with 25 additions and 9 deletions

View File

@ -78,4 +78,3 @@ def daemon_event_handlers(shared_state: 'TooMany'):
events_api.register_listener(print_test)
events_api.register_listener(upload_event)
events_api.register_listener(test_runtime)

View File

@ -48,7 +48,8 @@ class UploadQueue:
self.communicator = communicator
cache: deadsimplekv.DeadSimpleKV = deadsimplekv.DeadSimpleKV(
UPLOAD_MEMORY_FILE)
self.kv: "DeadSimpleKV" = communicator.shared_state.get_by_string("DeadSimpleKV")
self.kv: "DeadSimpleKV" = \
communicator.shared_state.get_by_string("DeadSimpleKV")
self.store_obj = cache
cache = cache.get('uploads')
if cache is None:

View File

@ -29,6 +29,7 @@ ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION
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
IS_QUBES = False
"""limit type length for a block (soft enforced, ignored if invalid but block still stored)."""
MAX_BLOCK_TYPE_LENGTH = 15
"""limit clock timestamp for new blocks to be skewed in the future in seconds,
@ -74,3 +75,5 @@ else:
SCRIPT_NAME = 'start-daemon.sh'
else:
SCRIPT_NAME = 'onionr.sh'
if 'qubes' in platform.release().lower():
IS_QUBES = True

View File

@ -160,3 +160,11 @@ class PrivateEndpoints:
'generating_blocks'
))
)
@private_endpoints_bp.route('/getblockstoupload')
def get_blocks_to_upload() -> Response:
return Response(
','.join(
g.too_many.get_by_string('DeadSimpleKV').get('blocksToUpload')
)
)

View File

@ -101,8 +101,8 @@ def insert_block(data: Union[str, bytes], header: str = 'txt',
except FileNotFoundError:
pass
# record nonce
with open(filepaths.data_nonce_file, 'a') as nonceFile:
nonceFile.write(dataNonce + '\n')
with open(filepaths.data_nonce_file, 'a') as nonce_file:
nonce_file.write(dataNonce + '\n')
plaintext = data
plaintextMeta = {}
@ -263,7 +263,8 @@ def insert_block(data: Union[str, bytes], header: str = 'txt',
'/daemon-event/remove_from_insert_queue_wrapper',
post=True,
post_data={'block_hash':
bytesconverter.bytes_to_str(crypto.hashers.sha3_hash(data))},
bytesconverter.bytes_to_str(
crypto.hashers.sha3_hash(data))},
is_json=True
).get(timeout=5)
return retData

View File

@ -184,13 +184,17 @@ def daemon():
events.event('init', threaded=False)
events.event('daemon_start')
if config.get('transports.lan', True):
Thread(target=LANServer(shared_state).start_server,
daemon=True).start()
LANManager(shared_state).start()
if not onionrvalues.IS_QUBES:
Thread(target=LANServer(shared_state).start_server,
daemon=True).start()
LANManager(shared_state).start()
else:
logger.warn('LAN not supported on Qubes', terminal=True)
if config.get('transports.sneakernet', True):
Thread(target=sneakernet_import_thread, daemon=True).start()
Thread(target=statistics_reporter, args=[shared_state], daemon=True).start()
Thread(target=statistics_reporter,
args=[shared_state], daemon=True).start()
shared_state.get(DeadSimpleKV).put(
'proxyPort', net.socksPort)