From 45b2af12d08c7eff064caaac2d44268711a5141a Mon Sep 17 00:00:00 2001 From: friehmaen Date: Thu, 30 Jan 2025 07:46:14 +0100 Subject: [PATCH] dns/ddclient: Add __IPV6PREFIX__ replace for custom urls if address is IPv6 --- .../app/controllers/OPNsense/DynDNS/forms/dialogAccount.xml | 1 + .../src/opnsense/scripts/ddclient/lib/account/dyndns2.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/dns/ddclient/src/opnsense/mvc/app/controllers/OPNsense/DynDNS/forms/dialogAccount.xml b/dns/ddclient/src/opnsense/mvc/app/controllers/OPNsense/DynDNS/forms/dialogAccount.xml index eb0fb768e4..60879a1eb6 100644 --- a/dns/ddclient/src/opnsense/mvc/app/controllers/OPNsense/DynDNS/forms/dialogAccount.xml +++ b/dns/ddclient/src/opnsense/mvc/app/controllers/OPNsense/DynDNS/forms/dialogAccount.xml @@ -30,6 +30,7 @@ DynDNS Server hostname or uri to use (depending on the protocol). When a URI is provided, the tag __MYIP__ will be replaced with the current detected address for this service and __HOSTNAME__ will contain the (comma separated) list of hostnames provided. + If the current address is an IPv6 the tag __IPV6PREFIX__ will be replaced with the /64 prefix of the current address. diff --git a/dns/ddclient/src/opnsense/scripts/ddclient/lib/account/dyndns2.py b/dns/ddclient/src/opnsense/scripts/ddclient/lib/account/dyndns2.py index e93d0e5abe..46331d6d94 100755 --- a/dns/ddclient/src/opnsense/scripts/ddclient/lib/account/dyndns2.py +++ b/dns/ddclient/src/opnsense/scripts/ddclient/lib/account/dyndns2.py @@ -23,6 +23,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ +import ipaddress import syslog import requests from requests.auth import HTTPBasicAuth @@ -71,6 +72,8 @@ def execute(self): url = self.settings.get('server') url = url.replace('__MYIP__', self.current_address) url = url.replace('__HOSTNAME__', self.settings.get('hostnames')) + if self.current_address.find(':') > 0: + url = url.replace('__IPV6PREFIX__', str(ipaddress.ip_network("%s/64" % self.current_address, strict=False))) req = requests.request( method=protocol, url=url,