Merge pull request #758 from Sean-Der/add-version-to-protocol

ENH: Add version command to protocol
pull/769/head
Yaroslav Halchenko 2014-07-17 18:58:41 -04:00
commit d498474c8f
7 changed files with 16 additions and 1 deletions

View File

@ -39,6 +39,7 @@ ver. 0.9.1 (2014/xx/xx) - better, faster, stronger
- New features:
- Added monit filter thanks Jason H Martin.
- fail2ban-client can fetch the running server version
- Enhancements
* Fail2ban-regex - add print-all-matched option. Closes gh-652

1
THANKS
View File

@ -88,6 +88,7 @@ Rolf Fokkens
Roman Gelfand
Russell Odom
SATO Kentaro
Sean DuBois
Sebastian Arcus
Serg G. Brester
Sireyessire

View File

@ -51,6 +51,8 @@ class Beautifier:
try:
if inC[0] == "ping":
msg = "Server replied: " + response
elif inC[0] == "version":
msg = response
elif inC[0] == "start":
msg = "Jail started"
elif inC[0] == "stop":

View File

@ -38,6 +38,7 @@ protocol = [
["status", "gets the current status of the server"],
["ping", "tests if the server is alive"],
["help", "return this output"],
["version", "return the server version"],
['', "LOGGING", ""],
["set loglevel <LEVEL>", "sets logging level to <LEVEL>. Levels: CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG"],
["get loglevel", "gets the logging level"],

View File

@ -28,6 +28,7 @@ import time
import json
from ..helpers import getLogger
from .. import version
# Gets the instance of the logger.
logSys = getLogger(__name__)
@ -103,6 +104,8 @@ class Transmitter:
return self.__commandGet(command[1:])
elif command[0] == "status":
return self.status(command[1:])
elif command[0] == "version":
return version.version
raise Exception("Invalid command")
def __commandSet(self, command):

View File

@ -37,6 +37,7 @@ from ..server.jail import Jail
from ..server.jailthread import JailThread
from .utils import LogCaptureTestCase
from ..helpers import getLogger
from .. import version
try:
from ..server import filtersystemd
@ -148,6 +149,9 @@ class Transmitter(TransmitterBase):
def testPing(self):
self.assertEqual(self.transm.proceed(["ping"]), (0, "pong"))
def testVersion(self):
self.assertEqual(self.transm.proceed(["version"]), (0, version.version))
def testSleep(self):
t0 = time.time()
self.assertEqual(self.transm.proceed(["sleep", "1"]), (0, None))

View File

@ -71,6 +71,9 @@ tests if the server is alive
.TP
\fBhelp\fR
return this output
.TP
\fBversion\fR
return the server version
.IP
LOGGING
.TP