Browse Source

add wip handler for singlepass created cells for clients

Chelsea H. Komlo 4 years ago
parent
commit
b579bff319
1 changed files with 18 additions and 3 deletions
  1. 18 3
      client.py

+ 18 - 3
client.py

@@ -163,6 +163,19 @@ class TelescopingExtendedHandler:
         # Send the cell
         circhandler.send_cell(circextendmsg)
 
+class SinglePassCreatedHandler:
+    """A handler for SinglePassCreatedCircuitCell cells."""
+
+    def __init__(self, channelmgr, ntor, client_key):
+        self.channelmgr = channelmgr
+        self.ntor = ntor
+        self.client_key = client_key
+
+    def received_cell(self, circhandler, cell):
+        logging.debug("Received cell in SinglePassCreatedHandler")
+        sys.exit("not yet implemented")
+
+
 class ClientChannelManager(relay.ChannelManager):
     """The subclass of ChannelManager for clients."""
 
@@ -319,6 +332,11 @@ class ClientChannelManager(relay.ChannelManager):
         circcreatemsg = relay.SinglePassCreateCircuitMsg(circid, ntor_request,
                 client_key.public_key, ttl)
 
+        # Set up the reply handler
+        circhandler.replace_celltype_handler(
+                relay.SinglePassCreatedCircuitCell,
+                SinglePassCreatedHandler(self, ntor, client_key))
+
         # Send the message
         guardchannel.send_msg(circcreatemsg)
 
@@ -329,9 +347,6 @@ class ClientChannelManager(relay.ChannelManager):
             logging.debug("Circuit was already closed, not sending bytes. circid: " + str(circid))
             return None
 
-        #TODO validate the Sphinx keys on reply
-        logging.warning("Unimplemented! The client should validate the NTOR handshake using Sphinx operations here.")
-
         return circhandler