mirror of
https://github.com/fosrl/olm.git
synced 2026-02-24 22:06:42 +00:00
34
dns/platform/detect_windows.go
Normal file
34
dns/platform/detect_windows.go
Normal file
@@ -0,0 +1,34 @@
|
||||
//go:build windows
|
||||
|
||||
package dns
|
||||
|
||||
import "fmt"
|
||||
|
||||
// DetectBestConfigurator returns the Windows DNS configurator
|
||||
// guid is the network interface GUID
|
||||
func DetectBestConfigurator(guid string) (DNSConfigurator, error) {
|
||||
if guid == "" {
|
||||
return nil, fmt.Errorf("interface GUID is required for Windows")
|
||||
}
|
||||
return NewWindowsDNSConfigurator(guid)
|
||||
}
|
||||
|
||||
// GetSystemDNS returns the current system DNS servers for the given interface
|
||||
func GetSystemDNS(guid string) ([]string, error) {
|
||||
configurator, err := NewWindowsDNSConfigurator(guid)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("create configurator: %w", err)
|
||||
}
|
||||
|
||||
servers, err := configurator.GetCurrentDNS()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get current DNS: %w", err)
|
||||
}
|
||||
|
||||
var result []string
|
||||
for _, server := range servers {
|
||||
result = append(result, server.String())
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user