Skip to content

Commit

Permalink
duckdns: add option to grab IP addresses from URLs (home-assistant#1077)
Browse files Browse the repository at this point in the history
* duckdns: add option to grab IP addresses from URLs

Enables use of external services instead of Duck DNS' automatic
detection, which at time of writing doesn't work with IPv6.

* Update config.json

* Update CHANGELOG.md

* Update README.md

Co-authored-by: Pascal Vizeli <[email protected]>
  • Loading branch information
scop and pvizeli authored Feb 21, 2020
1 parent dbc3c56 commit 5650cea
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions duckdns/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.12

- Add option to specify a service or URL as IPv4 and IPv6 address source

## 1.11

- Do not skip TLS security checks on Duck DNS API access
Expand Down
12 changes: 12 additions & 0 deletions duckdns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,20 @@ By default, Duck DNS will auto detect your IPv4 address and use that.
This option allows you to override the auto-detection and specify an
IPv4 address manually.

If you specify a URL here, contents of the resource it points to will be
fetched and used as the address. This enables getting the address using
a service like https://api4.ipify.org/ or https://ipv4.wtfismyip.com/text

### Option: `ipv6` (optional)

By default, Duck DNS will auto detect your IPv6 address and use that.
This option allows you to override the auto-detection and specify an
IPv6 address manually.

If you specify a URL here, contents of the resource it points to will be
fetched and used as the address. This enables getting the address using
a service like https://api6.ipify.org/ or https://ipv6.wtfismyip.com/text

### Option: `token`

The DuckDNS authentication token found at the top of the DuckDNS account landing page. The token is required to make any changes to the subdomains registered to your account.
Expand All @@ -89,6 +97,9 @@ The number of seconds to wait before updating DuckDNS subdomains and renewing Le

- To log in, DuckDNS requires a free account from any of the following services: Google, Github, Twitter, Persona or Reddit.
- A free DuckDNS account is limited to five subdomains.
- At time of writing, Duck DNS' own IPv6 autodetection
[does not actually work][duckdns-faq], but you can use the URL option
for `ipv6` to get around this, read on.

## Support

Expand All @@ -112,3 +123,4 @@ In case you've found a bug, please [open an issue on our GitHub][issue].
[issue]: https://github.com/home-assistant/hassio-addons/issues
[reddit]: https://reddit.com/r/homeassistant
[duckdns]: https://duckdns.org
[duckdns-faq]: https://www.duckdns.org/faqs.jsp
2 changes: 1 addition & 1 deletion duckdns/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Duck DNS",
"version": "1.10",
"version": "1.11",
"slug": "duckdns",
"description": "Free Dynamic DNS (DynDNS or DDNS) service with Let's Encrypt support",
"url": "https://github.com/home-assistant/hassio-addons/tree/master/duckdns",
Expand Down
6 changes: 5 additions & 1 deletion duckdns/data/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ fi

# Run duckdns
while true; do
if answer="$(curl -s "https://www.duckdns.org/update?domains=${DOMAINS}&token=${TOKEN}&ip=${IPV4}&ipv6=${IPV6}&verbose=true")"; then

[[ ${IPV4} != *:/* ]] && ipv4=${IPV4} || ipv4=$(curl -s -m 10 "${IPV4}")
[[ ${IPV6} != *:/* ]] && ipv6=${IPV6} || ipv6=$(curl -s -m 10 "${IPV6}")

if answer="$(curl -s "https://www.duckdns.org/update?domains=${DOMAINS}&token=${TOKEN}&ip=${ipv4}&ipv6=${ipv6}&verbose=true")"; then
bashio::log.info "${answer}"
else
bashio::log.warning "${answer}"
Expand Down

0 comments on commit 5650cea

Please sign in to comment.