mirror of https://github.com/fail2ban/fail2ban
Merge branch '0.10' into 0.11
commit
eba8bd4faa
|
@ -47,9 +47,7 @@ class CSocket:
|
||||||
|
|
||||||
def send(self, msg, nonblocking=False, timeout=None):
|
def send(self, msg, nonblocking=False, timeout=None):
|
||||||
# Convert every list member to string
|
# Convert every list member to string
|
||||||
obj = dumps(map(
|
obj = dumps(map(CSocket.convert, msg), HIGHEST_PROTOCOL)
|
||||||
lambda m: str(m) if not isinstance(m, (list, dict, set)) else m, msg),
|
|
||||||
HIGHEST_PROTOCOL)
|
|
||||||
self.__csock.send(obj + CSPROTO.END)
|
self.__csock.send(obj + CSPROTO.END)
|
||||||
return self.receive(self.__csock, nonblocking, timeout)
|
return self.receive(self.__csock, nonblocking, timeout)
|
||||||
|
|
||||||
|
@ -70,6 +68,14 @@ class CSocket:
|
||||||
pass
|
pass
|
||||||
self.__csock = None
|
self.__csock = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def convert(m):
|
||||||
|
"""Convert every "unexpected" member of message to string"""
|
||||||
|
if isinstance(m, (basestring, bool, int, float, list, dict, set)):
|
||||||
|
return m
|
||||||
|
else: # pragma: no cover
|
||||||
|
return str(m)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def receive(sock, nonblocking=False, timeout=None):
|
def receive(sock, nonblocking=False, timeout=None):
|
||||||
msg = CSPROTO.EMPTY
|
msg = CSPROTO.EMPTY
|
||||||
|
|
Loading…
Reference in New Issue