Skip to content

Commit

Permalink
refactor: remove useless code (#997)
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia authored Dec 13, 2024
1 parent 6f486e1 commit e761902
Show file tree
Hide file tree
Showing 28 changed files with 108 additions and 848 deletions.
16 changes: 8 additions & 8 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,14 @@ The emoji “🧪” indicates experimental features and the emoji “🤖” in

> 👉 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.
| 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` | <p>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.)</p><p>⚠️ 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.</p> |
| 🧪 `local.iface:<iface>` (available since version 1.15.0 but not finalized until 1.16.0) | <p>🧪 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).</p><p>⚠️ 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.</p> |
| `url:<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 <https://api4.ipify.org>. Since version 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` | <p>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.</p><p>🧪 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 still experimental, this behavior is subject to changes and please [provide feedback](https://github.com/favonia/cloudflare-ddns/issues/new).</p> |
| 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). |
| `cloudflare.trace` | Get the IP address by parsing the [Cloudflare debugging page](https://api.cloudflare.com/cdn-cgi/trace). **This is the default provider.** |
| `local` | <p>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.)</p><p>⚠️ 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.</p> |
| 🧪 `local.iface:<iface>` (available since version 1.15.0 but not finalized until 1.16.0) | <p>🧪 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).</p><p>⚠️ 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.</p> |
| `url:<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 <https://api4.ipify.org>. Since version 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` | <p>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.</p><p>🧪 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 still experimental, this behavior is subject to changes and please [provide feedback](https://github.com/favonia/cloudflare-ddns/issues/new).</p> |

</details>

Expand Down
7 changes: 0 additions & 7 deletions internal/config/config_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,6 @@ func (c *Config) Normalize(ppfmt pp.PP) bool {
}
}

// Part 7: Warn about short DetectionTimeout
if c.DetectionTimeout <= provider.HappyEyeballsAlternativeDelay {
ppfmt.Noticef(pp.EmojiUserWarning,
"DETECTION_TIMEOUT=%s may be too short for trying 1.0.0.1 when 1.1.1.1 does not work", c.DetectionTimeout)
provider.Hint1111Blockage(ppfmt)
}

// Final Part: override the old values
c.Provider = providerMap
c.Proxied = proxiedMap
Expand Down
35 changes: 0 additions & 35 deletions internal/config/config_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,41 +453,6 @@ func TestNormalize(t *testing.T) {
)
},
},
"dectioctn-time-too-short": {
input: &config.Config{ //nolint:exhaustruct
UpdateOnStart: true,
Provider: map[ipnet.Type]provider.Provider{
ipnet.IP6: provider.NewCloudflareTrace(),
},
Domains: map[ipnet.Type][]domain.Domain{
ipnet.IP6: {domain.FQDN("a.b.c")},
},
ProxiedTemplate: "true",
DetectionTimeout: time.Nanosecond,
},
ok: true,
expected: &config.Config{ //nolint:exhaustruct
UpdateOnStart: true,
Provider: map[ipnet.Type]provider.Provider{
ipnet.IP6: provider.NewCloudflareTrace(),
},
Domains: map[ipnet.Type][]domain.Domain{
ipnet.IP6: {domain.FQDN("a.b.c")},
},
ProxiedTemplate: "true",
Proxied: map[domain.Domain]bool{domain.FQDN("a.b.c"): true},
DetectionTimeout: time.Nanosecond,
},
prepareMockPP: func(m *mocks.MockPP) {
gomock.InOrder(
m.EXPECT().IsShowing(pp.Info).Return(true),
m.EXPECT().Infof(pp.EmojiEnvVars, "Checking settings . . ."),
m.EXPECT().Indent().Return(m),
m.EXPECT().Noticef(pp.EmojiUserWarning, "DETECTION_TIMEOUT=%s may be too short for trying 1.0.0.1 when 1.1.1.1 does not work", time.Nanosecond),
m.EXPECT().Hintf(pp.Hint1111Blockage, "%s", provider.Hint1111BlocakageText),
)
},
},
} {
t.Run(name, func(t *testing.T) {
t.Parallel()
Expand Down
158 changes: 9 additions & 149 deletions internal/mocks/mock_provider.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e761902

Please sign in to comment.