From 84474b3228fe365a297ca0c4d77ecb5d05d08fef Mon Sep 17 00:00:00 2001 From: favonia Date: Thu, 26 Sep 2024 21:41:10 -0500 Subject: [PATCH] fix(config): change `local:` to `local.iface:` --- README.markdown | 48 ++++++++++++++-------------- internal/config/env_provider.go | 6 ++-- internal/config/env_provider_test.go | 12 +++---- internal/provider/local_iface.go | 2 +- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/README.markdown b/README.markdown index 0be5195d..dd546d19 100644 --- a/README.markdown +++ b/README.markdown @@ -297,23 +297,23 @@ _(Click to expand the following items.)_
🔍 IP address providers -| Name | Meaning | Default Value | -| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -| `IP4_PROVIDER` | This specifies how to detect the current IPv4 address. Available providers include `cloudflare.doh`, `cloudflare.trace`, `local`, `local:`, `url:`, and `none`. The special `none` provider disables IPv4 completely. See below for a detailed explanation. | `cloudflare.trace` | -| `IP6_PROVIDER` | This specifies how to detect the current IPv6 address. Available providers include `cloudflare.doh`, `cloudflare.trace`, `local`, `local:`, `url:`, and `none`. The special `none` provider disables IPv6 completely. See below for a detailed explanation. | `cloudflare.trace` | +| Name | Meaning | Default Value | +| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | +| `IP4_PROVIDER` | This specifies how to detect the current IPv4 address. Available providers include `cloudflare.doh`, `cloudflare.trace`, `local`, `local.iface:`, `url:`, and `none`. The special `none` provider disables IPv4 completely. See below for a detailed explanation. | `cloudflare.trace` | +| `IP6_PROVIDER` | This specifies how to detect the current IPv6 address. Available providers include `cloudflare.doh`, `cloudflare.trace`, `local`, `local.iface:`, `url:`, and `none`. The special `none` provider disables IPv6 completely. See below for a detailed explanation. | `cloudflare.trace` | > 👉 The option `IP4_PROVIDER` governs `A`-type DNS records and IPv4 addresses in WAF lists, while the option `IP6_PROVIDER` governs `AAAA`-type DNS records and IPv6 addresses in WAF lists. The two options act independently of each other. You can specify different address providers for IPv4 and IPv6. > 📡 Available IP address providers: > -> | Provider Name | Explanation | -> | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -> | `cloudflare.doh` | Get the IP address by querying `whoami.cloudflare.` against [Cloudflare via DNS-over-HTTPS](https://developers.cloudflare.com/1.1.1.1/dns-over-https). 🤖 The updater will connect `1.1.1.1` for IPv4 and `2606:4700:4700::1111` for IPv6. Since version 1.9.3, the updater will switch to `1.0.0.1` for IPv4 if `1.1.1.1` appears to be blocked or intercepted by your ISP or your router (which is still not uncommon). Since version 1.14.0, the blockage detection uses a variant of [the Happy Eyeballs algorithm](https://en.wikipedia.org/wiki/Happy_Eyeballs) to reduce delay. | -> | `cloudflare.trace` | Get the IP address by parsing the [Cloudflare debugging page](https://one.one.one.one/cdn-cgi/trace). **This is the default provider.** 🤖 The updater will connect `1.1.1.1` for IPv4 and `2606:4700:4700::1111` for IPv6. Since version 1.9.3, the updater will switch to `1.0.0.1` for IPv4 if `1.1.1.1` appears to be blocked or intercepted by your ISP or your router (which is still not uncommon). Since version 1.14.0, the blockage detection uses a variant of [the Happy Eyeballs algorithm](https://en.wikipedia.org/wiki/Happy_Eyeballs) to reduce delay. | -> | `local` | Get the IP address via local network interfaces and routing tables. The updater will use the local address that _would have_ been used for outbound UDP connections to Cloudflare servers. (No data will be transmitted.) ⚠️ The updater needs access to the host network (such as `network_mode: host` in Docker Compose) for this provider, for otherwise the updater will detect the addresses inside [the default bridge network in Docker](https://docs.docker.com/network/bridge/) instead of those in the host network. | -> | 🧪 `local:` (since 1.15.0) | 🧪 Get the IP address via the specific local network interface `iface`. The updater will choose the first global unicast IP address of the matching IP family (IPv4 or IPv6). ⚠️ The updater needs access to the host network (such as `network_mode: host` in Docker Compose) for this provider, for otherwise the updater cannot access host network interfaces. | -> | `url:` | Fetch the IP address from a URL. The provider format is `url:` followed by the URL itself. For example, `IP4_PROVIDER=url:https://api4.ipify.org` will fetch the IPv4 address from . Since 1.15.0, the updater will enforce the matching protocol (IPv4 or IPv6) when connecting to the provided URL. Currently, only HTTP(S) is supported. | -> | `none` | Stop the DNS updating for the specified IP version completely. For example `IP4_PROVIDER=none` will disable IPv4 completely. Existing DNS records will not be removed. ⚠️ The IP addresses of the disabled IP version will be removed from WAF lists; so `IP4_PROVIDER=none` will remove all IPv4 addresses from all managed WAF lists. 🧪 As the support of WAF lists is experimental, this behavior is subject to changes and please [provide feedback](https://github.com/favonia/cloudflare-ddns/issues/new). | +> | Provider Name | Explanation | +> | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +> | `cloudflare.doh` | Get the IP address by querying `whoami.cloudflare.` against [Cloudflare via DNS-over-HTTPS](https://developers.cloudflare.com/1.1.1.1/dns-over-https). 🤖 The updater will connect `1.1.1.1` for IPv4 and `2606:4700:4700::1111` for IPv6. Since version 1.9.3, the updater will switch to `1.0.0.1` for IPv4 if `1.1.1.1` appears to be blocked or intercepted by your ISP or your router (which is still not uncommon). Since version 1.14.0, the blockage detection uses a variant of [the Happy Eyeballs algorithm](https://en.wikipedia.org/wiki/Happy_Eyeballs) to reduce delay. | +> | `cloudflare.trace` | Get the IP address by parsing the [Cloudflare debugging page](https://one.one.one.one/cdn-cgi/trace). **This is the default provider.** 🤖 The updater will connect `1.1.1.1` for IPv4 and `2606:4700:4700::1111` for IPv6. Since version 1.9.3, the updater will switch to `1.0.0.1` for IPv4 if `1.1.1.1` appears to be blocked or intercepted by your ISP or your router (which is still not uncommon). Since version 1.14.0, the blockage detection uses a variant of [the Happy Eyeballs algorithm](https://en.wikipedia.org/wiki/Happy_Eyeballs) to reduce delay. | +> | `local` | Get the IP address via local network interfaces and routing tables. The updater will use the local address that _would have_ been used for outbound UDP connections to Cloudflare servers. (No data will be transmitted.) ⚠️ The updater needs access to the host network (such as `network_mode: host` in Docker Compose) for this provider, for otherwise the updater will detect the addresses inside [the default bridge network in Docker](https://docs.docker.com/network/bridge/) instead of those in the host network. | +> | 🧪 `local.iface:` (since 1.15.0) | 🧪 Get the IP address via the specific local network interface `iface`. The updater will choose the first global unicast IP address of the matching IP family (IPv4 or IPv6). ⚠️ The updater needs access to the host network (such as `network_mode: host` in Docker Compose) for this provider, for otherwise the updater cannot access host network interfaces. | +> | `url:` | Fetch the IP address from a URL. The provider format is `url:` followed by the URL itself. For example, `IP4_PROVIDER=url:https://api4.ipify.org` will fetch the IPv4 address from . Since 1.15.0, the updater will enforce the matching protocol (IPv4 or IPv6) when connecting to the provided URL. Currently, only HTTP(S) is supported. | +> | `none` | Stop the DNS updating for the specified IP version completely. For example `IP4_PROVIDER=none` will disable IPv4 completely. Existing DNS records will not be removed. ⚠️ The IP addresses of the disabled IP version will be removed from WAF lists; so `IP4_PROVIDER=none` will remove all IPv4 addresses from all managed WAF lists. 🧪 As the support of WAF lists is experimental, this behavior is subject to changes and please [provide feedback](https://github.com/favonia/cloudflare-ddns/issues/new). |
@@ -421,18 +421,18 @@ _(Click to expand the following items.)_ ⚠️ [oznu/cloudflare-ddns](https://github.com/oznu/docker-cloudflare-ddns) relies on the insecure DNS protocol to obtain public IP addresses; a malicious hacker could more easily forge DNS responses and trick it into updating your domain with any IP address. In comparison, we use only verified responses from Cloudflare, which makes the attack much more difficult. See the [design document](docs/DESIGN.markdown) for more information on security. -| Old Parameter | | Note | -| -------------------------------------- | --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `API_KEY=key` | ✔️ | Use `CF_API_TOKEN=key` | -| `API_KEY_FILE=file` | ✔️ | Use `CF_API_TOKEN_FILE=file` | -| `ZONE=example.org` and `SUBDOMAIN=sub` | ✔️ | Use `DOMAINS=sub.example.org` directly | -| `PROXIED=true` | ✔️ | Same (`PROXIED=true`) | -| `RRTYPE=A` | ✔️ | Both IPv4 and IPv6 are enabled by default; use `IP6_PROVIDER=none` to disable IPv6 | -| `RRTYPE=AAAA` | ✔️ | Both IPv4 and IPv6 are enabled by default; use `IP4_PROVIDER=none` to disable IPv4 | -| `DELETE_ON_STOP=true` | ✔️ | Same (`DELETE_ON_STOP=true`) | -| `INTERFACE=iface` | ✔️ | To automatically select the local address, use `IP4/6_PROVIDER=local`. 🧪 To select the first address of a specific network interface, use `IP4/6_PROVIDER=local:iface` (available since 1.15.0). | -| `CUSTOM_LOOKUP_CMD=cmd` | ❌ | Custom commands are not supported because there are no other programs in the minimal Docker image | -| `DNS_SERVER=server` | ❌ | The updater only supports secure DNS queries using Cloudflare’s DNS over HTTPS (DoH) server. To enable this, set `IP4/6_PROVIDER=cloudflare.doh`. | +| Old Parameter | | Note | +| -------------------------------------- | --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `API_KEY=key` | ✔️ | Use `CF_API_TOKEN=key` | +| `API_KEY_FILE=file` | ✔️ | Use `CF_API_TOKEN_FILE=file` | +| `ZONE=example.org` and `SUBDOMAIN=sub` | ✔️ | Use `DOMAINS=sub.example.org` directly | +| `PROXIED=true` | ✔️ | Same (`PROXIED=true`) | +| `RRTYPE=A` | ✔️ | Both IPv4 and IPv6 are enabled by default; use `IP6_PROVIDER=none` to disable IPv6 | +| `RRTYPE=AAAA` | ✔️ | Both IPv4 and IPv6 are enabled by default; use `IP4_PROVIDER=none` to disable IPv4 | +| `DELETE_ON_STOP=true` | ✔️ | Same (`DELETE_ON_STOP=true`) | +| `INTERFACE=name` | ✔️ | To automatically select the local address, use `IP4/6_PROVIDER=local`. 🧪 To select the first address of a specific network interface, use `IP4/6_PROVIDER=local.iface:name` (available since 1.15.0). | +| `CUSTOM_LOOKUP_CMD=cmd` | ❌ | Custom commands are not supported because there are no other programs in the minimal Docker image | +| `DNS_SERVER=server` | ❌ | The updater only supports secure DNS queries using Cloudflare’s DNS over HTTPS (DoH) server. To enable this, set `IP4/6_PROVIDER=cloudflare.doh`. | diff --git a/internal/config/env_provider.go b/internal/config/env_provider.go index 807c0fa2..044e3170 100644 --- a/internal/config/env_provider.go +++ b/internal/config/env_provider.go @@ -113,17 +113,17 @@ func ReadProvider(ppfmt pp.PP, key, keyDeprecated string, field *provider.Provid case len(parts) == 1 && parts[0] == "local": *field = provider.NewLocal() return true - case len(parts) == 2 && parts[0] == "local": + case len(parts) == 2 && parts[0] == "local.iface": if parts[1] == "" { ppfmt.Noticef( pp.EmojiUserError, - `%s=local: must be followed by a network interface name`, + `%s=local.iface: must be followed by a network interface name`, key, ) return false } ppfmt.Hintf(pp.HintExperimentalLocalWithInterface, - `You are using the experimental provider "local:%s" added in version 1.15.0`, + `You are using the experimental provider "local.iface:%s" added in version 1.15.0`, parts[1]) *field = provider.NewLocalWithInterface(parts[1]) return true diff --git a/internal/config/env_provider_test.go b/internal/config/env_provider_test.go index 63839dcf..6e3ed068 100644 --- a/internal/config/env_provider_test.go +++ b/internal/config/env_provider_test.go @@ -155,18 +155,18 @@ func TestReadProvider(t *testing.T) { "cloudflare.doh": {true, " \tcloudflare.doh ", false, "", none, doh, true, nil}, "none": {true, " none ", false, "", trace, none, true, nil}, "local": {true, " local ", false, "", trace, local, true, nil}, - "local:lo": { - true, " local : lo ", false, "", trace, localLoopback, true, + "local.iface:lo": { + true, " local.iface : lo ", false, "", trace, localLoopback, true, func(m *mocks.MockPP) { - m.EXPECT().Hintf(pp.HintExperimentalLocalWithInterface, `You are using the experimental provider "local:%s" added in version 1.15.0`, "lo") //nolint:lll + m.EXPECT().Hintf(pp.HintExperimentalLocalWithInterface, `You are using the experimental provider "local.iface:%s" added in version 1.15.0`, "lo") //nolint:lll }, }, - "local:": { - true, " local: ", false, "", trace, trace, false, + "local.iface:": { + true, " local.iface: ", false, "", trace, trace, false, func(m *mocks.MockPP) { m.EXPECT().Noticef( pp.EmojiUserError, - `%s=local: must be followed by a network interface name`, + `%s=local.iface: must be followed by a network interface name`, key, ) }, diff --git a/internal/provider/local_iface.go b/internal/provider/local_iface.go index 2c9f5dfa..a261626d 100644 --- a/internal/provider/local_iface.go +++ b/internal/provider/local_iface.go @@ -5,7 +5,7 @@ import "github.com/favonia/cloudflare-ddns/internal/provider/protocol" // NewLocalWithInterface creates a protocol.LocalWithInterface provider. func NewLocalWithInterface(iface string) Provider { return protocol.LocalWithInterface{ - ProviderName: "local:" + iface, + ProviderName: "local.iface:" + iface, InterfaceName: iface, } }