diff options
Diffstat (limited to 'ejabberdrpc.py')
-rwxr-xr-x | ejabberdrpc.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/ejabberdrpc.py b/ejabberdrpc.py index 9bdfe1c..d90831b 100755 --- a/ejabberdrpc.py +++ b/ejabberdrpc.py @@ -1,6 +1,9 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- import ipaddress +import re + +from packaging import version # rfc6052: IPv6 Addressing of IPv4/IPv6 Translators nat64 = ipaddress.ip_network("64:ff9b::/96") @@ -25,6 +28,20 @@ class EjabberdMetrics: return f"{self._login['user']}@{self._login['server']}", self._login['password'] return None + @property + def _verstring(self): + if self._login is not None: + ver_str = re.compile('([1-9][0-9.-]*)') + status = self._cmd('status', {}) + + # matches + tmp = ver_str.findall(status)[0] + + # return parsed version string + return version.parse(tmp) + + return None + def _rest(self, command: str, data): import requests @@ -138,8 +155,7 @@ class EjabberdMetrics: def fetch_muc(self, vhost=None): host = "global" if vhost is not None: - version = self._cmd("status", {}) - if "19.09" in version: + if self._verstring.major > 19: host = "conference." + vhost else: host = vhost |