Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duckdns: add option to grab IP addresses from URLs #1077

Merged
merged 4 commits into from Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions duckdns/CHANGELOG.md
@@ -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
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
Copy link
Member Author

@scop scop Feb 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pvizeli I think adding the services here is not a good change. I specifically left them out because they do not actually work. ipv6.wtfismyip.com does not have an IPv4 address so it doesn't work at all without IPv6, and api6.ipify.org returns and IPv4 (!) address when fetched without IPv6 support: rdegges/ipify-api#43. So I think the services should not be mentioned here.


### 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
@@ -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
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