cli: route organization Internal Domains from managed config

Consume resolver.split_dns and generate a policy rule per domain, plus its
wildcard, so a suffix and its subdomains route to the OS resolver when no
resolvers are given, or to the configured resolvers when they are.

Explicit resolvers are exclusive: when all of them fail the query returns
SERVFAIL rather than taking the OS catch-all or starting recovery, and it
skips VPN split routing, which is auto-detected. Excludes and custom config
keep precedence; a refresh regenerates the config, so removals leave no
stale rule or upstream.
This commit is contained in:
Cuong Manh Le committed 2026-09-28 16:45:16 +07:00
1 parent c75989a6ee
commit 7da2507d19
10 files changed
+2175 -20

No files matched your search

+25
View File
@@ -1021,6 +1021,14 @@ func processCDFlags(ctx context.Context, cfg *ctrld.Config) (*controld.ResolverC
}
cfg.Listener["0"] = lc
// Organization Internal Domains. Applied after the Magic Folder excludes
// above, so an excluded domain keeps its exclusion, and before the
// platform AD auto-detection in addExtraSplitDnsRule, which skips any
// domain that already has a rule.
if summary := applyInternalDomains(cfg, resolverConfig.SplitDNS); !summary.empty() {
logInternalDomainsSummary(logger, summary)
}
// Set default value.
setListenerDefaultValue(cfg)
setNetworkDefaultValue(cfg)
@@ -1028,6 +1036,23 @@ func processCDFlags(ctx context.Context, cfg *ctrld.Config) (*controld.ResolverC
return resolverConfig, nil
}
// logInternalDomainsSummary reports what the Internal Domains list produced,
// as counts only. Domain names and resolver addresses are private to the
// organization and stay at debug level.
func logInternalDomainsSummary(logger zerolog.Logger, summary internalDomainsSummary) {
event := logger.Info()
if summary.skipped > 0 || summary.preempted > 0 {
event = logger.Warn()
}
event.Int("domains", summary.domains).
Int("os_resolver", summary.osMode).
Int("explicit_resolver", summary.explicit).
Int("resolvers", summary.resolvers).
Int("skipped", summary.skipped).
Int("preempted", summary.preempted).
Msg("applied organization Internal Domains")
}
// setListenerDefaultValue sets the default value for cfg.Listener if none existed.
func setListenerDefaultValue(cfg *ctrld.Config) {
if len(cfg.Listener) == 0 {