Skip to content

Commit 6a7c403

Browse files
committed
Fix monitor
1 parent d105263 commit 6a7c403

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/sagernet/gvisor v0.0.0-20241021032506-a4324256e4a3
1010
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a
1111
github.com/sagernet/nftables v0.3.0-beta.4
12-
github.com/sagernet/sing v0.6.0-alpha.4
12+
github.com/sagernet/sing v0.6.0-alpha.5
1313
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
1414
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
1515
golang.org/x/net v0.26.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a h1:ObwtHN2VpqE0ZN
2222
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
2323
github.com/sagernet/nftables v0.3.0-beta.4 h1:kbULlAwAC3jvdGAC1P5Fa3GSxVwQJibNenDW2zaXr8I=
2424
github.com/sagernet/nftables v0.3.0-beta.4/go.mod h1:OQXAjvjNGGFxaTgVCSTRIhYB5/llyVDeapVoENYBDS8=
25-
github.com/sagernet/sing v0.6.0-alpha.4 h1:h9oshzhaY0ESPC9HERcXtT9MhK7Oyo/IWXVu1uIiw3Y=
26-
github.com/sagernet/sing v0.6.0-alpha.4/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
25+
github.com/sagernet/sing v0.6.0-alpha.5 h1:AQHBy2It7mSefP9eaic03yymaxPA2IPsPIClLT+IM0I=
26+
github.com/sagernet/sing v0.6.0-alpha.5/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
2727
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
2828
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
2929
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=

monitor_darwin.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,10 @@ func (m *networkUpdateMonitor) Close() error {
107107
}
108108

109109
func (m *defaultInterfaceMonitor) checkUpdate() error {
110-
err := m.interfaceFinder.Update()
111-
if err != nil {
112-
return E.Cause(err, "update interfaces")
113-
}
114-
var defaultInterface *control.Interface
110+
var (
111+
defaultInterface *control.Interface
112+
err error
113+
)
115114
if m.underNetworkExtension {
116115
defaultInterface, err = m.getDefaultInterfaceBySocket()
117116
if err != nil {

monitor_shared.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ func (m *defaultInterfaceMonitor) delayCheckUpdate() {
7474
}
7575

7676
func (m *defaultInterfaceMonitor) postCheckUpdate() {
77-
err := m.checkUpdate()
77+
err := m.interfaceFinder.Update()
78+
if err != nil {
79+
m.logger.Error("update interface: ", err)
80+
return
81+
}
82+
err = m.checkUpdate()
7883
if errors.Is(err, ErrNoRoute) {
7984
if !m.noRoute {
8085
m.noRoute = true

0 commit comments

Comments
 (0)