From 12b94065d6089b833744fffc8d0fe4d4ff10c424 Mon Sep 17 00:00:00 2001 From: sonny Date: Sat, 3 May 2025 15:51:30 +0200 Subject: [PATCH 1/5] Add README file --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..3864495 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +# Transip client + +A simple command line client for updating DNS records with the Transip API. It does +so by determining the current hosts (external) IP address and accordingly updates +the records DNS for the given domain names. + +## Installation + +Installation can be done through using uv: + +``` +$ uv sync --frozen --no-dev +``` + +Or through the provided Dockerfile: + +``` +$ docker image build --tag transip-client:0.7.0 . +``` + +Optional dependencies can be installed with: + +``` +$ uv sync --frozen --no-dev --extra sentry-enabled +``` + +For docker installations optional dependencies can be installed with: + +``` +$ docker image build \ + --build-arg UV_ARGS="--extra sentry-enabled" \ + --tag transip-client:0.7.0 . +``` + +## Usage +Use the help option to show all available options: + +``` +transip-update --help +``` + + +## Configuration + +The client can be configured with the following environment variables: + +`LOGGING_CONFIG`: Specifies the path for the [logging configuration](https://docs.python.org/3.11/library/logging.html) to be used. Note that both `LOGGING_CONFIG_SRC` and `LOGGING_CONFIG_DST` can be used when building the docker image to achieve similar results. + +`VERSION`: Application version. The client will try to retrieve this through git if it is not set. + +`SENTRY_DSN`: Optionally used for specifying Sentry's DSN + +`ENVIRONMENT`: Optionally used for specifying the environment in Sentry From 654a1234585d06e6b89c4e8e707fd01384eaf0b2 Mon Sep 17 00:00:00 2001 From: sonny Date: Sat, 3 May 2025 15:53:32 +0200 Subject: [PATCH 2/5] Update version numbers --- CHANGELOG.md | 8 ++++++++ pyproject.toml | 4 ++-- uv.lock | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a419e26..9c65293 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +# 0.7.0 + +- Added different classes responsible for determining host IP +- Changed cli usage from `transip-client` to `transip-update` +- Added Dockerfile +- Added editorconfig configuration file +- Added README + # 0.6.0 - Replaced dns query usage with calling an external API diff --git a/pyproject.toml b/pyproject.toml index f9408d9..54b502c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [project] name = "transip_client" -version = "0.5.0" +version = "0.7.0" description = "Listens for changes about the current public IP and acts upon it." -authors = [{name = "Sonny", email= "sonnyba871@gmail.com"}] +authors = [{name = "Sonny"}] license = {text = "GPL-3.0"} requires-python = ">=3.11" dependencies = [ diff --git a/uv.lock b/uv.lock index bfdbe75..d42ebb4 100644 --- a/uv.lock +++ b/uv.lock @@ -270,7 +270,7 @@ wheels = [ [[package]] name = "transip-client" -version = "0.5.0" +version = "0.7.0" source = { editable = "." } dependencies = [ { name = "click", marker = "sys_platform == 'linux'" }, From 6d371c13d771add2c62f80834c04ae8652349b8e Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Sun, 4 May 2025 09:04:07 +0200 Subject: [PATCH 3/5] Use secrets module to generate token nonce --- transip_client/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transip_client/main.py b/transip_client/main.py index b451d6b..35030f7 100644 --- a/transip_client/main.py +++ b/transip_client/main.py @@ -1,9 +1,9 @@ import base64 import json import logging -import time from concurrent.futures import ThreadPoolExecutor, as_completed +from secrets import token_urlsafe from typing import Generator import requests @@ -28,7 +28,7 @@ def _get_token(private_key_path: str, login: str, api_url: str) -> str: f"{api_url}/auth", json={ "login": login, - "nonce": str(int(time.time() * 1000)), + "nonce": token_urlsafe(), "read_only": False, "expiration_time": "30 minutes", "label": "Trans IP client", From e598e8f1ed6c259299de25d3e9251b9e56fcf9b7 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Sun, 4 May 2025 09:36:32 +0200 Subject: [PATCH 4/5] Add publish CI job --- .woodpecker/publish.yaml | 12 ++++++++++++ pyproject.toml | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 .woodpecker/publish.yaml diff --git a/.woodpecker/publish.yaml b/.woodpecker/publish.yaml new file mode 100644 index 0000000..18ecb26 --- /dev/null +++ b/.woodpecker/publish.yaml @@ -0,0 +1,12 @@ +when: + - event: tag + +steps: + - name: publish package + image: ghcr.io/astral-sh/uv:python3.11-alpine + commands: + - uv build + - uv publish --index forgejo + environment: + UV_PUBLISH_TOKEN: + from_secret: publish_token diff --git a/pyproject.toml b/pyproject.toml index 54b502c..d5e3da0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,12 @@ sentry-enabled = ["sentry_sdk>=0.19.5"] [tool.setuptools.packages] find = {include = ["transip_client"]} +[[tool.uv.index]] +name = "forgejo" +url = "https://forgejo.fudiggity.nl/sonny/transip-client/packages" +publish-url = "https://forgejo.fudiggity.nl/api/packages/sonny/pypi" +explicit = true + [project.scripts] transip-update = "transip_client.cli:update" From 90f9873cadcba24947c9caa3a214c333040924c8 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Sun, 4 May 2025 09:38:28 +0200 Subject: [PATCH 5/5] Allow test jobs to be ran manually --- .woodpecker/tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker/tests.yaml b/.woodpecker/tests.yaml index e64b9d6..ba3a4ad 100644 --- a/.woodpecker/tests.yaml +++ b/.woodpecker/tests.yaml @@ -1,5 +1,6 @@ when: - event: push + - event: manual steps: - name: python tests