Compare commits
6 Commits
0985bd3073
...
a9f763c649
Author | SHA1 | Date | |
---|---|---|---|
a9f763c649 | |||
d9eeda3c80 | |||
335296e29d | |||
0285b95518 | |||
5f4d4aeb73 | |||
021152bcf5 |
@ -31,6 +31,31 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
docker push git.sh-edraft.de/sh-edraft.de/open-redirect-api:$(cat version.txt)
|
docker push git.sh-edraft.de/sh-edraft.de/open-redirect-api:$(cat version.txt)
|
||||||
|
|
||||||
|
build-redirector:
|
||||||
|
runs-on: [runner]
|
||||||
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
|
steps:
|
||||||
|
- name: Clone Repository
|
||||||
|
uses: https://github.com/actions/checkout@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build docker
|
||||||
|
run: |
|
||||||
|
cd api
|
||||||
|
docker build -f dockerfile_redirector -t git.sh-edraft.de/sh-edraft.de/open-redirect-redirector:$(cat ../version.txt) .
|
||||||
|
|
||||||
|
- name: Login to registry git.sh-edraft.de
|
||||||
|
uses: https://github.com/docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: git.sh-edraft.de
|
||||||
|
username: ${{ secrets.CI_USERNAME }}
|
||||||
|
password: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||||
|
|
||||||
|
- name: Push image
|
||||||
|
run: |
|
||||||
|
docker push git.sh-edraft.de/sh-edraft.de/open-redirect-redirector:$(cat version.txt)
|
||||||
|
|
||||||
build-web:
|
build-web:
|
||||||
runs-on: [runner]
|
runs-on: [runner]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
|
@ -3,10 +3,14 @@ FROM python:3.12.8-alpine
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY ./src/api/ ./api
|
||||||
COPY ./src/core/ ./core
|
COPY ./src/core/ ./core
|
||||||
COPY ./src/data/ ./data
|
COPY ./src/data/ ./data
|
||||||
|
COPY ./src/service/ ./service
|
||||||
|
|
||||||
COPY ./src/static/ ./static
|
COPY ./src/static/ ./static
|
||||||
COPY ./src/templates/ ./templates
|
COPY ./src/templates/ ./templates
|
||||||
|
|
||||||
COPY ./src/redirector.py .
|
COPY ./src/redirector.py .
|
||||||
COPY ./src/redirector .
|
COPY ./src/redirector .
|
||||||
|
|
||||||
|
@ -13,4 +13,4 @@ fi
|
|||||||
|
|
||||||
export PYTHONPATH=./:$PYTHONPATH
|
export PYTHONPATH=./:$PYTHONPATH
|
||||||
|
|
||||||
python3.12 main.py
|
python3.12 -u main.py
|
||||||
|
@ -13,4 +13,4 @@ fi
|
|||||||
|
|
||||||
export PYTHONPATH=./:$PYTHONPATH
|
export PYTHONPATH=./:$PYTHONPATH
|
||||||
|
|
||||||
python3.12 redirector.py
|
python3.12 -u redirector.py
|
||||||
|
@ -40,6 +40,8 @@ async def _handle_request(path: str):
|
|||||||
return await _handle_short_url(path, short_url)
|
return await _handle_short_url(path, short_url)
|
||||||
|
|
||||||
if short_url.loading_screen:
|
if short_url.loading_screen:
|
||||||
|
await _track_visit(short_url)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"redirect.html",
|
"redirect.html",
|
||||||
key=short_url.short_url,
|
key=short_url.short_url,
|
||||||
@ -53,6 +55,11 @@ async def _handle_short_url(path: str, short_url: ShortUrl):
|
|||||||
if path.startswith("api/"):
|
if path.startswith("api/"):
|
||||||
path = path.replace("api/", "")
|
path = path.replace("api/", "")
|
||||||
|
|
||||||
|
await _track_visit(short_url)
|
||||||
|
|
||||||
|
return _do_redirect(short_url.target_url)
|
||||||
|
|
||||||
|
async def _track_visit(short_url: ShortUrl):
|
||||||
try:
|
try:
|
||||||
await shortUrlVisitDao.create(
|
await shortUrlVisitDao.create(
|
||||||
ShortUrlVisit(0, short_url.id, request.headers.get("User-Agent"))
|
ShortUrlVisit(0, short_url.id, request.headers.get("User-Agent"))
|
||||||
@ -60,9 +67,6 @@ async def _handle_short_url(path: str, short_url: ShortUrl):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to update short url {short_url.short_url} with error", e)
|
logger.error(f"Failed to update short url {short_url.short_url} with error", e)
|
||||||
|
|
||||||
return _do_redirect(short_url.target_url)
|
|
||||||
|
|
||||||
|
|
||||||
async def _find_short_url_by_url(url: str) -> ShortUrl:
|
async def _find_short_url_by_url(url: str) -> ShortUrl:
|
||||||
return await shortUrlDao.find_single_by({ShortUrl.short_url: url})
|
return await shortUrlDao.find_single_by({ShortUrl.short_url: url})
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
0.3.1
|
1.0.4
|
Loading…
Reference in New Issue
Block a user