diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2020-09-30 20:35:28 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2020-09-30 20:35:28 +0200 |
commit | 9ea078b05e1191c6879cc9bd63bdb44cc5c3aec9 (patch) | |
tree | 57c28da238bc6e7b88b818b33611d3153264436e /examples/py-flow-info/flow-info.py | |
parent | 2f7a052f436454fde1f951e7210aca64b24e1548 (diff) |
Improved python event validation with focus on readability.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'examples/py-flow-info/flow-info.py')
-rwxr-xr-x | examples/py-flow-info/flow-info.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/py-flow-info/flow-info.py b/examples/py-flow-info/flow-info.py index ca3249a3e..044d11d9b 100755 --- a/examples/py-flow-info/flow-info.py +++ b/examples/py-flow-info/flow-info.py @@ -11,7 +11,7 @@ from nDPIsrvd import nDPIsrvdSocket, TermColor def parse_json_str(json_str): j = nDPIsrvd.JsonParseBytes(json_str[0]) - nDPIdEvent = nDPIsrvd.validateJsonEventTypes(j) + nDPIdEvent = nDPIsrvd.nDPIdEvent.validateJsonEventTypes(j) if nDPIdEvent.isValid is False: raise RuntimeError('Missing flow_event_name in the JSON string: {}'.format(j)) if nDPIdEvent.FlowEventID == -1: @@ -38,7 +38,8 @@ def parse_json_str(json_str): ndpi_frisk[:-2]) if j['l3_proto'] == 'ip4': - print('{:>16}: [{:.>6}] [{}][{:.>5}] [{:.>15}]{} -> [{:.>15}]{} {}'.format(nDPIdEvent.FlowEventName, + print('{:>16}: [{:.>6}] [{}][{:.>5}] [{:.>15}]{} -> [{:.>15}]{} {}' \ + ''.format(nDPIdEvent.FlowEventPrettyName, j['flow_id'], j['l3_proto'], j['l4_proto'], j['src_ip'].lower(), '[{:.>5}]'.format(j['src_port']) if 'src_port' in j else '', @@ -46,7 +47,8 @@ def parse_json_str(json_str): '[{:.>5}]'.format(j['dst_port']) if 'dst_port' in j else '', ndpi_proto_categ)) elif j['l3_proto'] == 'ip6': - print('{:>16}: [{:.>6}] [{}][{:.>5}] [{:.>39}]{} -> [{:.>39}]{} {}'.format(nDPIdEvent.FlowEventName, + print('{:>16}: [{:.>6}] [{}][{:.>5}] [{:.>39}]{} -> [{:.>39}]{} {}' \ + ''.format(nDPIdEvent.FlowEventPrettyName, j['flow_id'], j['l3_proto'], j['l4_proto'], j['src_ip'].lower(), '[{:.>5}]'.format(j['src_port']) if 'src_port' in j else '', |