Allow combining autodetected and statically configured locations. fixes #754
authorDaira Hopwood <daira@jacaranda.org>
Mon, 9 Feb 2015 19:18:58 +0000 (19:18 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 9 Feb 2015 19:18:58 +0000 (19:18 +0000)
Replaces the location 'AUTO' with the autodetected IP/port combination.

Author: Chris Kerr <debdepba@dasganma.tk>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/node.py

index 710ce7d5045923dbaae3c9c94a8ac6e835e751d0..ab8722af188a937491cc24b29d76b7e7d8570862 100644 (file)
@@ -398,9 +398,16 @@ class Node(service.MultiService):
         # next time
         fileutil.write_atomically(self._portnumfile, "%d\n" % portnum, mode="")
 
-        base_location = ",".join([ "%s:%d" % (addr, portnum)
-                                   for addr in local_addresses ])
-        location = self.get_config("node", "tub.location", base_location)
+        location = self.get_config("node", "tub.location", "AUTO")
+
+        # Replace the location "AUTO" with the detected local addresses.
+        split_location = location.split(",")
+        if "AUTO" in split_location:
+            split_location.remove("AUTO")
+            split_location.extend([ "%s:%d" % (addr, portnum)
+                                    for addr in local_addresses ])
+            location = ",".join(split_location)
+
         self.log("Tub location set to %s" % location)
         self.tub.setLocation(location)