Browse Source

send created message in the clear, but encrypt prior cells

Chelsea H. Komlo 4 years ago
parent
commit
eca66df0e7
1 changed files with 7 additions and 5 deletions
  1. 7 5
      relay.py

+ 7 - 5
relay.py

@@ -204,11 +204,14 @@ class SinglePassCreatedCircuitCell(RelayCell):
     """The message for responding to circuit creation in Single-Pass Walking
     Onions."""
 
-    def __init__(self, ntor_reply, snip, vrf_output, ttl):
+    def __init__(self, ntor_reply, snip, vrf_output, ttl, encrypted_cell):
         self.ntor_reply = ntor_reply
         self.snip = snip
         self.vrf_output = vrf_output
         self.ttl = ttl
+        # the above fields are sent in plaintext, the below is encrypted
+        # information
+        self.encrypted_cell = encrypted_cell
 
 
 class EncryptedCell(RelayCell):
@@ -544,9 +547,9 @@ class SinglePassCreatedRelayHandler:
 
         # Just forward a SinglePassCreatedCircuitCell back towards the
         # client
-        circhandler.adjacent_circuit_handler.send_cell(
+        circhandler.adjacent_circuit_handler.channel_send_cell(
             SinglePassCreatedCircuitCell(cell.ntor_reply, self.next_snip,
-                self.vrf_output, self.ttl))
+                self.vrf_output, self.ttl, cell))
 
 
 class CircuitHandler:
@@ -941,7 +944,7 @@ class RelayChannelManager(ChannelManager):
             # Send the ntor reply, but no need to send the snip for the next
             # relay or vrf proof, as this is the last relay in the circuit.
             self.send_msg(CircuitCellMsg(msg.circid,
-                SinglePassCreatedCircuitCell(reply, None, None, 0)), peeraddr)
+                SinglePassCreatedCircuitCell(reply, None, None, 0, None)), peeraddr)
 
         elif isinstance(msg, SinglePassCreateCircuitMsg) and msg.ttl > 0:
             logging.debug("RelayChannelManager: Single-Pass TTL is greater than 0; extending")
@@ -974,7 +977,6 @@ class RelayChannelManager(ChannelManager):
                     self.relaypicker).get_output(idx_as_hex)
 
             next_hop = self.relaypicker.pick_relay_by_uniform_index(vrf_output.output)
-            logging.debug("WARNING: Unimplemented! Need to validate next hop is not null or ourselves, if it is, we should send a CLOSE cell.")
             if next_hop == None:
                 logging.debug("Client requested extending the circuit to a relay index that results in None, aborting. my circid: %s", str(circhandler.circid))
                 circhandler.close()