Skip to content

Commit

Permalink
add automatic ipv6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
p0lycarpio committed Jun 16, 2023
1 parent 5cb141e commit c34d0b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ cap_add_param_vars: ""
# optional container parameters
opt_param_usage_include_env: true
opt_param_env_vars:
- { env_var: "UPDATE_BOTH", env_value: "false", desc: "Set to `true` to update IPv4 and IPv6 address. NB: use only if you have a public IPv6 address."}
- { env_var: "FORCE_IPV6", env_value: "false", desc: "Set to `true` to update IP **only** with your public IPv6 address. NB: use only if you have a public IPv6 address."}
- { env_var: "LOG_FILE", env_value: "false", desc: "Set to `true` to log to file (also need to map /config)."}
opt_param_usage_include_vols: true
opt_param_volumes:
Expand Down
12 changes: 11 additions & 1 deletion root/app/duck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ else
fi

{
RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=")
if [ "${UPDATE_BOTH}" = "true" ]; then
IPV4=$(curl -sS4 "https://ipconfig.io")
IPV6=$(curl -sS6 "https://ipconfig.io")
RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV4}&ipv6=${IPV6}")
elif [ "${FORCE_IPV6}" = "true" ]; then
IPV6=$(curl -sS6 "https://ipconfig.io")
RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV6}")
else
RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=")
fi

if [ "${RESPONSE}" = "OK" ]; then
echo "Your IP was updated at $(date)"
else
Expand Down

0 comments on commit c34d0b0

Please sign in to comment.