mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 07:16:38 +00:00
Feature/dns client configuration (#563)
Added host configurators for Linux, Windows, and macOS. The host configurator will update the peer system configuration directing DNS queries according to its capabilities. Some Linux distributions don't support split (match) DNS or custom ports, and that will be reported to our management system in another PR
This commit is contained in:
25
dns/dns.go
25
dns/dns.go
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/miekg/dns"
|
||||
"golang.org/x/net/idna"
|
||||
"net"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
@@ -60,6 +61,30 @@ func (s SimpleRecord) String() string {
|
||||
return fmt.Sprintf("%s %d %s %s %s", fqdn, s.TTL, s.Class, dns.Type(s.Type).String(), s.RData)
|
||||
}
|
||||
|
||||
// Len returns the length of the RData field, based on its type
|
||||
func (s SimpleRecord) Len() uint16 {
|
||||
emptyString := s.RData == ""
|
||||
switch s.Type {
|
||||
case 1:
|
||||
if emptyString {
|
||||
return 0
|
||||
}
|
||||
return net.IPv4len
|
||||
case 5:
|
||||
if emptyString || s.RData == "." {
|
||||
return 1
|
||||
}
|
||||
return uint16(len(s.RData) + 1)
|
||||
case 28:
|
||||
if emptyString {
|
||||
return 0
|
||||
}
|
||||
return net.IPv6len
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
// GetParsedDomainLabel returns a domain label with max 59 characters,
|
||||
// parsed for old Hosts.txt requirements, and converted to ASCII and lowercase
|
||||
func GetParsedDomainLabel(name string) (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user