From 3ce2caede504357519a1bff907f56e85ff952526 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Sat, 24 Jun 2023 14:43:41 +0200 Subject: [PATCH] feat: add IPv6 endpoint --- packaging/PKGBUILD | 2 +- src/netcup_dns/main.py | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packaging/PKGBUILD b/packaging/PKGBUILD index b06a56b..1e89f30 100644 --- a/packaging/PKGBUILD +++ b/packaging/PKGBUILD @@ -5,7 +5,7 @@ _name=netcup-dns pkgname="python-$_name-git" -pkgver=r16.4b5193e +pkgver=r18.0485c33 pkgrel=1 pkgdesc='update DNS records with your current external IP address using the netcup DNS API' arch=(any) diff --git a/src/netcup_dns/main.py b/src/netcup_dns/main.py index ebf5183..4660a7d 100644 --- a/src/netcup_dns/main.py +++ b/src/netcup_dns/main.py @@ -104,7 +104,11 @@ def ipv4_endpoints() -> list[str]: :return: List of services that return your external IPv4 address. """ # IPv4 only. - endpoints = ['https://checkipv4.dedyn.io', 'https://api.ipify.org', 'https://v4.ident.me/'] + endpoints = [ + 'https://checkipv4.dedyn.io', + 'https://api.ipify.org', + 'https://v4.ident.me/', + ] # Not sure if they return IPv4 addresses only. endpoints += ['https://ipinfo.io/ip', 'https://ifconfig.me/ip'] return endpoints @@ -115,11 +119,24 @@ def ipv6_endpoints() -> list[str]: :return: List of services that return your external IPv6 address. """ # IPv6 only. - endpoints = ['https://checkipv6.dedyn.io', 'https://api6.ipify.org', 'https://v6.ident.me/'] + endpoints = [ + 'https://checkipv6.dedyn.io', + 'https://api6.ipify.org', + 'https://v6.ident.me/', + 'https://ipv6.icanhazip.com', + ] # Returns either IPv4 or IPv6. - endpoints += [] + endpoints += ['https://ifconfig.co/ip'] # Not sure if they return IPv6. endpoints += ['https://ipinfo.io/ip'] + + # https://ifconfig.co + # - if it detects `curl`, only the IP is returned + # - but on a normal request, a HTML website is given + # https://ifconfig.co/ip + # - returns only the ip + # - `curl -4/-6 https://ifconfig.co/ip` -> returns IPv4/IPv6 + return endpoints