From dfa3768e812c651e40c0e87e05c104768c9cd779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Mon, 16 Sep 2019 17:19:07 +0200 Subject: [PATCH] log-to-scs: remove stream management nonzas by default --- utils/log-to-scs.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/utils/log-to-scs.py b/utils/log-to-scs.py index d077dcd6..c8dc4098 100644 --- a/utils/log-to-scs.py +++ b/utils/log-to-scs.py @@ -48,6 +48,14 @@ ) +SM_TAGS = [ + "{urn:xmpp:sm:3}a", + "{urn:xmpp:sm:3}r", + "{urn:xmpp:sm:3}enable", + "{urn:xmpp:sm:3}enabled" +] + + def _parse_stream_bytes(b): FOOTER = b"" b = ast.literal_eval(b) @@ -124,6 +132,19 @@ def xmllines(tree): return [line for line in lines if line.strip()] +def filter_sm(actions): + for action in actions: + xml = action.get("sent", action.get("recv")) + if xml is None: + yield action + continue + + if xml["xml"].tag in SM_TAGS: + continue + + yield action + + def filter_sessions(actions): ids_to_drop = set() for action in actions: @@ -274,6 +295,13 @@ def bind_client(client_id, jid): default=[], const=filter_serverdisco, ) + parser.add_argument( + "--no-strip-stream-management", + action="append_const", + dest="remove_filters", + default=[], + const=filter_sm, + ) parser.add_argument( "--no-strip-sessions", action="append_const", @@ -304,7 +332,7 @@ def bind_client(client_id, jid): args = parser.parse_args() - filters = [filter_sessions] + filters = [filter_sm, filter_sessions] for to_add in args.add_filters: filters.append(to_add) for to_remove in args.remove_filters: