mirror of
https://github.com/SagerNet/sing-tun.git
synced 2025-04-04 04:17:39 +03:00
refactor: More interface reuse
This commit is contained in:
parent
1015c096bb
commit
355e4e81cc
8 changed files with 51 additions and 107 deletions
|
@ -51,14 +51,14 @@ func (m *defaultInterfaceMonitor) checkUpdate() error {
|
|||
return err
|
||||
}
|
||||
|
||||
oldInterface := m.defaultInterfaceName
|
||||
oldIndex := m.defaultInterfaceIndex
|
||||
|
||||
m.defaultInterfaceName = link.Attrs().Name
|
||||
m.defaultInterfaceIndex = link.Attrs().Index
|
||||
|
||||
oldInterface := m.defaultInterface.Load()
|
||||
newInterface, err := m.interfaceFinder.ByIndex(link.Attrs().Index)
|
||||
if err != nil {
|
||||
return E.Cause(err, "find updated interface: ", link.Attrs().Name)
|
||||
}
|
||||
m.defaultInterface.Store(newInterface)
|
||||
var event int
|
||||
if oldInterface != m.defaultInterfaceName || oldIndex != m.defaultInterfaceIndex {
|
||||
if oldInterface == nil || oldInterface.Name != newInterface.Name || oldInterface.Index != newInterface.Index {
|
||||
event |= EventInterfaceUpdate
|
||||
}
|
||||
if oldVPNEnabled != m.androidVPNEnabled {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue