Browse Source

Network now has enums for the WO style and SNIP auth style

Ian Goldberg 4 years ago
parent
commit
8b47f03442
1 changed files with 19 additions and 2 deletions
  1. 19 2
      network.py

+ 19 - 2
network.py

@@ -1,6 +1,21 @@
 #!/usr/bin/env python3
 
 import random
+from enum import Enum
+
+class WOMode(Enum):
+    """The different Walking Onion modes"""
+    VANILLA     = 0  # No Walking Onions
+    TELESCOPING = 1  # Telescoping Walking Onions
+    SINGLEPASS  = 2  # Single-Pass Walking Onions
+
+
+class SNIPAuthMode(Enum):
+    """The different styles of SNIP authentication"""
+    NONE        = 0  # No SNIPs; only used for WOMode = VANILLA
+    MERKLE      = 1  # Merkle trees
+    THRESHSIG   = 2  # Threshold signatures
+
 
 class NetAddr:
     """A class representing a network address"""
@@ -26,13 +41,15 @@ class Network:
     to the network, yielding a NetAddr (network address), and clients
     can connect() to a NetAddr yielding a Connection."""
 
-    def __init__(self):
+    def __init__(self, womode, snipauthmode):
         self.servers = dict()
         self.epoch = 1
         self.epochcallbacks = []
         self.epochendingcallbacks = []
         self.dirauthkeylist = []
         self.fallbackrelays = []
+        self.womode = womode
+        self.snipauthmode = snipauthmode
 
     def printservers(self):
         """Print the list of NetAddrs bound to something."""
@@ -108,7 +125,7 @@ class Network:
         return self.fallbackrelays
 
 # The singleton instance of Network
-thenetwork = Network()
+thenetwork = Network(WOMode.VANILLA, SNIPAuthMode.NONE)
 
 # Initialize the (non-cryptographic) random seed
 random.seed(1)