Skip to content

Commit

Permalink
Fix check interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Nov 12, 2024
1 parent 6a7c403 commit 64c0f52
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/sagernet/gvisor v0.0.0-20241021032506-a4324256e4a3
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a
github.com/sagernet/nftables v0.3.0-beta.4
github.com/sagernet/sing v0.6.0-alpha.5
github.com/sagernet/sing v0.6.0-alpha.6
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
golang.org/x/net v0.26.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a h1:ObwtHN2VpqE0ZN
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
github.com/sagernet/nftables v0.3.0-beta.4 h1:kbULlAwAC3jvdGAC1P5Fa3GSxVwQJibNenDW2zaXr8I=
github.com/sagernet/nftables v0.3.0-beta.4/go.mod h1:OQXAjvjNGGFxaTgVCSTRIhYB5/llyVDeapVoENYBDS8=
github.com/sagernet/sing v0.6.0-alpha.5 h1:AQHBy2It7mSefP9eaic03yymaxPA2IPsPIClLT+IM0I=
github.com/sagernet/sing v0.6.0-alpha.5/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/sagernet/sing v0.6.0-alpha.6 h1:R0abM8ZeazyAKo9d3DNxtrgW17g3tZAD8al7O5+ADOw=
github.com/sagernet/sing v0.6.0-alpha.6/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
Expand Down
2 changes: 1 addition & 1 deletion monitor_android.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (m *defaultInterfaceMonitor) checkUpdate() error {
}
m.defaultInterface.Store(newInterface)
var event int
if oldInterface == nil || oldInterface.Name != newInterface.Name || oldInterface.Index != newInterface.Index {
if oldInterface == nil || !oldInterface.Equals(*newInterface) {
event |= EventInterfaceUpdate
}
if oldVPNEnabled != m.androidVPNEnabled {
Expand Down
2 changes: 1 addition & 1 deletion monitor_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (m *defaultInterfaceMonitor) checkUpdate() error {
return E.Cause(err, "find updated interface: ", defaultInterface.Name)
}
m.defaultInterface.Store(newInterface)
if oldInterface != nil && oldInterface.Name == newInterface.Name && oldInterface.Index == newInterface.Index {
if oldInterface != nil && oldInterface.Equals(*newInterface) {
return nil
}
m.emit(EventInterfaceUpdate)
Expand Down
2 changes: 1 addition & 1 deletion monitor_linux_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (m *defaultInterfaceMonitor) checkUpdate() error {
return E.Cause(err, "find updated interface: ", link.Attrs().Name)
}
m.defaultInterface.Store(newInterface)
if oldInterface != nil && oldInterface.Name == newInterface.Name && oldInterface.Index == newInterface.Index {
if oldInterface != nil && oldInterface.Equals(*newInterface) {
return nil
}
m.emit(EventInterfaceUpdate)
Expand Down
2 changes: 1 addition & 1 deletion monitor_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (m *defaultInterfaceMonitor) checkUpdate() error {
return E.Cause(err, "find updated interface: ", alias)
}
m.defaultInterface.Store(newInterface)
if oldInterface != nil && oldInterface.Name == newInterface.Name && oldInterface.Index == newInterface.Index {
if oldInterface != nil && !oldInterface.Equals(*newInterface) {
return nil
}
m.emit(EventInterfaceUpdate)
Expand Down

0 comments on commit 64c0f52

Please sign in to comment.