diff --git a/app/activitypub/signature.py b/app/activitypub/signature.py index 9bac1e3a..f41fb799 100644 --- a/app/activitypub/signature.py +++ b/app/activitypub/signature.py @@ -387,7 +387,7 @@ class HttpSignature: } ) - headers["User-Agent"] = 'PieFed/1.0' + headers["User-Agent"] = f'PieFed/1.0; +https://{current_app.config["SERVER_NAME"]}' # Send the request with all those headers except the pseudo one del headers["(request-target)"] diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 5ba58ff0..9404f290 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -1262,7 +1262,7 @@ def new_instance_profile_task(instance_id: int): instance.updated_at = utcnow() session.commit() - headers = {'User-Agent': 'PieFed/1.0', 'Accept': 'application/activity+json'} + headers = {'Accept': 'application/activity+json'} try: nodeinfo = get_request(f"https://{instance.domain}/.well-known/nodeinfo", headers=headers) if nodeinfo.status_code == 200: diff --git a/app/cli.py b/app/cli.py index e30bb19f..c67b21e8 100644 --- a/app/cli.py +++ b/app/cli.py @@ -232,7 +232,7 @@ def register(app): try: # Check for dormant or dead instances instances = Instance.query.filter(Instance.gone_forever == False, Instance.id != 1).all() - HEADERS = {'User-Agent': 'PieFed/1.0', 'Accept': 'application/activity+json'} + HEADERS = {'Accept': 'application/activity+json'} for instance in instances: if instance_banned(instance.domain) or instance.domain == 'flipboard.com': diff --git a/app/utils.py b/app/utils.py index 51a50137..91966a04 100644 --- a/app/utils.py +++ b/app/utils.py @@ -85,9 +85,9 @@ def getmtime(filename): def get_request(uri, params=None, headers=None) -> httpx.Response: timeout = 15 if 'washingtonpost.com' in uri else 5 # Washington Post is really slow on og:image for some reason if headers is None: - headers = {'User-Agent': 'PieFed/1.0'} + headers = {'User-Agent': f'PieFed/1.0; +https://{current_app.config["SERVER_NAME"]}'} else: - headers.update({'User-Agent': 'PieFed/1.0'}) + headers.update({'User-Agent': f'PieFed/1.0; +https://{current_app.config["SERVER_NAME"]}'}) if params and '/webfinger' in uri: payload_str = urllib.parse.urlencode(params, safe=':@') else: @@ -129,9 +129,9 @@ def get_request_instance(uri, instance: Instance, params=None, headers=None) -> # do a HEAD request to a uri, return the result def head_request(uri, params=None, headers=None) -> httpx.Response: if headers is None: - headers = {'User-Agent': 'PieFed/1.0'} + headers = {'User-Agent': f'PieFed/1.0; +https://{current_app.config["SERVER_NAME"]}'} else: - headers.update({'User-Agent': 'PieFed/1.0'}) + headers.update({'User-Agent': f'PieFed/1.0; +https://{current_app.config["SERVER_NAME"]}'}) try: response = httpx_client.head(uri, params=params, headers=headers, timeout=5, allow_redirects=True) except httpx.HTTPError as er: diff --git a/gunicorn.conf.py b/gunicorn.conf.py index 57f21872..16a591bd 100644 --- a/gunicorn.conf.py +++ b/gunicorn.conf.py @@ -13,5 +13,5 @@ worker_class = 'gevent' accesslog = '-' errorlog = '-' -max_requests = 5000 +max_requests = 500 max_requests_jitter = 50