Browse Source

Edits with Chelsea in Ian's office

Ian Goldberg 4 years ago
parent
commit
e898f91c91
2 changed files with 24 additions and 10 deletions
  1. 14 5
      client.py
  2. 10 5
      relay.py

+ 14 - 5
client.py

@@ -74,9 +74,12 @@ class ClientChannelManager(relay.ChannelManager):
     def get_consensus_from_fallbackrelay(self):
         """Download a fresh consensus from a random fallbackrelay."""
         fb = random.choice(network.thenetwork.getfallbackrelays())
-        if self.consensus is not None and \
-                len(self.consensus.consdict['relays']) > 0:
-            self.send_msg(relay.RelayGetConsensusDiffMsg(), fb.netaddr)
+        if network.thenetwork.womode == network.WOMode.VANILLA:
+            if self.consensus is not None and \
+                    len(self.consensus.consdict['relays']) > 0:
+                self.send_msg(relay.RelayGetConsensusDiffMsg(), fb.netaddr)
+            else:
+                self.send_msg(relay.RelayGetConsensusMsg(), fb.netaddr)
         else:
             self.send_msg(relay.RelayGetConsensusMsg(), fb.netaddr)
 
@@ -229,6 +232,9 @@ if __name__ == '__main__':
     clisent = 0
     clirecv = 0
 
+    network.thenetwork.set_wo_style(network.WOMode.TELESCOPING,
+            network.SNIPAuthMode.THRESHSIG)
+
     # Start some dirauths
     numdirauths = 9
     dirauthaddrs = []
@@ -301,8 +307,11 @@ if __name__ == '__main__':
     # Pick a bunch of bw-weighted random relays and look at the
     # distribution
     for i in range(100):
-        r = clients[0].channelmgr.relaypicker.pick_weighted_relay()
-        print("relay",r.descdict["addr"])
+        r = relays[0].channelmgr.relaypicker.pick_weighted_relay()
+        if network.thenetwork.womode == network.WOMode.VANILLA:
+            print("relay",r.descdict["addr"])
+        else:
+            print("relay",r.snipdict["addr"])
 
     relays[3].terminate()
     relaysent += relays[3].perfstats.bytes_sent

+ 10 - 5
relay.py

@@ -17,11 +17,13 @@ class RelayNetMsg(network.NetMsg):
 
 
 class RelayGetConsensusMsg(RelayNetMsg):
-    """The subclass of RelayNetMsg for fetching the consensus."""
+    """The subclass of RelayNetMsg for fetching the consensus. Sent by
+    clients to relays."""
 
 
 class RelayConsensusMsg(RelayNetMsg):
-    """The subclass of RelayNetMsg for returning the consensus."""
+    """The subclass of RelayNetMsg for returning the consensus from
+    relays to clients, in response to RelayGetConsensusMsg."""
 
     def __init__(self, consensus):
         self.consensus = consensus
@@ -29,14 +31,16 @@ class RelayConsensusMsg(RelayNetMsg):
 
 class RelayGetConsensusDiffMsg(RelayNetMsg):
     """The subclass of RelayNetMsg for fetching the consensus, if the
-    requestor already has the previous consensus."""
+    requestor already has the previous consensus. Sent by clients to
+    relays."""
 
 
 class RelayConsensusDiffMsg(RelayNetMsg):
     """The subclass of RelayNetMsg for returning the consensus, if the
     requestor already has the previous consensus.  We don't _actually_
     produce the diff at this time; we just charge fewer bytes for this
-    message."""
+    message. Sent by relays to clients in response to
+    RelayGetConsensusDiffMsg."""
 
     def __init__(self, consensus):
         self.consensus = consensus
@@ -60,7 +64,8 @@ class RelayRandomHopMsg(RelayNetMsg):
 
 
 class CircuitCellMsg(RelayNetMsg):
-    """Send a message tagged with a circuit id."""
+    """Send a message tagged with a circuit id. This is the container
+    class for all RelayCell messages."""
 
     def __init__(self, circuitid, cell):
         self.circid = circuitid