do not upload plaintext to peers that do not support it, closes #14

This commit is contained in:
Kevin Froman 2020-10-10 04:26:51 +00:00
parent 503bf65cbe
commit fc7db42deb
5 changed files with 19 additions and 2 deletions

View File

@ -100,7 +100,15 @@ def connect_new_peer_to_communicator(shared_state, peer='', useBootstrap=False):
else:
kv.get('peerProfiles').append(
onionrpeers.PeerProfiles(address))
try:
del kv.get('plaintextDisabledPeers')[address]
except KeyError:
pass
if peeraction.peer_action(
shared_state, address, 'plaintext') == 'false':
kv.get('plaintextDisabledPeers')[address] = True
break
else:
# Mark a peer as tried if they failed to respond to ping
tried.append(address)

View File

@ -68,6 +68,9 @@ def upload_blocks_from_communicator(comm_inst: 'OnionrCommunicatorDaemon'):
for _ in range(min(len(kv.get('onlinePeers')), 6)):
try:
peer = onlinepeers.pick_online_peer(kv)
if peer in kv.get('plaintextDisabledPeers'):
logger.info(f"Cannot upload plaintext block to peer that denies it {peer}") # noqa
continue
except onionrexceptions.OnlinePeerNeeded:
continue
try:

View File

@ -23,10 +23,10 @@ import filepaths
DENIABLE_PEER_ADDRESS = "OVPCZLOXD6DC5JHX4EQ3PSOGAZ3T24F75HQLIUZSDSMYPEOXCPFA"
PASSWORD_LENGTH = 25
ONIONR_TAGLINE = 'Private P2P Communication - GPLv3 - https://Onionr.net'
ONIONR_VERSION = '6.0.0'
ONIONR_VERSION = '6.1.0'
ONIONR_VERSION_CODENAME = 'Genesis'
ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION)
API_VERSION = '2' # 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 = '3' # 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

View File

@ -58,6 +58,11 @@ class PublicEndpoints:
return send_from_directory(
config.get('www.public.path', 'static-data/www/public/'), path)
@public_endpoints_bp.route('/plaintext')
def plaintext_enabled_endpoint():
return Response(str(config.get("general.store_plaintext_blocks", True)).lower())
@public_endpoints_bp.route('/ping')
def ping():
# Endpoint to test if nodes are up

View File

@ -27,6 +27,7 @@ if TYPE_CHECKING:
def setup_kv(shared_vars: 'DeadSimpleKV'):
"""Init initial pseudo-variables."""
shared_vars.put('plaintextDisabledPeers', {})
shared_vars.put('blockQueue', {})
shared_vars.put('shutdown', False)
shared_vars.put('onlinePeers', [])