feat(config): add links and dns settings

- links: short names mapped to host selectors, validated against chains
  and static host names
- dns.suggest / dns.save_link: ask, always or never
- dns.domains: domain rules per name pattern (mx* -> easysahre.de)
- the wizard edits the dns settings under Resolver & cache and keeps links;
  setup.SaveTo reports to a chosen writer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-18 13:07:08 +01:00
1 parent c408d529a0
commit 5c41a5eb6f
6 files changed
+290 -6

No files matched your search

+31
View File
@@ -60,3 +60,34 @@ func (c *Config) StaticHost(name string) *StaticHost {
}
return nil
}
// Link returns the target of the link named name (case-insensitive).
func (c *Config) Link(name string) (string, bool) {
for key, target := range c.Links {
if strings.EqualFold(key, name) {
return target, true
}
}
return "", false
}
// ValidateLinks keeps link names usable as selectors and shell aliases and
// rejects chains, which could loop.
func (c *Config) ValidateLinks() error {
for name, target := range c.Links {
if !staticHostName.MatchString(name) || strings.Contains(name, "/") {
return fmt.Errorf("links: name %q must start with a letter or digit and contain only letters, digits, dots, underscores, or hyphens", name)
}
if c.StaticHost(name) != nil {
return fmt.Errorf("links: %q is also a static host", name)
}
target = strings.TrimSpace(target)
if target == "" || strings.HasPrefix(target, "-") || strings.ContainsAny(target, " \t\n\r@") {
return fmt.Errorf("links.%s: invalid target %q", name, target)
}
if _, chained := c.Link(target); chained {
return fmt.Errorf("links.%s: target %q is another link", name, target)
}
}
return nil
}