Skip to content

Commit 9563c5a

Browse files
authored
Merge pull request #78 from dougbw/fallthrough
add fallthrough option
2 parents d07091a + 33feaa9 commit 9563c5a

File tree

13 files changed

+219
-101
lines changed

13 files changed

+219
-101
lines changed

Corefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
password {$OMADA_PASSWORD}
88
refresh_minutes 1
99
ignore_startup_errors {$OMADA_IGNORE_STARTUP_ERRORS}
10+
fallthrough ${FALLTHROUGH_ZONES}
1011
}
1112
forward . {$UPSTREAM_DNS}
1213
}

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# docker buildx use multiplatform
1010
# docker buildx inspect --bootstrap
1111

12-
FROM --platform=$BUILDPLATFORM golang:1.24-bookworm as builder
12+
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm as builder
1313
ARG TARGETOS TARGETARCH
1414
RUN apt update
1515
RUN apt install git curl jq -y
@@ -43,4 +43,5 @@ COPY --from=builder /coredns/coredns /coredns
4343
COPY Corefile /Corefile
4444
EXPOSE 53 53/udp
4545
ENV OMADA_IGNORE_STARTUP_ERRORS=FALSE
46+
ENV FALLTHROUGH_ZONES="."
4647
ENTRYPOINT ["/coredns"]

config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type config struct {
2121
resolve_dhcp_reservations bool // resolve static 'dhcp reservations'
2222
stale_record_duration time.Duration // duration to keep serving stale records for clients no longer present in the controller)
2323
ignore_startup_errors bool // ignore any errors during the initial zone refresh
24+
fallthrough_zones *[]string // list of fallthrough zones
2425
}
2526

2627
func parse(c *caddy.Controller) (config config, err error) {
@@ -126,6 +127,13 @@ func parse(c *caddy.Controller) (config config, err error) {
126127
return config, c.ArgErr()
127128
}
128129

130+
case "fallthrough":
131+
fallthroughZones := c.RemainingArgs()
132+
config.fallthrough_zones = &fallthroughZones
133+
if err != nil {
134+
return config, c.ArgErr()
135+
}
136+
129137
default:
130138
return config, c.Errf("unknown property: %q", c.Val())
131139
}

config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestConfig(t *testing.T) {
2222
resolve_devices true
2323
resolve_dhcp_reservations true
2424
stale_record_duration 10m
25+
fallthrough
2526
}`, false},
2627

2728
// missing required property: controller url
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
. {
2+
health :8080
3+
omada {
4+
controller_url https://10.0.0.2
5+
site Home
6+
username coredns-omada
7+
password coredns-omada
8+
refresh_minutes 1
9+
fallthrough
10+
}
11+
forward . 10.0.0.1
12+
}

docs/configuration.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ Example corefiles are located [here](../corefile-examples)
77

88
## Omada plugin configuration syntax
99

10-
| Name | Required | Type | Notes |
11-
|---------------------------|----------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
12-
| controller_url || string | address of the Omada controller. Include `https://` prefix |
13-
| site || string | name of the site from the Omada controller (note this is a regex pattern) |
14-
| username || string | Omada controller username |
15-
| password || string | Omada controller password |
16-
| refresh_minutes || int | How often to refresh the zones (default 1 minute) |
17-
| refresh_login_hours || int | How often to refresh the login token (default 24 hours) |
18-
| resolve_clients || bool | Whether to resolve client addresses (default true) |
19-
| resolve_devices || bool | Whether to resolve device addresses (default true) |
20-
| resolve_dhcp_reservations || bool | Whether to resolve device addresses (default true) |
10+
| Name | Required | Type | Notes |
11+
| ------------------------- | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
12+
| controller_url || string | address of the Omada controller. Include `https://` prefix |
13+
| site || string | name of the site from the Omada controller (note this is a regex pattern) |
14+
| username || string | Omada controller username |
15+
| password || string | Omada controller password |
16+
| refresh_minutes || int | How often to refresh the zones (default 1 minute) |
17+
| refresh_login_hours || int | How often to refresh the login token (default 24 hours) |
18+
| resolve_clients || bool | Whether to resolve client addresses (default true) |
19+
| resolve_devices || bool | Whether to resolve device addresses (default true) |
20+
| resolve_dhcp_reservations || bool | Whether to resolve device addresses (default true) |
2121
| stale_record_duration || duration | How long to keep serving stale records for clients/devices which are no longer present in the Omada controller. Specified in Go time [duration](https://pkg.go.dev/time#ParseDuration) format |
22-
| ignore_startup_errors || bool | ignore connection/configuration errors to the omada controller on startup. Set this to true if you want coredns to startup even if unable to connect to omada (default false) |
23-
22+
| ignore_startup_errors || bool | ignore connection/configuration errors to the omada controller on startup. Set this to true if you want coredns to startup even if unable to connect to omada (default false) |
23+
| fallthrough [ZONES...] || []string | Whether to enable fallthrough. If fallthrough statement is present but no zone is specified then defaults to all zones, equivilent to:<br> `fallthrough .` |
2424

2525
## Credentials
2626

@@ -30,6 +30,14 @@ For this service you should create a new user in the `Admin` page of the control
3030

3131
A single Omada controller can support multiple network sites. This plugin can be configured to use multiple sites via the `site` configuration property (regex). Multiple sites can be specified using the `|` separator like this `SiteA|SiteB|SiteC` or all sites can be selected by setting it to `.*`
3232

33+
## Fallthrough behaviour
34+
35+
The `fallthrough` option controls the behaviour for records which are not found. If fallthrough is enabled then requests for records which are not found are passed to the next plugin in the chain. If fallthrough is disabled then records which are not found are returned an `NXDOMAIN` response by the coredns_omada plugin and processing stops without being passed down the plugin chain.
36+
37+
The use case for using fallthrough is to use other plugins to handle queries for the same zone as `coredns_omada` such as the [file](https://coredns.io/plugins/file/) plugin.
38+
39+
Note: prior to the fallthrough option being implemented, the default behaviour enabled fallthrough.
40+
3341
## HTTPS Verification
3442

3543
This will depend on your network and configuration, but due to the lack of a suitable internal DNS resolution you may need to disable HTTPS verification to the controller, as even if you have a valid certificate on your controller you need a valid DNS record pointing to your controller where coredns is running.

docs/getting-started.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ CoreDNS plugins need to be compiled into CoreDNS, you can follow the [build](bui
2727

2828
This guide provides three options on how to run CoreDNS:
2929

30-
- [CoreDNS binary](#coredns-binary)
31-
- [Docker container](#docker)
32-
- [Kubernetes](#kubernetes)
30+
- [CoreDNS binary](#coredns-binary)
31+
- [Docker](#docker)
32+
- [Kubernetes](#kubernetes)
3333

3434
### CoreDNS binary
3535

@@ -52,8 +52,13 @@ Note: If you do not have a valid https certificate on your controller then set t
5252
* `OMADA_PASSWORD`
5353
* `UPSTREAM_DNS`
5454

55+
The pre-built images support these optional environment variables:
56+
* `OMADA_IGNORE_STARTUP_ERRORS` = `true` | `false`
57+
* `FALLTHROUGH_ZONES` - defaults to all zones `.` to maintain previous compatibility. To disable fallthrough completely either set this a a fake zone (e.g `FALLTHROUGH_ZONES=disabled`) or mount a custom Corefile.
58+
5559
Note: If you do not have a valid https certificate on your controller then set the `OMADA_DISABLE_HTTPS_VERIFICATION` environment variable to true
5660

61+
5762
Example docker run command:
5863
```
5964
docker run \

go.mod

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module github.com/dougbw/coredns_omada
22

3-
go 1.24.0
3+
go 1.25.0
44

55
require (
6-
github.com/coredns/caddy v1.1.2-0.20241029205200-8de985351a98
7-
github.com/coredns/coredns v1.12.3
6+
github.com/coredns/caddy v1.1.4
7+
github.com/coredns/coredns v1.14.1
88
github.com/dougbw/go-omada v0.6.2
9-
github.com/go-playground/validator/v10 v10.27.0
10-
github.com/miekg/dns v1.1.68
11-
github.com/stretchr/testify v1.10.0
9+
github.com/go-playground/validator/v10 v10.30.1
10+
github.com/miekg/dns v1.1.72
11+
github.com/stretchr/testify v1.11.1
1212
)
1313

1414
require (
@@ -17,7 +17,7 @@ require (
1717
github.com/cespare/xxhash/v2 v2.3.0 // indirect
1818
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
1919
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
20-
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
20+
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
2121
github.com/go-playground/locales v0.14.1 // indirect
2222
github.com/go-playground/universal-translator v0.18.1 // indirect
2323
github.com/golang/protobuf v1.5.4 // indirect
@@ -28,21 +28,23 @@ require (
2828
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
2929
github.com/opentracing/opentracing-go v1.2.0 // indirect
3030
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
31-
github.com/prometheus/client_golang v1.23.0 // indirect
31+
github.com/prometheus/client_golang v1.23.2 // indirect
3232
github.com/prometheus/client_model v0.6.2 // indirect
33-
github.com/prometheus/common v0.65.0 // indirect
34-
github.com/prometheus/procfs v0.17.0 // indirect
35-
github.com/quic-go/quic-go v0.54.0 // indirect
33+
github.com/prometheus/common v0.67.5 // indirect
34+
github.com/prometheus/procfs v0.19.2 // indirect
35+
github.com/quic-go/qpack v0.6.0 // indirect
36+
github.com/quic-go/quic-go v0.59.0 // indirect
3637
go.uber.org/mock v0.6.0 // indirect
37-
golang.org/x/crypto v0.41.0 // indirect
38-
golang.org/x/mod v0.27.0 // indirect
39-
golang.org/x/net v0.43.0 // indirect
40-
golang.org/x/sync v0.16.0 // indirect
41-
golang.org/x/sys v0.35.0 // indirect
42-
golang.org/x/text v0.28.0 // indirect
43-
golang.org/x/tools v0.36.0 // indirect
44-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250826171959-ef028d996bc1 // indirect
45-
google.golang.org/grpc v1.75.0 // indirect
46-
google.golang.org/protobuf v1.36.8 // indirect
38+
go.yaml.in/yaml/v2 v2.4.3 // indirect
39+
golang.org/x/crypto v0.48.0 // indirect
40+
golang.org/x/mod v0.33.0 // indirect
41+
golang.org/x/net v0.50.0 // indirect
42+
golang.org/x/sync v0.19.0 // indirect
43+
golang.org/x/sys v0.41.0 // indirect
44+
golang.org/x/text v0.34.0 // indirect
45+
golang.org/x/tools v0.42.0 // indirect
46+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260217215200-42d3e9bedb6d // indirect
47+
google.golang.org/grpc v1.79.1 // indirect
48+
google.golang.org/protobuf v1.36.11 // indirect
4749
gopkg.in/yaml.v3 v3.0.1 // indirect
4850
)

0 commit comments

Comments
 (0)