From 75b6b9d83363bba6c4f1e34cea2ff2a54e79f2d6 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 14 Aug 2018 21:54:46 +0200 Subject: [PATCH 1/3] Add debug= parameter to webfinger --- little_boxes/webfinger.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/little_boxes/webfinger.py b/little_boxes/webfinger.py index 6af6224..b52e3c2 100644 --- a/little_boxes/webfinger.py +++ b/little_boxes/webfinger.py @@ -13,7 +13,9 @@ from .urlutils import check_url logger = logging.getLogger(__name__) -def webfinger(resource: str) -> Optional[Dict[str, Any]]: # noqa: C901 +def webfinger( + resource: str, debug: bool = False +) -> Optional[Dict[str, Any]]: # noqa: C901 """Mastodon-like WebFinger resolution to retrieve the activity stream Actor URL. """ logger.info(f"performing webfinger resolution for {resource}") @@ -32,7 +34,7 @@ def webfinger(resource: str) -> Optional[Dict[str, Any]]: # noqa: C901 resource = "acct:" + resource # Security check on the url (like not calling localhost) - check_url(f"https://{host}") + check_url(f"https://{host}", debug=debug) is_404 = False for i, proto in enumerate(protos): From 99e86b2aca7f80d3e49b90514d3dccfd6281ab74 Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 14 Aug 2018 22:22:55 +0200 Subject: [PATCH 2/3] Add more debug --- little_boxes/webfinger.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/little_boxes/webfinger.py b/little_boxes/webfinger.py index b52e3c2..513d151 100644 --- a/little_boxes/webfinger.py +++ b/little_boxes/webfinger.py @@ -64,8 +64,8 @@ def webfinger( return None -def get_remote_follow_template(resource: str) -> Optional[str]: - data = webfinger(resource) +def get_remote_follow_template(resource: str, debug: bool = False) -> Optional[str]: + data = webfinger(resource, debug=debug) if data is None: return None for link in data["links"]: @@ -74,13 +74,13 @@ def get_remote_follow_template(resource: str) -> Optional[str]: return None -def get_actor_url(resource: str) -> Optional[str]: +def get_actor_url(resource: strm, debug: bool = False) -> Optional[str]: """Mastodon-like WebFinger resolution to retrieve the activity stream Actor URL. Returns: the Actor URL or None if the resolution failed. """ - data = webfinger(resource) + data = webfinger(resource, debug=debug) if data is None: return None for link in data["links"]: From 3f52156c67b29ac6fcb678db9fe6722acec9a61b Mon Sep 17 00:00:00 2001 From: Dashie Date: Tue, 14 Aug 2018 22:28:32 +0200 Subject: [PATCH 3/3] Whoops typo --- little_boxes/webfinger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/little_boxes/webfinger.py b/little_boxes/webfinger.py index 513d151..6853e29 100644 --- a/little_boxes/webfinger.py +++ b/little_boxes/webfinger.py @@ -74,7 +74,7 @@ def get_remote_follow_template(resource: str, debug: bool = False) -> Optional[s return None -def get_actor_url(resource: strm, debug: bool = False) -> Optional[str]: +def get_actor_url(resource: str, debug: bool = False) -> Optional[str]: """Mastodon-like WebFinger resolution to retrieve the activity stream Actor URL. Returns: