fix panic on nil defaultInterfaceMonitor

This commit is contained in:
Nova 2025-02-28 22:36:38 +03:30
parent e9efee0746
commit 60dc6f4528
2 changed files with 10 additions and 0 deletions

View File

@ -30,6 +30,9 @@ func HandleInterfaceChange(_ *control.Interface, _ int) {
}
func getDefaultInterfaceGuid() (string, error) {
if DefaultIfcMonitor == nil {
return "", E.New("No default interface monitor")
}
ifc := DefaultIfcMonitor.DefaultInterface()
if ifc == nil {
log.Println("Default interface is nil!")
@ -53,6 +56,9 @@ func getDefaultInterfaceGuid() (string, error) {
}
func getDefaultInterfaceLUID() (winipcfg.LUID, error) {
if DefaultIfcMonitor == nil {
return 0, E.New("No default interface monitor")
}
ifc := DefaultIfcMonitor.DefaultInterface()
if ifc == nil {
log.Println("Default interface is nil!")

View File

@ -15,6 +15,10 @@ import (
var DefaultIfcMonitor tun.DefaultInterfaceMonitor
func monitorForUnderlyingDNS(customDNS []netip.Addr) {
if DefaultIfcMonitor == nil {
log.Println("Default interface monitor not available!")
return
}
ifc := DefaultIfcMonitor.DefaultInterface()
if ifc == nil {
log.Println("Default interface is nil!")