diff --git a/go.mod b/go.mod index 34c332a..a247513 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/google/nftables -go 1.17 +go 1.18 require ( github.com/mdlayher/netlink v1.7.1 diff --git a/monitor.go b/monitor.go index 2d1801e..d75fe02 100644 --- a/monitor.go +++ b/monitor.go @@ -15,6 +15,8 @@ package nftables import ( + "math" + "strings" "sync" "github.com/mdlayher/netlink" @@ -49,12 +51,12 @@ var ( monitorFlags = map[MonitorAction]map[MonitorObject]uint32{ MonitorActionAny: { MonitorObjectAny: 0xffffffff, - MonitorObjectTables: 1<>8 != netlink.HeaderType(unix.NFNL_SUBSYS_NFTABLES) { @@ -256,12 +271,13 @@ func (monitor *Monitor) monitor() { func (monitor *Monitor) Close() { monitor.mu.Lock() + defer monitor.mu.Unlock() + if monitor.status != monitorClosed { monitor.status = monitorClosed monitor.closer() close(monitor.eventCh) } - monitor.mu.Unlock() } // AddMonitor to perform the monitor immediately. The channel will be closed after