+
+
+class Registration(misc.Object):
+ def init(self, data):
+ self.data = data
+
+ def __lt__(self, other):
+ if isinstance(other, self.__class__):
+ if isinstance(self.user, accounts.Account):
+ if isinstance(other.user, accounts.Account):
+ return self.user < other.user
+ else:
+ return self.user.name < other.user
+ else:
+ if isinstance(other.user, accounts.Account):
+ return self.user < other.user.name
+ else:
+ return self.user < other.user
+
+ return NotImplemented
+
+ def __str__(self):
+ return self.user_agent
+
+ def matches(self, filter):
+ return self.data.Endpoint == filter
+
+ @lazy_property
+ def uri(self):
+ return urllib.parse.urlparse(self.data.Uri)
+
+ @lazy_property
+ def uri_params(self):
+ params = {}
+
+ for param in self.uri.params.split(";"):
+ key, _, value = param.partition("=")
+
+ params[key] = value
+
+ return params
+
+ @property
+ def transport(self):
+ return self.uri_params.get("transport")
+
+ @lazy_property
+ def user(self):
+ return self.backend.accounts.get_by_sip_id(self.data.Endpoint) or self.data.Endpoint
+
+ @property
+ def address(self):
+ # Remove the user
+ user, _, address = self.uri.path.partition("@")
+
+ # Remove the port
+ address, _, port = address.rpartition(":")
+
+ return address
+
+ @property
+ def user_agent(self):
+ return self.data.UserAgent.replace("_", " ")
+
+ @property
+ def roundtrip(self):
+ return int(self.data.RoundtripUsec) / 1000