Add msgpack 1.0 support

This project now only supports msgpack versions >= 1.0.0

Backport from https://github.com/faucetsdn/ryu/commit/aa10ca

Story: #2009283
Task: #46863
Change-Id: I3bfd54851717238330af82655361b7b631079f59
This commit is contained in:
Benjamin Beasley 2020-12-30 09:59:13 -05:00 committed by Rodolfo Alonso
parent f10f2b2852
commit fc75bd821b
2 changed files with 13 additions and 3 deletions

View File

@ -39,7 +39,12 @@ class MessageEncoder(object):
def __init__(self):
super(MessageEncoder, self).__init__()
self._packer = msgpack.Packer(use_bin_type=True)
# NOTE(ralonsoh): msgpack>=1.0.0
self._packer = msgpack.Packer()
# The strict_map_key=False option is required to use int keys in
# maps; it is disabled by default to prevent hash collision denial
# of service attacks (hashdos) in scenarios where an attacker can
# control the keys to be hashed.
self._unpacker = msgpack.Unpacker(strict_map_key=False)
self._next_msgid = 0

View File

@ -101,8 +101,13 @@ class RpcSession(Activity):
def __init__(self, sock, outgoing_msg_sink_iter):
self.peer_name = str(sock.getpeername())
super(RpcSession, self).__init__(self.NAME_FMT % self.peer_name)
self._packer = msgpack.Packer(encoding='utf-8', use_bin_type=True)
self._unpacker = msgpack.Unpacker(encoding='utf-8')
# NOTE(ralonsoh): msgpack>=1.0.0
self._packer = msgpack.Packer()
# The strict_map_key=False option is required to use int keys in
# maps; it is disabled by default to prevent hash collision denial
# of service attacks (hashdos) in scenarios where an attacker can
# control the keys to be hashed.
self._unpacker = msgpack.Unpacker(strict_map_key=False)
self._next_msgid = 0
self._socket = sock
self._outgoing_msg_sink_iter = outgoing_msg_sink_iter