|
@@ -275,6 +275,7 @@ class VanillaExtendCircuitHandler:
|
|
|
|
|
|
# Set up a handler for when the VanillaCreatedCircuitCell comes
|
|
|
# back
|
|
|
+ #TODO shouldn't these be extended?
|
|
|
newcirchandler.replace_celltype_handler(
|
|
|
VanillaCreatedCircuitCell,
|
|
|
VanillaCreatedRelayHandler())
|
|
@@ -295,6 +296,7 @@ class TelescopingExtendCircuitHandler:
|
|
|
def received_cell(self, circhandler, cell):
|
|
|
# Remove ourselves from handling a second
|
|
|
# TelescopingExtendCircuitCell on this circuit
|
|
|
+ print("Log: Received TelescopingExtendCircuitHandler cell")
|
|
|
circhandler.replace_celltype_handler(TelescopingExtendCircuitCell, None)
|
|
|
|
|
|
# Find the SNIP corresponding to the index sent by the client
|
|
@@ -303,15 +305,22 @@ class TelescopingExtendCircuitHandler:
|
|
|
# Allocate a new circuit id to the requested next hop
|
|
|
channelmgr = circhandler.channel.channelmgr
|
|
|
nexthopchannel = channelmgr.get_channel_to(next_snip.snipdict["addr"])
|
|
|
+ newcircid, newcirchandler = nexthopchannel.new_circuit()
|
|
|
|
|
|
- #newcircid, newcirchandler = nexthopchannel.new_circuit()
|
|
|
-
|
|
|
- sys.exit("WARNING: Unimplemented! TelescopingExtendCircuitHandler")
|
|
|
-
|
|
|
-
|
|
|
+ # Connect the existing and new circuits together
|
|
|
+ circhandler.adjacent_circuit_handler = newcirchandler
|
|
|
+ newcirchandler.adjacent_circuit_handler = circhandler
|
|
|
|
|
|
|
|
|
+ # Set up a handler for when the TelescopingCreatedCircuitCell comes
|
|
|
+ # back
|
|
|
+ newcirchandler.replace_celltype_handler(
|
|
|
+ TelescopingCreatedCircuitCell,
|
|
|
+ TelescopingCreatedRelayHandler(next_snip))
|
|
|
|
|
|
+ # Forward a TelescopingCreateCircuitMsg to the next hop
|
|
|
+ nexthopchannel.send_msg(
|
|
|
+ TelescopingCreateCircuitMsg(newcircid, cell.ntor_request))
|
|
|
|
|
|
class VanillaCreatedRelayHandler:
|
|
|
"""Handle a VanillaCreatedCircuitCell received by a _relay_ that
|
|
@@ -328,6 +337,24 @@ class VanillaCreatedRelayHandler:
|
|
|
circhandler.adjacent_circuit_handler.send_cell(
|
|
|
VanillaExtendedCircuitCell(cell.ntor_reply))
|
|
|
|
|
|
+class TelescopingCreatedRelayHandler:
|
|
|
+ """Handle a TelescopingCreatedCircuitCell received by a _relay_ that
|
|
|
+ recently received a TelescopingExtendCircuitCell from a client, and so
|
|
|
+ forwarded a TelescopingCreateCircuitCell to the next hop."""
|
|
|
+
|
|
|
+ def __init__(self, next_snip):
|
|
|
+ self.next_snip = next_snip
|
|
|
+
|
|
|
+ def received_cell(self, circhandler, cell):
|
|
|
+ print("LOG: Handle a TelescopingCreatedCircui received by a relay")
|
|
|
+ # Remove ourselves from handling a second
|
|
|
+ # VanillaCreatedCircuitCell on this circuit
|
|
|
+ circhandler.replace_celltype_handler(TelescopingCreatedCircuitCell, None)
|
|
|
+
|
|
|
+ # Just forward a TelescopingExtendedCircuitCell back towards the
|
|
|
+ # client
|
|
|
+ circhandler.adjacent_circuit_handler.send_cell(
|
|
|
+ TelescopingExtendedCircuitCell(cell.ntor_reply, self.next_snip))
|
|
|
|
|
|
class CircuitHandler:
|
|
|
"""A class for managing sending and receiving encrypted cells on a
|
|
@@ -692,8 +719,6 @@ class RelayChannelManager(ChannelManager):
|
|
|
# Send the ntor reply
|
|
|
self.send_msg(CircuitCellMsg(msg.circid,
|
|
|
TelescopingCreatedCircuitCell(reply)), peeraddr)
|
|
|
- elif isinstance(msg, TelescopingExtendCircuitMsg):
|
|
|
- sys.exit("ERR: TelescopingExtendCircuitMsg is not yet implemented ")
|
|
|
else:
|
|
|
return super().received_msg(msg, peeraddr, channel)
|
|
|
|