From 36195198a6767c0329f1ae84a8c41c3cf5b9d0ae Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 14 Feb 2023 14:40:08 -0500 Subject: [PATCH] Add fallback for newer msgpack Newer msgpack refuses the encoding argument, use raw=False instead. Further, newer msgpack refuses to accept int as key by default. Opt into it as the risk is hash collision due to msgpack int being used directly, and we aren't dealing with untrusted peer (we only talk to ourselves). --- confluent_server/confluent/networking/macmap.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/confluent_server/confluent/networking/macmap.py b/confluent_server/confluent/networking/macmap.py index 6069fa6f..c760dcda 100644 --- a/confluent_server/confluent/networking/macmap.py +++ b/confluent_server/confluent/networking/macmap.py @@ -220,7 +220,10 @@ def _start_offloader(): def _recv_offload(): - upacker = msgpack.Unpacker(encoding='utf8') + try: + upacker = msgpack.Unpacker(encoding='utf8') + except TypeError: + upacker = msgpack.Unpacker(raw=False, strict_map_key=False) instream = _offloader.stdout.fileno() while True: select.select([_offloader.stdout], [], []) @@ -689,7 +692,10 @@ def rescan(cfg): if __name__ == '__main__': if len(sys.argv) > 1 and sys.argv[1] == '-o': - upacker = msgpack.Unpacker(encoding='utf8') + try: + upacker = msgpack.Unpacker(encoding='utf8') + except TypeError: + upacker = msgpack.Unpacker(raw=False, strict_map_key=False) currfl = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL) fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, currfl | os.O_NONBLOCK) @@ -714,4 +720,4 @@ if __name__ == '__main__': print("Mac to location lookup table: -------------------") print(repr(_macmap)) print("switch to fdb lookup table: -------------------") - print(repr(_macsbyswitch)) \ No newline at end of file + print(repr(_macsbyswitch))