Compare commits

..

No commits in common. "6b6d357a139c118ca02a7e301ad78ee003929188" and "7b0c761dd1251a60e6b82ab65a88b939e1a94e2c" have entirely different histories.

7 changed files with 11 additions and 15 deletions

View File

@ -1,7 +1,6 @@
#!/bin/sh #!/bin/sh
ORIG_ONIONR_RUN_DIR=`pwd` ORIG_ONIONR_RUN_DIR=`pwd`
export ORIG_ONIONR_RUN_DIR export ORIG_ONIONR_RUN_DIR
export PYTHONDONTWRITEBYTECODE=1
cd "$(dirname "$0")" cd "$(dirname "$0")"
cd src cd src
./__init__.py "$@" ./__init__.py "$@"

View File

@ -8,6 +8,7 @@ app_root = os.path.dirname(os.path.realpath(__file__)) + '/../../'
gossip_server_socket_file = home + 'gossip-server.sock' gossip_server_socket_file = home + 'gossip-server.sock'
usage_file = home + 'disk-usage.txt' usage_file = home + 'disk-usage.txt'
block_data_location = home + 'blocks/'
contacts_location = home + 'contacts/' contacts_location = home + 'contacts/'
public_API_host_file = home + 'public-host.txt' public_API_host_file = home + 'public-host.txt'
private_API_host_file = home + 'private-host.txt' private_API_host_file = home + 'private-host.txt'

View File

@ -81,7 +81,6 @@ async def stem_out(d_phase: 'DandelionPhase'):
if not len(gossip_peer_set): if not len(gossip_peer_set):
sleep(1) sleep(1)
return return
not_enough_edges = False
# Spawn threads with deep copied block queue to add to db after time # Spawn threads with deep copied block queue to add to db after time
# for black hole attack # for black hole attack
@ -97,17 +96,15 @@ async def stem_out(d_phase: 'DandelionPhase'):
# Using orderedset for the tried edges to ensure random pairing with queue # Using orderedset for the tried edges to ensure random pairing with queue
tried_edges: "OrderedSet[Peer]" = OrderedSet() tried_edges: "OrderedSet[Peer]" = OrderedSet()
while len(peer_sockets) < OUTBOUND_DANDELION_EDGES or not_enough_edges: while len(peer_sockets) < OUTBOUND_DANDELION_EDGES:
try: try:
# Get a socket for stem out (makes sure they accept) # Get a socket for stem out (makes sure they accept)
peer_sockets.append(await _setup_edge(gossip_peer_set, tried_edges)) peer_sockets.append(await _setup_edge(gossip_peer_set, tried_edges))
except NotEnoughEdges: except NotEnoughEdges:
# No possible edges at this point (edges < OUTBOUND_DANDELION_EDGE) # No possible edges at this point (edges < OUTBOUND_DANDELION_EDGE)
logger.warn( logger.warn("Not able to build enough tunnels for stemout.",
"Making too few edges for stemout " +
"this is bad for anonymity if frequent."
terminal=True) terminal=True)
not_enough_edges = True break
else: else:
# Ran out of time for stem phase # Ran out of time for stem phase
if not d_phase.is_stem_phase() or d_phase.remaining_time() < 5: if not d_phase.is_stem_phase() or d_phase.remaining_time() < 5:

View File

@ -33,7 +33,7 @@ def store_blocks(dandelion_phase: 'DandelionPhase'):
and dandelion_phase.remaining_time() > 1: and dandelion_phase.remaining_time() > 1:
try: try:
blockdb.add_block_to_db( blockdb.add_block_to_db(
new_queue.get(timeout=dandelion_phase.remaining_time() + 1) new_queue.get(timeout=dandelion_phase.remaining_time())
) )
except Empty: except Empty:
pass pass

View File

@ -31,7 +31,7 @@ def create_dirs():
"""Create onionr data-related directories in """Create onionr data-related directories in
order of the hardcoded list below, order of the hardcoded list below,
then trigger creation of DBs""" then trigger creation of DBs"""
gen_dirs = [home, gen_dirs = [home, filepaths.block_data_location,
filepaths.contacts_location, filepaths.contacts_location,
filepaths.export_location] filepaths.export_location]
for path in gen_dirs: for path in gen_dirs:

View File

@ -8,19 +8,18 @@ from torpeer import TorPeer
def on_announce_rec(api, data=None): def on_announce_rec(api, data=None):
socks_address, socks_port = get_socks()[0] socks_address, socks_port = get_socks()[0]
announced: str = data['address'] announced = data['address']
try: try:
announced = announced.decode('utf-8') announced = announced.decode('utf-8')
except AttributeError: except AttributeError:
pass pass
announced = announced.strip()
if announced.removesuffix('.onion') == config.get( if announced == config.get('tor.transport_address'):
'tor.transport_address', '').removesuffix('.onion'):
logger.warn( logger.warn(
"Received announcement for our own node, which shouldn't happen") "Received announcement for our own node, which shouldn't happen")
return return
announced = announced.strip()
if not announced.endswith('.onion'): if not announced.endswith('.onion'):
announced += '.onion' announced += '.onion'

View File

@ -71,7 +71,7 @@ class OnionrGossipClientGetNewPeers(unittest.TestCase):
def test_get_new_peers_no_peers(self): def test_get_new_peers_no_peers(self):
gossip_peer_set.clear() gossip_peer_set.clear()
get_new_peers() self.assertRaises(ValueError, get_new_peers)
self.assertFalse(len(gossip_peer_set)) self.assertFalse(len(gossip_peer_set))