diff --git a/Dockerfile b/Dockerfile index 7cc0bf8..41640b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM alpine:3.20.0 ENV TZ=Europe/Paris +ENV DDNS_MYADDR_IP_VERSION="ipv4" ENV DDNS_MYADDR_KEY=xxxxx RUN apk update && apk add --no-cache tzdata curl wget python3 py3-pip diff --git a/root/app/ddns-myaddr.py b/root/app/ddns-myaddr.py index 64be006..f27ed34 100644 --- a/root/app/ddns-myaddr.py +++ b/root/app/ddns-myaddr.py @@ -7,12 +7,16 @@ from datetime import datetime, timedelta logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') # Variables +ip_version = os.getenv('DDNS_MYADDR_IP_VERSION') # 'ipv4' ou 'ipv6' key = os.getenv('DDNS_MYADDR_KEY') # Récupère clé check_interval = 15 * 60 # Intervalle de vérification de 15 minutes no_update_limit = timedelta(days=30) # Limite de 30 jours def get_public_ip(): - response = requests.get('https://api.ipify.org') + if ip_version == 'ipv6': + response = requests.get('https://api64.ipify.org') # Appel pour IPv6 + else: + response = requests.get('https://api.ipify.org') # Appel pour IPv4 return response.text.strip() def update_ip(ip):