Browse Source

- Display a message if we could not bind the socket.

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_8@636 a942ae1a-1317-0410-a47c-b1dcaea8d605
_tent/ipv6_via_aInfo
Cyril Jaquier 17 years ago
parent
commit
379aa2f855
  1. 12
      server/asyncserver.py

12
server/asyncserver.py

@ -25,7 +25,7 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL"
from pickle import dumps, loads, HIGHEST_PROTOCOL
import asyncore, asynchat, socket, os, logging, sys
import asyncore, asynchat, socket, os, logging
# Gets the instance of the logger.
logSys = logging.getLogger("fail2ban.server")
@ -46,7 +46,6 @@ class RequestHandler(asynchat.async_chat):
self.__buffer = []
# Sets the terminator.
self.set_terminator(RequestHandler.END_STRING)
self.found_terminator = self.handle_request_line
def collect_incoming_data(self, data):
logSys.debug("Received raw data: " + str(data))
@ -57,7 +56,7 @@ class RequestHandler(asynchat.async_chat):
#
# This method is called once we have a complete request.
def handle_request_line(self):
def found_terminator(self):
# Joins the buffer items.
message = loads("".join(self.__buffer))
# Gives the message to the transmitter.
@ -125,12 +124,15 @@ class AsyncServer(asyncore.dispatcher):
# Creates the socket.
self.create_socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind(sock)
try:
self.bind(sock)
except Exception:
raise AsyncServerException("Unable to bind socket %s" % self.__sock)
self.listen(1)
# Sets the init flag.
self.__init = True
# TODO Add try..catch
asyncore.loop(timeout = 2)
asyncore.loop()
##
# Stops the communication server.

Loading…
Cancel
Save