Skip to content

Commit

Permalink
add set element expires field (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
iwind authored Apr 21, 2023
1 parent 1510be9 commit a58e58c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion set.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ type SetElement struct {
VerdictData *expr.Verdict
// To support aging of set elements
Timeout time.Duration

// Life left of the "timeout" elements
Expires time.Duration
}

func (s *SetElement) decode() func(b []byte) error {
Expand Down Expand Up @@ -308,7 +311,9 @@ func (s *SetElement) decode() func(b []byte) error {
flags := ad.Uint32()
s.IntervalEnd = (flags & unix.NFT_SET_ELEM_INTERVAL_END) != 0
case unix.NFTA_SET_ELEM_TIMEOUT:
s.Timeout = time.Duration(time.Millisecond * time.Duration(ad.Uint64()))
s.Timeout = time.Millisecond * time.Duration(ad.Uint64())
case unix.NFTA_SET_ELEM_EXPIRATION:
s.Expires = time.Millisecond * time.Duration(ad.Uint64())
}
}
return ad.Err()
Expand Down

0 comments on commit a58e58c

Please sign in to comment.