Change server list to joinmatrix.org's
This commit is contained in:
@@ -507,33 +507,6 @@ class Backend:
|
||||
ping=sum(times) // len(times), status=PingStatus.Done,
|
||||
)
|
||||
|
||||
|
||||
def _get_homeserver_stability(
|
||||
self, logs: List[Dict[str, Any]],
|
||||
) -> Tuple[float, List[timedelta]]:
|
||||
"""Return server stability % and a list of downtime durations."""
|
||||
|
||||
stability = 100.0
|
||||
durations = []
|
||||
|
||||
for period in logs:
|
||||
started_at = datetime.fromtimestamp(period["datetime"])
|
||||
time_since_now = datetime.now() - started_at
|
||||
|
||||
if time_since_now.days > 30 or period["type"] != 1: # 1 = downtime
|
||||
continue
|
||||
|
||||
lasted_minutes = period["duration"] / 60
|
||||
durations.append(timedelta(seconds=period["duration"]))
|
||||
|
||||
stability -= (
|
||||
(lasted_minutes * stability / 1000) /
|
||||
max(1, time_since_now.days / 3)
|
||||
)
|
||||
|
||||
return (stability, durations)
|
||||
|
||||
|
||||
async def fetch_homeservers(self) -> None:
|
||||
"""Retrieve a list of public homeservers and add them to our model."""
|
||||
|
||||
@@ -557,7 +530,7 @@ class Backend:
|
||||
connector = session.connector,
|
||||
)
|
||||
|
||||
api_list = "https://publiclist.anchel.nl/publiclist.json"
|
||||
api_list = "https://joinmatrix.org/servers.json"
|
||||
try:
|
||||
response = await session.get(api_list)
|
||||
except:
|
||||
@@ -568,27 +541,19 @@ class Backend:
|
||||
coros = []
|
||||
|
||||
for server in (await response.json()):
|
||||
homeserver_url = server["homeserver"]
|
||||
homeserver_url = "https://" + server["domain"]
|
||||
|
||||
if homeserver_url.startswith("http://"): # insecure server
|
||||
if not server["open"]: # ignore closed servers
|
||||
continue
|
||||
|
||||
if not re.match(r"^https?://.+", homeserver_url):
|
||||
homeserver_url = f"https://{homeserver_url}"
|
||||
|
||||
if server["country"] == "USA":
|
||||
server["country"] = "United States"
|
||||
|
||||
stability, durations = \
|
||||
self._get_homeserver_stability(server["monitor"]["logs"])
|
||||
|
||||
self.models["homeservers"][homeserver_url] = Homeserver(
|
||||
id = homeserver_url,
|
||||
name = server["name"],
|
||||
site_url = server["url"],
|
||||
country = server["country"],
|
||||
stability = stability,
|
||||
downtimes_ms = [d.total_seconds() * 1000 for d in durations],
|
||||
site_url = server["domain"],
|
||||
country = server["jurisdiction"],
|
||||
stability = 0,
|
||||
downtimes_ms = 0,
|
||||
# austin's list doesn't have stability/downtime
|
||||
)
|
||||
|
||||
coros.append(self._ping_homeserver(session, homeserver_url))
|
||||
|
Reference in New Issue
Block a user