diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2021-02-16 20:37:29 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2021-02-16 20:43:00 +0100 |
commit | 893f43705132dfeb64dd33dc8697193f463708c0 (patch) | |
tree | c3748bb28b112ef8ad2519104373b55be2bfd5a9 /examples/py-json-stdout | |
parent | 7218990e5826e4179fcb6360ef8e087fcc45467a (diff) |
Aligned nDPIsrvd.py to nDPIsrvd.h for consistency.
* Simplified Python interface as well.
* c-captured and flow-undetected-to-pcap.py produce similiar results
* Removed overloaded nDPIsrvd.py event structures.
* flow-info.py prints (with a color-hash) additional information e.g. alias/source and midstream
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'examples/py-json-stdout')
-rwxr-xr-x | examples/py-json-stdout/json-stdout.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/examples/py-json-stdout/json-stdout.py b/examples/py-json-stdout/json-stdout.py index ac94d707f..9f58d161e 100755 --- a/examples/py-json-stdout/json-stdout.py +++ b/examples/py-json-stdout/json-stdout.py @@ -8,13 +8,9 @@ import nDPIsrvd from nDPIsrvd import nDPIsrvdSocket, TermColor -def parse_json_str(json_str): - - j = nDPIsrvd.JsonParseBytes(json_str[0]) - nDPIdEvent = nDPIsrvd.nDPIdEvent.validateJsonEventTypes(j) - if nDPIdEvent.isValid is False: - raise RuntimeError('Missing event id or event name invalid in the JSON string: {}'.format(j)) - print(j) +def onJsonLineRecvd(json_dict, current_flow, global_user_data): + print(json_dict) + return True if __name__ == '__main__': argparser = nDPIsrvd.defaultArgumentParser() @@ -26,9 +22,4 @@ if __name__ == '__main__': nsock = nDPIsrvdSocket() nsock.connect(address) - - while True: - received = nsock.receive() - for received_json_pkt in received: - parse_json_str(received_json_pkt) - + nsock.loop(onJsonLineRecvd, None) |