]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/introducer/common.py
introweb: fix connection hints for server announcements
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / introducer / common.py
index c7347971e00d090dc18d7bb4aa549c24d6a09bf5..699408ece8d6cc996103fb5dce720ee26dd94e21 100644 (file)
@@ -1,21 +1,20 @@
 
 import re, simplejson
-from foolscap.api import SturdyRef
 from allmydata.util import keyutil, base32, rrefutil
 
 def make_index(ann, key_s):
     """Return something that can be used as an index (e.g. a tuple of
     strings), such that two messages that refer to the same 'thing' will have
     the same index. This is a tuple of (service-name, signing-key, None) for
-    signed announcements, or (service-name, None, tubid) for unsigned
+    signed announcements, or (service-name, None, tubid_s) for unsigned
     announcements."""
 
     service_name = str(ann["service-name"])
     if key_s:
         return (service_name, key_s, None)
     else:
-        tubid = get_tubid_string_from_ann(ann)
-        return (service_name, None, tubid)
+        tubid_s = get_tubid_string_from_ann(ann)
+        return (service_name, None, tubid_s)
 
 def get_tubid_string_from_ann(ann):
     return get_tubid_string(str(ann.get("anonymous-storage-FURL")
@@ -101,20 +100,18 @@ class SubscriberDescriptor:
     .nickname: their self-provided nickname, or "?" (unicode)
     .version: their self-provided version (string)
     .app_versions: versions of each library they use (dict str->str)
-    .advertised_addresses: what hosts they listen on (list of strings)
     .remote_address: the external address from which they connected (string)
     .tubid: for subscribers connecting with Foolscap, their tubid (string)
     """
 
     def __init__(self, service_name, when,
                  nickname, version, app_versions,
-                 advertised_addresses, remote_address, tubid):
+                 remote_address, tubid):
         self.service_name = service_name
         self.when = when
         self.nickname = nickname
         self.version = version
         self.app_versions = app_versions
-        self.advertised_addresses = advertised_addresses
         self.remote_address = remote_address
         self.tubid = tubid
 
@@ -132,12 +129,11 @@ class AnnouncementDescriptor:
      .service_name: which service they are announcing (string)
      .version: 'my-version' portion of announcement (string)
      .nickname: their self-provided nickname, or "" (unicode)
-
-    The following attributes will be empty ([] for lists, "" for strings)
-    unless the announcement included an 'anonymous-storage-FURL'.
-
-     .advertised_addresses: which hosts they listen on (list of strings)
-     .tubid: their tubid (string)
+     .serverid: the server identifier. This is a pubkey (for V2 clients),
+                or a tubid (for V1 clients).
+     .connection_hints: where they listen (list of strings) if the
+                        announcement included a key for
+                        'anonymous-storage-FURL', else an empty list.
     """
 
     def __init__(self, when, index, canary, ann_d):
@@ -148,10 +144,10 @@ class AnnouncementDescriptor:
         self.service_name = ann_d["service-name"]
         self.version = ann_d.get("my-version", "")
         self.nickname = ann_d.get("nickname", u"")
+        (service_name, key_s, tubid_s) = index
+        self.serverid = key_s or tubid_s
         furl = ann_d.get("anonymous-storage-FURL")
         if furl:
-            self.advertised_addresses = rrefutil.hosts_for_furl(furl)
-            self.tubid = SturdyRef(furl).tubID
+            self.connection_hints = rrefutil.connection_hints_for_furl(furl)
         else:
-            self.advertised_addresses = []
-            self.tubid = ""
+            self.connection_hints = []