diff --git a/src/keria/app/agenting.py b/src/keria/app/agenting.py index 466e2658..07f1d494 100644 --- a/src/keria/app/agenting.py +++ b/src/keria/app/agenting.py @@ -7,7 +7,7 @@ import json import os from dataclasses import asdict -from urllib.parse import urlparse +from urllib.parse import urlparse, urljoin from keri import kering from keri.app.notifying import Notifier @@ -504,7 +504,6 @@ def recur(self, tyme, deeds=None): if self.queries: msg = self.queries.popleft() pre = msg["pre"] - if "sn" in msg: seqNoDo = querying.SeqNoQuerier(hby=self.hby, hab=self.agentHab, pre=pre, sn=msg["sn"]) self.extend([seqNoDo]) @@ -889,31 +888,34 @@ def on_get(req, rep, alias): if role in (kering.Roles.witness,): # Fetch URL OOBIs for all witnesses oobis = [] for wit in hab.kever.wits: - urls = hab.fetchUrls(eid=wit, scheme=kering.Schemes.http) + urls = hab.fetchUrls(eid=wit, scheme=kering.Schemes.http) or hab.fetchUrls(eid=wit, scheme=kering.Schemes.https) if not urls: raise falcon.HTTPNotFound(description=f"unable to query witness {wit}, no http endpoint") - up = urlparse(urls[kering.Schemes.http]) - oobis.append(f"http://{up.hostname}:{up.port}/oobi/{hab.pre}/witness/{wit}") + url = urls[kering.Schemes.http] if kering.Schemes.http in urls else urls[kering.Schemes.https] + up = urlparse(url) + oobis.append(urljoin(up.geturl(),f"/oobi/{hab.pre}/witness/{wit}")) res["oobis"] = oobis elif role in (kering.Roles.controller,): # Fetch any controller URL OOBIs oobis = [] - urls = hab.fetchUrls(eid=hab.pre, scheme=kering.Schemes.http) + urls = hab.fetchUrls(eid=hab.pre, scheme=kering.Schemes.http) or hab.fetchUrls(eid=hab.pre, scheme=kering.Schemes.https) if not urls: raise falcon.HTTPNotFound(description=f"unable to query controller {hab.pre}, no http endpoint") - up = urlparse(urls[kering.Schemes.http]) - oobis.append(f"http://{up.hostname}:{up.port}/oobi/{hab.pre}/controller") + url = urls[kering.Schemes.http] if kering.Schemes.http in urls else urls[kering.Schemes.https] + up = urlparse(url) + oobis.append(urljoin(up.geturl(),f"/oobi/{hab.pre}/controller")) res["oobis"] = oobis elif role in (kering.Roles.agent,): oobis = [] - roleUrls = hab.fetchRoleUrls(hab.pre, scheme=kering.Schemes.http, role=kering.Roles.agent) + roleUrls = hab.fetchRoleUrls(hab.pre, scheme=kering.Schemes.http, role=kering.Roles.agent) or hab.fetchRoleUrls(hab.pre, scheme=kering.Schemes.https, role=kering.Roles.agent) if not roleUrls: raise falcon.HTTPNotFound(description=f"unable to query controller {hab.pre}, no http endpoint") for eid, urls in roleUrls['agent'].items(): - up = urlparse(urls[kering.Schemes.http]) - oobis.append(f"http://{up.hostname}:{up.port}/oobi/{hab.pre}/agent/{eid}") + url = urls[kering.Schemes.http] if kering.Schemes.http in urls else urls[kering.Schemes.https] + up = urlparse(url) + oobis.append(urljoin(up.geturl(),f"/oobi/{hab.pre}/agent/{eid}")) res["oobis"] = oobis else: rep.status = falcon.HTTP_404 diff --git a/src/keria/app/aiding.py b/src/keria/app/aiding.py index 27f3e77d..d1a20db1 100644 --- a/src/keria/app/aiding.py +++ b/src/keria/app/aiding.py @@ -6,7 +6,7 @@ """ import json from dataclasses import asdict -from urllib.parse import urlparse +from urllib.parse import urlparse, urljoin import falcon from keri import kering @@ -641,24 +641,26 @@ def on_get(req, rep, name): if role in (kering.Roles.witness,): # Fetch URL OOBIs for all witnesses oobis = [] for wit in hab.kever.wits: - urls = hab.fetchUrls(eid=wit, scheme=kering.Schemes.http) + urls = hab.fetchUrls(eid=wit, scheme=kering.Schemes.http) or hab.fetchUrls(eid=wit, scheme=kering.Schemes.https) if not urls: raise falcon.HTTPNotFound(description=f"unable to query witness {wit}, no http endpoint") - up = urlparse(urls[kering.Schemes.http]) - oobis.append(f"{kering.Schemes.http}://{up.hostname}:{up.port}/oobi/{hab.pre}/witness/{wit}") + url = urls[kering.Schemes.http] if kering.Schemes.http in urls else urls[kering.Schemes.https] + up = urlparse(url) + oobis.append(urljoin(up.geturl(),f"/oobi/{hab.pre}/witness/{wit}")) res["oobis"] = oobis elif role in (kering.Roles.controller,): # Fetch any controller URL OOBIs oobis = [] - urls = hab.fetchUrls(eid=hab.pre, scheme=kering.Schemes.http) + urls = hab.fetchUrls(eid=hab.pre, scheme=kering.Schemes.http) or hab.fetchUrls(eid=hab.pre, scheme=kering.Schemes.https) if not urls: raise falcon.HTTPNotFound(description=f"unable to query controller {hab.pre}, no http endpoint") - up = urlparse(urls[kering.Schemes.http]) - oobis.append(f"{kering.Schemes.http}://{up.hostname}:{up.port}/oobi/{hab.pre}/controller") + url = urls[kering.Schemes.http] if kering.Schemes.http in urls else urls[kering.Schemes.https] + up = urlparse(url) + oobis.append(urljoin(up.geturl(),f"/oobi/{hab.pre}/controller")) res["oobis"] = oobis elif role in (kering.Roles.agent,): # Fetch URL OOBIs for all witnesses - roleUrls = hab.fetchRoleUrls(cid=hab.pre, role=kering.Roles.agent, scheme=kering.Schemes.http) + roleUrls = hab.fetchRoleUrls(cid=hab.pre, role=kering.Roles.agent, scheme=kering.Schemes.http) or hab.fetchRoleUrls(cid=hab.pre, role=kering.Roles.agent, scheme=kering.Schemes.https) if kering.Roles.agent not in roleUrls: raise falcon.HTTPNotFound(description=f"unable to query agent roles for {hab.pre}, no http endpoint") @@ -668,9 +670,14 @@ def on_get(req, rep, name): for agent in set(aoobis.keys()): murls = aoobis.naball(agent) for murl in murls: - for url in murl.naball(kering.Schemes.http): + urls = [] + if kering.Schemes.http in murl: + urls.extend(murl.naball(kering.Schemes.http)) + if kering.Schemes.https in murl: + urls.extend(murl.naball(kering.Schemes.https)) + for url in urls: up = urlparse(url) - oobis.append(f"{kering.Schemes.http}://{up.hostname}:{up.port}/oobi/{hab.pre}/agent/{agent}") + oobis.append(urljoin(up.geturl(),f"/oobi/{hab.pre}/agent/{agent}")) res["oobis"] = oobis else: