From de0f57806c09db7da4df9e79acf3040d2a74df59 Mon Sep 17 00:00:00 2001 From: Frederik Lindenaar Date: Thu, 1 Aug 2019 15:55:50 +0200 Subject: [PATCH] Made autodetect explicit for updates (no more implicit autodetect) Changed the behaviour of the update command so that it would not just pick the remote address if no ip parameter was provided. To autodetect the IP address it is now mandatory to pass value auto (so ip=auto) for the ipv4addr or ipv6addr. This also allows to specify which address should be autodetected and have a static address passed for ipv4 and have the ipv6 address autodetected for multi-network systems (also closes #6) --- dyndns.pl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dyndns.pl b/dyndns.pl index 8a86293..5c02b01 100755 --- a/dyndns.pl +++ b/dyndns.pl @@ -221,11 +221,14 @@ sub handle_update($$$$$$) { } else { # Get ipv4, and ipv6 parameters my $remote_addr = $cgi->remote_addr; - my $ipv4addr = $cgi->param('ipv4addr') - || $cgi->param('ip') - || (is_ipv4($remote_addr) ? $remote_addr : undef); - my $ipv6addr = $cgi->param('ipv6addr') - || (! $ipv4addr and is_ipv6($remote_addr)) ? $remote_addr : undef; + my $ipv4addr = $cgi->param('ipv4addr') || $cgi->param('ip'); + if ($ipv4addr == 'auto') { + $ipv4addr = is_ipv4($remote_addr) ? $remote_addr : undef; + } + my $ipv6addr = $cgi->param('ipv6addr') || $cgi->param('ipv6'); + if ($ipv6addr == 'auto') { + $ipv6addr = is_ipv6($remote_addr) ? $remote_addr : undef; + } ($statuscode, $statusmessage) = DNS_Update($dnsdomain, $dnshost, $ipv4addr, $ipv6addr, $signer, $key, $debug); }