fix: unmarshaling verdicts with chain information (#106)
Before this commit: the unmarshaling of a verdict pointing to a chain fails. After this commit: the unmarshaling of a rule with a verdict pointing to a chain succeeds and the information about the chain gets put in `Verdict.Chain`. Resolves: #105 Signed-off-by: Paul Greenberg <greenpau@outlook.com>
This commit is contained in:
parent
7127d9d224
commit
c25e4f69b4
|
@ -15,6 +15,7 @@
|
|||
package expr
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
|
||||
|
@ -100,6 +101,7 @@ func (e *Verdict) unmarshal(data []byte) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ad.ByteOrder = binary.BigEndian
|
||||
for ad.Next() {
|
||||
switch ad.Type() {
|
||||
|
@ -111,7 +113,10 @@ func (e *Verdict) unmarshal(data []byte) error {
|
|||
for nestedAD.Next() {
|
||||
switch nestedAD.Type() {
|
||||
case unix.NFTA_DATA_VERDICT:
|
||||
e.Kind = VerdictKind(binaryutil.BigEndian.Uint32(nestedAD.Bytes()[4:]))
|
||||
e.Kind = VerdictKind(int32(binaryutil.BigEndian.Uint32(nestedAD.Bytes()[4:8])))
|
||||
if len(nestedAD.Bytes()) > 12 {
|
||||
e.Chain = string(bytes.Trim(nestedAD.Bytes()[12:], "\x00"))
|
||||
}
|
||||
}
|
||||
}
|
||||
if nestedAD.Err() != nil {
|
||||
|
|
Loading…
Reference in New Issue