|
|
|
|
@ -8,6 +8,7 @@ import ( |
|
|
|
|
"errors" |
|
|
|
|
"fmt" |
|
|
|
|
"net/netip" |
|
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
"tailscale.com/types/logger" |
|
|
|
|
"tailscale.com/util/dnsname" |
|
|
|
|
@ -65,6 +66,42 @@ type OSConfig struct { |
|
|
|
|
MatchDomains []dnsname.FQDN |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (o *OSConfig) WriteToBufioWriter(w *bufio.Writer) { |
|
|
|
|
if o == nil { |
|
|
|
|
w.WriteString("<nil>") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
w.WriteString("{") |
|
|
|
|
if len(o.Hosts) > 0 { |
|
|
|
|
fmt.Fprintf(w, "Hosts:%v ", o.Hosts) |
|
|
|
|
} |
|
|
|
|
if len(o.Nameservers) > 0 { |
|
|
|
|
fmt.Fprintf(w, "Nameservers:%v ", o.Nameservers) |
|
|
|
|
} |
|
|
|
|
if len(o.SearchDomains) > 0 { |
|
|
|
|
fmt.Fprintf(w, "SearchDomains:%v ", o.SearchDomains) |
|
|
|
|
} |
|
|
|
|
if len(o.MatchDomains) > 0 { |
|
|
|
|
w.WriteString("SearchDomains:[") |
|
|
|
|
sp := "" |
|
|
|
|
var numARPA int |
|
|
|
|
for _, s := range o.MatchDomains { |
|
|
|
|
if strings.HasSuffix(string(s), ".arpa.") { |
|
|
|
|
numARPA++ |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
w.WriteString(sp) |
|
|
|
|
w.WriteString(string(s)) |
|
|
|
|
sp = " " |
|
|
|
|
} |
|
|
|
|
w.WriteString("]") |
|
|
|
|
if numARPA > 0 { |
|
|
|
|
fmt.Fprintf(w, "+%darpa", numARPA) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
w.WriteString("}") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (o OSConfig) IsZero() bool { |
|
|
|
|
return len(o.Nameservers) == 0 && len(o.SearchDomains) == 0 && len(o.MatchDomains) == 0 |
|
|
|
|
} |
|
|
|
|
|