mirror of
https://github.com/wader/fq.git
synced 2024-12-23 13:22:58 +03:00
8e0dde03d0
This will allow passing both cli options and format options to sub decoder. Ex: pass keylog option to a tls decoder when decoding a pcap. Ex: pass decode options to a format inside a http body inside a pcap. Add ArgAs method to lookup argument based on type. This also makes the format decode function have same signature as sub decoders in the decode API. This change decode.Format a bit: DecodeFn is now just func(d *D) any DecodeInArg renamed to DefaultInArg
38 lines
770 B
Go
38 lines
770 B
Go
package bitcoin
|
|
|
|
import (
|
|
"github.com/wader/fq/format"
|
|
"github.com/wader/fq/pkg/decode"
|
|
"github.com/wader/fq/pkg/interp"
|
|
)
|
|
|
|
var bitcoinBlockFormat decode.Group
|
|
|
|
func init() {
|
|
interp.RegisterFormat(decode.Format{
|
|
Name: format.BITCOIN_BLKDAT,
|
|
Description: "Bitcoin blk.dat",
|
|
Groups: []string{format.PROBE},
|
|
Dependencies: []decode.Dependency{
|
|
{Names: []string{format.BITCOIN_BLOCK}, Group: &bitcoinBlockFormat},
|
|
},
|
|
DecodeFn: decodeBlkDat,
|
|
RootArray: true,
|
|
RootName: "blocks",
|
|
})
|
|
}
|
|
|
|
func decodeBlkDat(d *decode.D) any {
|
|
validBlocks := 0
|
|
for !d.End() {
|
|
d.FieldFormat("block", bitcoinBlockFormat, format.BitCoinBlockIn{HasHeader: true})
|
|
validBlocks++
|
|
}
|
|
|
|
if validBlocks == 0 {
|
|
d.Fatalf("no valid blocks found")
|
|
}
|
|
|
|
return nil
|
|
}
|