From 893f43705132dfeb64dd33dc8697193f463708c0 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Tue, 16 Feb 2021 20:37:29 +0100 Subject: 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 --- examples/py-json-stdout/json-stdout.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'examples/py-json-stdout') 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) -- cgit v1.2.3