Browse Source

make sure we are not extending to a relay we just received a message from in single-pass

Chelsea H. Komlo 4 years ago
parent
commit
3171289538
1 changed files with 4 additions and 3 deletions
  1. 4 3
      relay.py

+ 4 - 3
relay.py

@@ -537,7 +537,7 @@ class SinglePassCreatedRelayHandler:
         circhandler.adjacent_circuit_handler.send_cell(
             SinglePassCreatedCircuitCell(cell.ntor_reply, self.next_snip))
 
-        sys.exit("have not yet implemented circuit handling for single-pass in relays")
+        sys.exit("ERROR ERROR have not yet implemented circuit handling for single-pass in relays")
 
 class CircuitHandler:
     """A class for managing sending and receiving encrypted cells on a
@@ -962,7 +962,9 @@ class RelayChannelManager(ChannelManager):
 
             # TODO temporary
             next_hop = None
-            while next_hop == None or next_hop.snipdict["idkey"] == self.idpubkey:
+            # make sure the next hop is not the same as ourselves or as the
+            # relay that we just received the create message from.
+            while next_hop == None or next_hop.snipdict["idkey"] == self.idpubkey or next_hop.snipdict["addr"] == peeraddr:
                 logging.debug("WARNING: Unimplemented! Need to validate next hop is not null or ourselves, if it is, we should send a CLOSE cell.")
                 idx = self.relaypicker.pick_weighted_relay_index()
                 next_hop = self.relaypicker.pick_relay_by_uniform_index(idx)
@@ -981,7 +983,6 @@ class RelayChannelManager(ChannelManager):
 
             # Add a handler for once the next relay replies to say that the
             # circuit has been created
-            # be at most one on this circuit).
             circhandler.replace_celltype_handler(
                     SinglePassCreatedCircuitCell,
                     SinglePassCreatedRelayHandler(ntorreply, next_hop, vrf_output))