|
@@ -93,6 +93,14 @@ class ClientChannelManager(relay.ChannelManager):
|
|
|
self.guard = self.relaypicker.pick_weighted_relay()
|
|
|
self.guardaddr = self.guard.descdict['addr']
|
|
|
|
|
|
+ self.test_guard_connection()
|
|
|
+
|
|
|
+ if self.guardaddr is not None:
|
|
|
+ break
|
|
|
+
|
|
|
+ print('chose guard=', self.guardaddr)
|
|
|
+
|
|
|
+ def test_guard_connection(self):
|
|
|
# Connect to the guard
|
|
|
try:
|
|
|
self.get_channel_to(self.guardaddr)
|
|
@@ -101,6 +109,24 @@ class ClientChannelManager(relay.ChannelManager):
|
|
|
self.guardaddr = None
|
|
|
self.guard = None
|
|
|
|
|
|
+ def ensure_guard_walking_onions(self):
|
|
|
+ """Ensure we have a channel to a guard (Walking Onions version).
|
|
|
+
|
|
|
+ For the first implementation, we assume an out-of-band mechanism
|
|
|
+ that just simply hands us a guard; we don't count the number of
|
|
|
+ operations or bandwidth as this operation in practice occurs
|
|
|
+ infrequently."""
|
|
|
+
|
|
|
+ while True:
|
|
|
+ if self.guardaddr is None:
|
|
|
+ #randomly-sample a guard
|
|
|
+ print("DANGER: Unimplemented- guard should be selected from any relays.")
|
|
|
+ self.guard = self.relaypicker.pick_weighted_relay()
|
|
|
+ # here, we have a SNIP instead of a relay descriptor
|
|
|
+ self.guardaddr = self.guard.snipdict['addr']
|
|
|
+
|
|
|
+ self.test_guard_connection()
|
|
|
+
|
|
|
if self.guardaddr is not None:
|
|
|
break
|
|
|
|
|
@@ -110,6 +136,10 @@ class ClientChannelManager(relay.ChannelManager):
|
|
|
"""Ensure that we have a channel to a guard."""
|
|
|
if network.thenetwork.womode == network.WOMode.VANILLA:
|
|
|
self.ensure_guard_vanilla()
|
|
|
+ return
|
|
|
+ # At this point, we are either in Telescoping or Single-Pass mode
|
|
|
+
|
|
|
+ self.ensure_guard_walking_onions()
|
|
|
|
|
|
def new_circuit_vanilla(self):
|
|
|
"""Create a new circuit from this client. (Vanilla Onion Routing
|