ddns-scripts: pass user agent string
authorClaudio Marelli <redacted>
Sat, 15 Jan 2022 09:07:30 +0000 (10:07 +0100)
committerClaudio Marelli <redacted>
Sat, 15 Jan 2022 09:07:30 +0000 (10:07 +0100)
This adds a user agent string to the wget request.

Fixes #17507

Signed-off-by: Claudio Marelli <redacted>
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh
net/ddns-scripts/samples/ddns.config_sample

index f36d11ca78e302944602bd6a67f6a954be47d760..cb345e846be538bbc6239d0f513e0f6b32c28784 100644 (file)
@@ -745,6 +745,13 @@ do_transfer() {
                # disable proxy if no set (there might be .wgetrc or .curlrc or wrong environment set)
                [ -z "$proxy" ] && __PROG="$__PROG --no-proxy"
 
+               # user agent string if provided
+               if [ -n "$user_agent" ]; then
+                       # replace single and double quotes
+                       user_agent=$(echo $user_agent | sed "s/'/ /g" | sed 's/"/ /g')
+                       __PROG="$__PROG --user-agent='$user_agent'"
+               fi
+
                __RUNPROG="$__PROG '$__URL'"    # build final command
                __PROG="GNU Wget"               # reuse for error logging
 
index a3aa7e8132c0a4fdba5c2c2654c05e125c1ce52d..46bd8abe241761c85538232d71a38343c18f9722 100644 (file)
@@ -221,6 +221,11 @@ config service "myddns"
 #      option ip_source "script"
 #      option ip_script ""
 
+       # This option can be used in combination with ip_source "web" and ip_url.
+       # It adds a given user agent string to the request.
+       # Will only be used when wget or wget-ssl is installed.
+#      option user_agent "Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/95.0"
+
        ###########
        # force_ipversion option will set the "-4" respectively "-6" parameter
        # on command line of transfer and DNS lookup program.
git clone https://git.99rst.org/PROJECT