add site url to user agent

This commit is contained in:
rimu 2025-01-21 19:51:11 +13:00
parent 2baf2b3a89
commit be18f16f21
5 changed files with 8 additions and 8 deletions

View file

@ -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)"]

View file

@ -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:

View file

@ -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':

View file

@ -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:

View file

@ -13,5 +13,5 @@ worker_class = 'gevent'
accesslog = '-'
errorlog = '-'
max_requests = 5000
max_requests = 500
max_requests_jitter = 50