mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-27 12:05:26 +00:00
Apply suggestions from code review
Co-authored-by: Kristoffer Dalby <kradalby@kradalby.no>
This commit is contained in:
parent
19165a40d2
commit
41c5a0ddf5
3
app.go
3
app.go
@ -113,7 +113,8 @@ func NewHeadscale(cfg Config) (*Headscale, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if h.cfg.DNSConfig.Routes == nil { // we might have routes already from Split DNS
|
// we might have routes already from Split DNS
|
||||||
|
if h.cfg.DNSConfig.Routes == nil {
|
||||||
h.cfg.DNSConfig.Routes = make(map[string][]dnstype.Resolver)
|
h.cfg.DNSConfig.Routes = make(map[string][]dnstype.Resolver)
|
||||||
}
|
}
|
||||||
for _, d := range magicDNSDomains {
|
for _, d := range magicDNSDomains {
|
||||||
|
@ -109,9 +109,9 @@ func GetDNSConfig() (*tailcfg.DNSConfig, string) {
|
|||||||
if len(dnsConfig.Nameservers) > 0 {
|
if len(dnsConfig.Nameservers) > 0 {
|
||||||
dnsConfig.Routes = make(map[string][]dnstype.Resolver)
|
dnsConfig.Routes = make(map[string][]dnstype.Resolver)
|
||||||
restrictedDNS := viper.GetStringMapStringSlice("dns_config.restricted_nameservers")
|
restrictedDNS := viper.GetStringMapStringSlice("dns_config.restricted_nameservers")
|
||||||
for domain, resNameservers := range restrictedDNS {
|
for domain, restrictedNameservers := range restrictedDNS {
|
||||||
resResolvers := make([]dnstype.Resolver, len(resNameservers))
|
restrictedResolvers := make([]dnstype.Resolver, len(restrictedNameservers))
|
||||||
for index, nameserverStr := range resNameservers {
|
for index, nameserverStr := range restrictedNameservers {
|
||||||
nameserver, err := netaddr.ParseIP(nameserverStr)
|
nameserver, err := netaddr.ParseIP(nameserverStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
@ -119,11 +119,11 @@ func GetDNSConfig() (*tailcfg.DNSConfig, string) {
|
|||||||
Err(err).
|
Err(err).
|
||||||
Msgf("Could not parse restricted nameserver IP: %s", nameserverStr)
|
Msgf("Could not parse restricted nameserver IP: %s", nameserverStr)
|
||||||
}
|
}
|
||||||
resResolvers[index] = dnstype.Resolver{
|
restrictedResolvers[index] = dnstype.Resolver{
|
||||||
Addr: nameserver.String(),
|
Addr: nameserver.String(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dnsConfig.Routes[domain] = resResolvers
|
dnsConfig.Routes[domain] = restrictedResolvers
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Warn().
|
log.Warn().
|
||||||
|
@ -36,4 +36,4 @@ dns_config:
|
|||||||
- `domains`: Search domains to inject.
|
- `domains`: Search domains to inject.
|
||||||
- `magic_dns`: Whether to use [MagicDNS](https://tailscale.com/kb/1081/magicdns/). Only works if there is at least a nameserver defined.
|
- `magic_dns`: Whether to use [MagicDNS](https://tailscale.com/kb/1081/magicdns/). Only works if there is at least a nameserver defined.
|
||||||
- `base_domain`: Defines the base domain to create the hostnames for MagicDNS. `base_domain` must be a FQDNs, without the trailing dot. The FQDN of the hosts will be `hostname.namespace.base_domain` (e.g., _myhost.mynamespace.example.com_).
|
- `base_domain`: Defines the base domain to create the hostnames for MagicDNS. `base_domain` must be a FQDNs, without the trailing dot. The FQDN of the hosts will be `hostname.namespace.base_domain` (e.g., _myhost.mynamespace.example.com_).
|
||||||
- `restricted_nameservers`: Also known as Split DNS (see https://tailscale.com/kb/1054/dns/), list of search domains and the DNS you want to use for them.
|
- `restricted_nameservers`: Split DNS (see https://tailscale.com/kb/1054/dns/), list of search domains and the DNS to query for each one.
|
Loading…
Reference in New Issue
Block a user