mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-30 14:01:57 -09:00
support/scripts/pkg-stats: use an unique HTTP user-agent
As requested by the gnu.org admins: " Since August 2024, we've been under DDoS attacks from common command line tools. To fix this, we would need to change the user-agent from "Python/3.11 aiohttp/3.8.4" to "buildroot.org pkg-stats" instead. " It indeed probably makes sense to use an unique user-agent string, so rework the script to do that. Signed-off-by: Peter Korsgaard <peter@korsgaard.com> Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
committed by
Julien Olivain
parent
6e88765aa1
commit
0981b4117d
@@ -42,6 +42,8 @@ RM_API_STATUS_FOUND_BY_DISTRO = 2
|
|||||||
RM_API_STATUS_FOUND_BY_PATTERN = 3
|
RM_API_STATUS_FOUND_BY_PATTERN = 3
|
||||||
RM_API_STATUS_NOT_FOUND = 4
|
RM_API_STATUS_NOT_FOUND = 4
|
||||||
|
|
||||||
|
HTTP_HEADERS = {'User-Agent': 'buildroot.org pkg-stats'}
|
||||||
|
|
||||||
|
|
||||||
class Defconfig:
|
class Defconfig:
|
||||||
def __init__(self, name, path):
|
def __init__(self, name, path):
|
||||||
@@ -469,7 +471,7 @@ async def check_url_status(session, pkg, npkgs, retry=True, verbose=False):
|
|||||||
global check_url_count
|
global check_url_count
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with session.head(pkg.url) as resp:
|
async with session.head(pkg.url, headers=HTTP_HEADERS) as resp:
|
||||||
if resp.status >= 400:
|
if resp.status >= 400:
|
||||||
pkg.status['url'] = ("error", "invalid {}".format(resp.status))
|
pkg.status['url'] = ("error", "invalid {}".format(resp.status))
|
||||||
check_url_count += 1
|
check_url_count += 1
|
||||||
@@ -526,7 +528,7 @@ def check_package_latest_version_set_status(pkg, status, version, identifier):
|
|||||||
async def check_package_get_latest_version_by_distro(session, pkg, retry=True):
|
async def check_package_get_latest_version_by_distro(session, pkg, retry=True):
|
||||||
url = "https://release-monitoring.org/api/project/Buildroot/%s" % pkg.name
|
url = "https://release-monitoring.org/api/project/Buildroot/%s" % pkg.name
|
||||||
try:
|
try:
|
||||||
async with session.get(url) as resp:
|
async with session.get(url, headers=HTTP_HEADERS) as resp:
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -553,7 +555,7 @@ async def check_package_get_latest_version_by_distro(session, pkg, retry=True):
|
|||||||
async def check_package_get_latest_version_by_guess(session, pkg, retry=True):
|
async def check_package_get_latest_version_by_guess(session, pkg, retry=True):
|
||||||
url = "https://release-monitoring.org/api/projects/?pattern=%s" % pkg.name
|
url = "https://release-monitoring.org/api/projects/?pattern=%s" % pkg.name
|
||||||
try:
|
try:
|
||||||
async with session.get(url) as resp:
|
async with session.get(url, headers=HTTP_HEADERS) as resp:
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user