mirror of https://github.com/fail2ban/fail2ban
- Use pickle instead of cPickle. Python 2.5 gives an exception with cPickle
- Use a binary format instead of ASCII git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@443 a942ae1a-1317-0410-a47c-b1dcaea8d6050.x
parent
9834734178
commit
d065d97888
|
@ -24,6 +24,8 @@ ver. 0.7.4 (2006/??/??) - beta
|
||||||
Python
|
Python
|
||||||
- Better debugging output for "fail2ban-regex"
|
- Better debugging output for "fail2ban-regex"
|
||||||
- Added support for more date format
|
- Added support for more date format
|
||||||
|
- cPickle does not work with Python 2.5. Use pickle instead
|
||||||
|
(performance is not a problem in our case)
|
||||||
|
|
||||||
ver. 0.7.3 (2006/09/28) - beta
|
ver. 0.7.3 (2006/09/28) - beta
|
||||||
----------
|
----------
|
||||||
|
|
2
TODO
2
TODO
|
@ -13,6 +13,8 @@ Legend:
|
||||||
# partially done
|
# partially done
|
||||||
* done
|
* done
|
||||||
|
|
||||||
|
- Fix the cPickle issue with Python 2.5
|
||||||
|
|
||||||
- Multiline log reading
|
- Multiline log reading
|
||||||
|
|
||||||
- Improve communication. (asyncore, asynchat??)
|
- Improve communication. (asyncore, asynchat??)
|
||||||
|
|
|
@ -24,7 +24,8 @@ __date__ = "$Date$"
|
||||||
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
||||||
__license__ = "GPL"
|
__license__ = "GPL"
|
||||||
|
|
||||||
from cPickle import dumps, loads
|
#from cPickle import dumps, loads, HIGHEST_PROTOCOL
|
||||||
|
from pickle import dumps, loads, HIGHEST_PROTOCOL
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
class CSocket:
|
class CSocket:
|
||||||
|
@ -40,7 +41,7 @@ class CSocket:
|
||||||
|
|
||||||
def send(self, msg):
|
def send(self, msg):
|
||||||
# Convert every list member to string
|
# Convert every list member to string
|
||||||
obj = dumps(map(str, msg))
|
obj = dumps(map(str, msg), HIGHEST_PROTOCOL)
|
||||||
self.__csock.send(obj + CSocket.END_STRING)
|
self.__csock.send(obj + CSocket.END_STRING)
|
||||||
ret = self.receive(self.__csock)
|
ret = self.receive(self.__csock)
|
||||||
self.__csock.close()
|
self.__csock.close()
|
||||||
|
|
|
@ -25,7 +25,9 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
||||||
__license__ = "GPL"
|
__license__ = "GPL"
|
||||||
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from cPickle import dumps, loads
|
# cPickle generates an exception with Python 2.5
|
||||||
|
#from cPickle import dumps, loads, HIGHEST_PROTOCOL
|
||||||
|
from pickle import dumps, loads, HIGHEST_PROTOCOL
|
||||||
import socket, logging, os, os.path
|
import socket, logging, os, os.path
|
||||||
|
|
||||||
# Gets the instance of the logger.
|
# Gets the instance of the logger.
|
||||||
|
@ -113,7 +115,7 @@ class SocketWorker(Thread):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __send(sock, msg):
|
def __send(sock, msg):
|
||||||
obj = dumps(msg)
|
obj = dumps(msg, HIGHEST_PROTOCOL)
|
||||||
sock.send(obj + SSocket.END_STRING)
|
sock.send(obj + SSocket.END_STRING)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue