Suppress no network error

This commit is contained in:
世界 2022-10-26 19:24:08 +08:00
parent 488c3b75f6
commit ea5c35f62f
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -63,15 +63,16 @@ type networkAddress struct {
func NewDefaultInterfaceMonitor(networkMonitor NetworkUpdateMonitor, options DefaultInterfaceMonitorOptions) (DefaultInterfaceMonitor, error) {
return &defaultInterfaceMonitor{
options: options,
networkMonitor: networkMonitor,
options: options,
networkMonitor: networkMonitor,
defaultInterfaceIndex: -1,
}, nil
}
func (m *defaultInterfaceMonitor) Start() error {
err := m.checkUpdate()
if err != nil {
return err
m.networkMonitor.NewError(context.Background(), err)
}
m.element = m.networkMonitor.RegisterCallback(m.delayCheckUpdate)
return nil
@ -129,6 +130,9 @@ func (m *defaultInterfaceMonitor) DefaultInterfaceName(destination netip.Addr) s
}
}
}
if m.defaultInterfaceIndex == -1 {
m.checkUpdate()
}
return m.defaultInterfaceName
}
@ -140,6 +144,9 @@ func (m *defaultInterfaceMonitor) DefaultInterfaceIndex(destination netip.Addr)
}
}
}
if m.defaultInterfaceIndex == -1 {
m.checkUpdate()
}
return m.defaultInterfaceIndex
}