src/api/events.py \
src/api/mirrors.py \
src/api/uploads.py \
- src/api/users.py
+ src/api/users.py \
+ src/api/util.py
apidir = $(pkgpythondir)/api
from . import apiv1
from . import app
from . import backend
-from .downloads import get_current_address
+from . import util
from ..distros import Distro
from ..repos import Repo
async def get_mirrorlist(
arch: str,
repo = fastapi.Depends(get_repo_from_path),
- current_address: ipaddress.IPv6Address | ipaddress.IPv4Address = fastapi.Depends(get_current_address),
+ current_address: ipaddress.IPv6Address | ipaddress.IPv4Address = \
+ fastapi.Depends(util.get_current_address),
) -> MirrorList:
# Check if we support the architecture
if not arch in pakfire.supported_arches():
from . import app
from . import backend
+from . import util
# Create a new router for all endpoints
router = fastapi.APIRouter(
},
)
-async def get_current_address(
- request: fastapi.Request
-) -> ipaddress.IPv6Address | ipaddress.IPv4Address:
- return ipaddress.ip_address(request.client.host)
-
-
@router.get("/{path:path}", include_in_schema=False)
async def get(
- path: str, current_address: ipaddress.IPv6Address | ipaddress.IPv4Address = \
- fastapi.Depends(get_current_address),
+ path: str,
+ current_address: ipaddress.IPv6Address | ipaddress.IPv4Address = \
+ fastapi.Depends(util.get_current_address),
) -> fastapi.responses.RedirectResponse:
"""
Handle any downloads
if not await backend.stat(path, stat.S_IFREG):
raise fastapi.HTTPException(404)
- print(path)
-
# Tell the clients to never cache the redirect
headers = {
"Cache-Control" : "no-store",
--- /dev/null
+###############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2025 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+import fastapi
+import ipaddress
+
+async def get_current_address(
+ request: fastapi.Request
+) -> ipaddress.IPv6Address | ipaddress.IPv4Address:
+ """
+ Returns the IP address of the client
+ """
+ return ipaddress.ip_address(request.client.host)