From 927ccee57dc0f56a409952b4e09ac76a77831afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 4 Jul 2024 00:07:40 +0800 Subject: [PATCH] auto-redirect: Fix nftables available check --- redirect_linux.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/redirect_linux.go b/redirect_linux.go index e5c8f27..53443dd 100644 --- a/redirect_linux.go +++ b/redirect_linux.go @@ -173,7 +173,17 @@ func (r *autoRedirect) initializeNFTables() error { return err } defer nft.CloseLasting() - _, err = nft.ListTablesOfFamily(nftables.TableFamilyIPv4) + done := make(chan struct{}) + go func() { + _, err = nft.ListTablesOfFamily(nftables.TableFamilyIPv4) + close(done) + }() + select { + case <-time.After(time.Second): + // Fix stuck on some (old?) kernels + return E.New("netlink netfilter socket timeout") + case <-done: + } if err != nil { return err }