Skip to content

Commit

Permalink
auto-redirect: Fix nftables available check
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Jul 3, 2024
1 parent 7506027 commit 927ccee
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion redirect_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 927ccee

Please sign in to comment.