From f35c49d2110c56354c8a131e32157e2d337815da Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 11 Feb 2025 17:39:53 +0000 Subject: [PATCH] net/dns: update to illarion/gonotify/v3 to fix a panic Fixes #14699 Signed-off-by: Anton --- cmd/k8s-operator/depaware.txt | 3 ++- cmd/tailscaled/depaware.txt | 3 ++- go.mod | 2 +- go.sum | 4 ++-- net/dns/direct_linux.go | 34 +++++++++++----------------------- 5 files changed, 18 insertions(+), 28 deletions(-) diff --git a/cmd/k8s-operator/depaware.txt b/cmd/k8s-operator/depaware.txt index c67a02aa2..f0d572006 100644 --- a/cmd/k8s-operator/depaware.txt +++ b/cmd/k8s-operator/depaware.txt @@ -142,7 +142,8 @@ tailscale.com/cmd/k8s-operator dependencies: (generated by github.com/tailscale/ github.com/gorilla/csrf from tailscale.com/client/web github.com/gorilla/securecookie from github.com/gorilla/csrf github.com/hdevalence/ed25519consensus from tailscale.com/clientupdate/distsign+ - L 💣 github.com/illarion/gonotify/v2 from tailscale.com/net/dns + L 💣 github.com/illarion/gonotify/v3 from tailscale.com/net/dns + L github.com/illarion/gonotify/v3/syscallf from github.com/illarion/gonotify/v3 L github.com/insomniacslk/dhcp/dhcpv4 from tailscale.com/feature/tap L github.com/insomniacslk/dhcp/iana from github.com/insomniacslk/dhcp/dhcpv4 L github.com/insomniacslk/dhcp/interfaces from github.com/insomniacslk/dhcp/dhcpv4 diff --git a/cmd/tailscaled/depaware.txt b/cmd/tailscaled/depaware.txt index 9bae28107..d19fb5c96 100644 --- a/cmd/tailscaled/depaware.txt +++ b/cmd/tailscaled/depaware.txt @@ -114,7 +114,8 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de github.com/gorilla/csrf from tailscale.com/client/web github.com/gorilla/securecookie from github.com/gorilla/csrf github.com/hdevalence/ed25519consensus from tailscale.com/clientupdate/distsign+ - L 💣 github.com/illarion/gonotify/v2 from tailscale.com/net/dns + L 💣 github.com/illarion/gonotify/v3 from tailscale.com/net/dns + L github.com/illarion/gonotify/v3/syscallf from github.com/illarion/gonotify/v3 L github.com/insomniacslk/dhcp/dhcpv4 from tailscale.com/feature/tap L github.com/insomniacslk/dhcp/iana from github.com/insomniacslk/dhcp/dhcpv4 L github.com/insomniacslk/dhcp/interfaces from github.com/insomniacslk/dhcp/dhcpv4 diff --git a/go.mod b/go.mod index 625105a86..074482479 100644 --- a/go.mod +++ b/go.mod @@ -48,7 +48,7 @@ require ( github.com/google/uuid v1.6.0 github.com/goreleaser/nfpm/v2 v2.33.1 github.com/hdevalence/ed25519consensus v0.2.0 - github.com/illarion/gonotify/v2 v2.0.3 + github.com/illarion/gonotify/v3 v3.0.2 github.com/inetaf/tcpproxy v0.0.0-20250203165043-ded522cbd03f github.com/insomniacslk/dhcp v0.0.0-20231206064809-8c70d406f6d2 github.com/jellydator/ttlcache/v3 v3.1.0 diff --git a/go.sum b/go.sum index b375d1f58..f12f5e514 100644 --- a/go.sum +++ b/go.sum @@ -554,8 +554,8 @@ github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq github.com/hugelgupf/vmtest v0.0.0-20240102225328-693afabdd27f h1:ov45/OzrJG8EKbGjn7jJZQJTN7Z1t73sFYNIRd64YlI= github.com/hugelgupf/vmtest v0.0.0-20240102225328-693afabdd27f/go.mod h1:JoDrYMZpDPYo6uH9/f6Peqms3zNNWT2XiGgioMOIGuI= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/illarion/gonotify/v2 v2.0.3 h1:B6+SKPo/0Sw8cRJh1aLzNEeNVFfzE3c6N+o+vyxM+9A= -github.com/illarion/gonotify/v2 v2.0.3/go.mod h1:38oIJTgFqupkEydkkClkbL6i5lXV/bxdH9do5TALPEE= +github.com/illarion/gonotify/v3 v3.0.2 h1:O7S6vcopHexutmpObkeWsnzMJt/r1hONIEogeVNmJMk= +github.com/illarion/gonotify/v3 v3.0.2/go.mod h1:HWGPdPe817GfvY3w7cx6zkbzNZfi3QjcBm/wgVvEL1U= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= diff --git a/net/dns/direct_linux.go b/net/dns/direct_linux.go index 20d96e2f1..8dccc5bfb 100644 --- a/net/dns/direct_linux.go +++ b/net/dns/direct_linux.go @@ -8,7 +8,7 @@ "context" "fmt" - "github.com/illarion/gonotify/v2" + "github.com/illarion/gonotify/v3" "tailscale.com/health" ) @@ -25,10 +25,6 @@ func (m *directManager) runFileWatcher() { func watchFile(ctx context.Context, dir, filename string, cb func()) error { ctx, cancel := context.WithCancel(ctx) defer cancel() - in, err := gonotify.NewInotify(ctx) - if err != nil { - return fmt.Errorf("NewInotify: %w", err) - } const events = gonotify.IN_ATTRIB | gonotify.IN_CLOSE_WRITE | @@ -37,28 +33,20 @@ func watchFile(ctx context.Context, dir, filename string, cb func()) error { gonotify.IN_MODIFY | gonotify.IN_MOVE - if err := in.AddWatch(dir, events); err != nil { - return fmt.Errorf("AddWatch: %w", err) + watcher, err := gonotify.NewDirWatcher(ctx, events, dir) + if err != nil { + return fmt.Errorf("NewDirWatcher: %w", err) } + for { - events, err := in.Read() - if ctx.Err() != nil { + select { + case event := <-watcher.C: + if event.Name == filename { + cb() + } + case <-ctx.Done(): return ctx.Err() } - if err != nil { - return fmt.Errorf("Read: %w", err) - } - var match bool - for _, ev := range events { - if ev.Name == filename { - match = true - break - } - } - if !match { - continue - } - cb() } }