Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_body(self, body):
"""
set msg body
"""
misc.check_type(body, str)
self._data['body'] = body
self._bodylen = len(body)
def ip_port2connaddr(peer):
"""
connaddr is a 64bit int
32 - 16 - 16 - 32
ip - port - stub - future
:param peer:
(ipaddr, port)
:return:
return a connaddr
"""
misc.check_type(peer, tuple)
ipaddr, port = peer
misc.check_type(ipaddr, str)
packed = socket.inet_aton(ipaddr)
return (struct.unpack("!L", packed)[0] << 64) | (port << 48)
def set_msg_type(self, msg_type):
"""
set msg type
"""
misc.check_type(msg_type, int)
self._data['type'] = self._asign_uint2byte_bybits(msg_type, 32)
self._type = msg_type
def _check_addr(cls, ip_port, stub_future):
ip, port = ip_port
stub, future = stub_future
misc.check_type(ip, str)
def check_type(param, expect):
"""
deprecated. Recommand using misc.check_type in cup.util
"""
misc.check_type(param, expect)
def _addr2pack(self, ip_port, stub_future):
misc.check_type(ip_port, tuple)
misc.check_type(stub_future, tuple)
pack = common.ip_port2connaddr(ip_port)
pack = common.add_stub2connaddr(pack, stub_future[0])
pack = common.add_future2connaddr(pack, stub_future[1])
return pack
def _addr2pack(self, ip_port, stub_future):
misc.check_type(ip_port, tuple)
misc.check_type(stub_future, tuple)
pack = common.ip_port2connaddr(ip_port)
pack = common.add_stub2connaddr(pack, stub_future[0])
pack = common.add_future2connaddr(pack, stub_future[1])
return pack