Compare commits

..

5 commits

Author SHA1 Message Date
90f9873cad Allow test jobs to be ran manually
All checks were successful
ci/woodpecker/push/tests Pipeline was successful
ci/woodpecker/manual/tests Pipeline was successful
2025-05-04 09:38:28 +02:00
e598e8f1ed Add publish CI job 2025-05-04 09:36:32 +02:00
6d371c13d7 Use secrets module to generate token nonce 2025-05-04 09:04:07 +02:00
654a123458 Update version numbers
All checks were successful
ci/woodpecker/push/tests Pipeline was successful
2025-05-03 15:53:32 +02:00
12b94065d6 Add README file 2025-05-03 15:51:30 +02:00
7 changed files with 85 additions and 5 deletions

12
.woodpecker/publish.yaml Normal file
View file

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

View file

@ -1,5 +1,6 @@
when: when:
- event: push - event: push
- event: manual
steps: steps:
- name: python tests - name: python tests

View file

@ -1,5 +1,13 @@
# Changelog # 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 # 0.6.0
- Replaced dns query usage with calling an external API - Replaced dns query usage with calling an external API

53
README.md Normal file
View file

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

View file

@ -1,8 +1,8 @@
[project] [project]
name = "transip_client" name = "transip_client"
version = "0.5.0" version = "0.7.0"
description = "Listens for changes about the current public IP and acts upon it." 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"} license = {text = "GPL-3.0"}
requires-python = ">=3.11" requires-python = ">=3.11"
dependencies = [ dependencies = [
@ -23,6 +23,12 @@ sentry-enabled = ["sentry_sdk>=0.19.5"]
[tool.setuptools.packages] [tool.setuptools.packages]
find = {include = ["transip_client"]} 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] [project.scripts]
transip-update = "transip_client.cli:update" transip-update = "transip_client.cli:update"

View file

@ -1,9 +1,9 @@
import base64 import base64
import json import json
import logging import logging
import time
from concurrent.futures import ThreadPoolExecutor, as_completed from concurrent.futures import ThreadPoolExecutor, as_completed
from secrets import token_urlsafe
from typing import Generator from typing import Generator
import requests import requests
@ -28,7 +28,7 @@ def _get_token(private_key_path: str, login: str, api_url: str) -> str:
f"{api_url}/auth", f"{api_url}/auth",
json={ json={
"login": login, "login": login,
"nonce": str(int(time.time() * 1000)), "nonce": token_urlsafe(),
"read_only": False, "read_only": False,
"expiration_time": "30 minutes", "expiration_time": "30 minutes",
"label": "Trans IP client", "label": "Trans IP client",

2
uv.lock generated
View file

@ -270,7 +270,7 @@ wheels = [
[[package]] [[package]]
name = "transip-client" name = "transip-client"
version = "0.5.0" version = "0.7.0"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "click", marker = "sys_platform == 'linux'" }, { name = "click", marker = "sys_platform == 'linux'" },