From 9a70560cfb16da38546c981d77a7dd8fc822409c Mon Sep 17 00:00:00 2001 From: nrbffs <38812627+nrbffs@users.noreply.github.com> Date: Sun, 17 Nov 2019 14:55:26 +0100 Subject: [PATCH] raw output: add custom fields This will include all configured custom fields in the raw output under the "custom_fields" key. --- output/raw/raw.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/output/raw/raw.go b/output/raw/raw.go index 15dad5e..bbaf82f 100644 --- a/output/raw/raw.go +++ b/output/raw/raw.go @@ -8,12 +8,13 @@ import ( // Node struct type RawNode struct { - Firstseen jsontime.Time `json:"firstseen"` - Lastseen jsontime.Time `json:"lastseen"` - Online bool `json:"online"` - Statistics *data.Statistics `json:"statistics"` - Nodeinfo *data.Nodeinfo `json:"nodeinfo"` - Neighbours *data.Neighbours `json:"neighbours"` + Firstseen jsontime.Time `json:"firstseen"` + Lastseen jsontime.Time `json:"lastseen"` + Online bool `json:"online"` + Statistics *data.Statistics `json:"statistics"` + Nodeinfo *data.Nodeinfo `json:"nodeinfo"` + Neighbours *data.Neighbours `json:"neighbours"` + CustomFields map[string]interface{} `json:"custom_fields"` } type NodeList struct { @@ -31,12 +32,13 @@ func transform(nodes *runtime.Nodes) *NodeList { for _, nodeOrigin := range nodes.List { if nodeOrigin != nil { node := &RawNode{ - Firstseen: nodeOrigin.Firstseen, - Lastseen: nodeOrigin.Lastseen, - Online: nodeOrigin.Online, - Statistics: nodeOrigin.Statistics, - Nodeinfo: nodeOrigin.Nodeinfo, - Neighbours: nodeOrigin.Neighbours, + Firstseen: nodeOrigin.Firstseen, + Lastseen: nodeOrigin.Lastseen, + Online: nodeOrigin.Online, + Statistics: nodeOrigin.Statistics, + Nodeinfo: nodeOrigin.Nodeinfo, + Neighbours: nodeOrigin.Neighbours, + CustomFields: nodeOrigin.CustomFields, } nodelist.List = append(nodelist.List, node) }