|
@@ -276,7 +276,6 @@ class VanillaExtendCircuitHandler:
|
|
|
|
|
|
# Set up a handler for when the VanillaCreatedCircuitCell comes
|
|
|
# back
|
|
|
- #TODO shouldn't these be extended?
|
|
|
newcirchandler.replace_celltype_handler(
|
|
|
VanillaCreatedCircuitCell,
|
|
|
VanillaCreatedRelayHandler())
|
|
@@ -298,7 +297,6 @@ 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
|
|
@@ -307,7 +305,7 @@ class TelescopingExtendCircuitHandler:
|
|
|
# Check to make sure that we aren't extending to ourselves. If we are,
|
|
|
# close the circuit.
|
|
|
if next_snip.snipdict["idkey"] == self.current_relay_idkey:
|
|
|
- print("ERR: Client requested extending the circuit to a relay already in the path; aborting.")
|
|
|
+ print("ERR: Client requested extending the circuit to a relay already in the path; aborting. my circid: " + str(circhandler.circid))
|
|
|
circhandler.close()
|
|
|
return
|
|
|
|
|
@@ -406,15 +404,13 @@ class CircuitHandler:
|
|
|
self.adjacent_circuit_handler = None
|
|
|
# The function to call when this circuit closes
|
|
|
self.closer = lambda: self.channel.circuithandlers.pop(circid)
|
|
|
- self.is_closed = False
|
|
|
|
|
|
def close(self):
|
|
|
"""Close the circuit. Sends a CloseCell on the circuit (and its
|
|
|
adjacent circuit, if present) and closes both."""
|
|
|
adjcirchandler = self.adjacent_circuit_handler
|
|
|
self.adjacent_circuit_handler = None
|
|
|
- self.is_closed = True
|
|
|
- print("CLOSED CIRCUIT!!!!!!")
|
|
|
+ print("Log: CLosing circuit. circid: " + str(self.circid))
|
|
|
if adjcirchandler is not None:
|
|
|
adjcirchandler.adjacent_circuit_handler = None
|
|
|
self.closer()
|
|
@@ -458,6 +454,7 @@ class CircuitHandler:
|
|
|
self.circid, self.channel.peer.channelmgr.myaddr))
|
|
|
|
|
|
elif isinstance(cell, CloseCell):
|
|
|
+ print("WARNING: Received CloseCell on circuit " + str(self.circid))
|
|
|
# Forward the CloseCell (without encryption) to the
|
|
|
# adjacent circuit, if any, and close both this and the
|
|
|
# adjacent circuit
|
|
@@ -538,6 +535,10 @@ class Channel(network.Connection):
|
|
|
self.circuithandlers[circid] = circuithandler
|
|
|
return circid, circuithandler
|
|
|
|
|
|
+ def is_circuit_open(self, circid):
|
|
|
+ is_open = (circid in self.circuithandlers) and (self.circuithandlers[circid] is not None)
|
|
|
+ return is_open
|
|
|
+
|
|
|
def new_circuit_with_circid(self, circid):
|
|
|
"""Allocate a new circuit on this channel, with the circuit id
|
|
|
received from our peer. Return the new CircuitHandler"""
|
|
@@ -729,12 +730,6 @@ class RelayChannelManager(ChannelManager):
|
|
|
TelescopingExtendCircuitHandler(self.relaypicker,
|
|
|
self.idpubkey))
|
|
|
|
|
|
- # first check to make sure the circuit is still open, in case there
|
|
|
- # were any errors when creating it
|
|
|
- if circhandler.is_closed:
|
|
|
- print("CIRCUIT IS CLOSED")
|
|
|
- self.channel_send_cell(CloseCell())
|
|
|
-
|
|
|
# Send the ntor reply
|
|
|
self.send_msg(CircuitCellMsg(msg.circid,
|
|
|
TelescopingCreatedCircuitCell(reply)), peeraddr)
|