mirror of https://github.com/fail2ban/fail2ban
Merge pull request #758 from Sean-Der/add-version-to-protocol
ENH: Add version command to protocolpull/769/head
commit
d498474c8f
|
@ -39,6 +39,7 @@ ver. 0.9.1 (2014/xx/xx) - better, faster, stronger
|
||||||
|
|
||||||
- New features:
|
- New features:
|
||||||
- Added monit filter thanks Jason H Martin.
|
- Added monit filter thanks Jason H Martin.
|
||||||
|
- fail2ban-client can fetch the running server version
|
||||||
|
|
||||||
- Enhancements
|
- Enhancements
|
||||||
* Fail2ban-regex - add print-all-matched option. Closes gh-652
|
* Fail2ban-regex - add print-all-matched option. Closes gh-652
|
||||||
|
|
1
THANKS
1
THANKS
|
@ -88,6 +88,7 @@ Rolf Fokkens
|
||||||
Roman Gelfand
|
Roman Gelfand
|
||||||
Russell Odom
|
Russell Odom
|
||||||
SATO Kentaro
|
SATO Kentaro
|
||||||
|
Sean DuBois
|
||||||
Sebastian Arcus
|
Sebastian Arcus
|
||||||
Serg G. Brester
|
Serg G. Brester
|
||||||
Sireyessire
|
Sireyessire
|
||||||
|
|
|
@ -51,6 +51,8 @@ class Beautifier:
|
||||||
try:
|
try:
|
||||||
if inC[0] == "ping":
|
if inC[0] == "ping":
|
||||||
msg = "Server replied: " + response
|
msg = "Server replied: " + response
|
||||||
|
elif inC[0] == "version":
|
||||||
|
msg = response
|
||||||
elif inC[0] == "start":
|
elif inC[0] == "start":
|
||||||
msg = "Jail started"
|
msg = "Jail started"
|
||||||
elif inC[0] == "stop":
|
elif inC[0] == "stop":
|
||||||
|
|
|
@ -38,6 +38,7 @@ protocol = [
|
||||||
["status", "gets the current status of the server"],
|
["status", "gets the current status of the server"],
|
||||||
["ping", "tests if the server is alive"],
|
["ping", "tests if the server is alive"],
|
||||||
["help", "return this output"],
|
["help", "return this output"],
|
||||||
|
["version", "return the server version"],
|
||||||
['', "LOGGING", ""],
|
['', "LOGGING", ""],
|
||||||
["set loglevel <LEVEL>", "sets logging level to <LEVEL>. Levels: CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG"],
|
["set loglevel <LEVEL>", "sets logging level to <LEVEL>. Levels: CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG"],
|
||||||
["get loglevel", "gets the logging level"],
|
["get loglevel", "gets the logging level"],
|
||||||
|
|
|
@ -28,6 +28,7 @@ import time
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from ..helpers import getLogger
|
from ..helpers import getLogger
|
||||||
|
from .. import version
|
||||||
|
|
||||||
# Gets the instance of the logger.
|
# Gets the instance of the logger.
|
||||||
logSys = getLogger(__name__)
|
logSys = getLogger(__name__)
|
||||||
|
@ -102,7 +103,9 @@ class Transmitter:
|
||||||
elif command[0] == "get":
|
elif command[0] == "get":
|
||||||
return self.__commandGet(command[1:])
|
return self.__commandGet(command[1:])
|
||||||
elif command[0] == "status":
|
elif command[0] == "status":
|
||||||
return self.status(command[1:])
|
return self.status(command[1:])
|
||||||
|
elif command[0] == "version":
|
||||||
|
return version.version
|
||||||
raise Exception("Invalid command")
|
raise Exception("Invalid command")
|
||||||
|
|
||||||
def __commandSet(self, command):
|
def __commandSet(self, command):
|
||||||
|
|
|
@ -37,6 +37,7 @@ from ..server.jail import Jail
|
||||||
from ..server.jailthread import JailThread
|
from ..server.jailthread import JailThread
|
||||||
from .utils import LogCaptureTestCase
|
from .utils import LogCaptureTestCase
|
||||||
from ..helpers import getLogger
|
from ..helpers import getLogger
|
||||||
|
from .. import version
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ..server import filtersystemd
|
from ..server import filtersystemd
|
||||||
|
@ -148,6 +149,9 @@ class Transmitter(TransmitterBase):
|
||||||
def testPing(self):
|
def testPing(self):
|
||||||
self.assertEqual(self.transm.proceed(["ping"]), (0, "pong"))
|
self.assertEqual(self.transm.proceed(["ping"]), (0, "pong"))
|
||||||
|
|
||||||
|
def testVersion(self):
|
||||||
|
self.assertEqual(self.transm.proceed(["version"]), (0, version.version))
|
||||||
|
|
||||||
def testSleep(self):
|
def testSleep(self):
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
self.assertEqual(self.transm.proceed(["sleep", "1"]), (0, None))
|
self.assertEqual(self.transm.proceed(["sleep", "1"]), (0, None))
|
||||||
|
|
|
@ -71,6 +71,9 @@ tests if the server is alive
|
||||||
.TP
|
.TP
|
||||||
\fBhelp\fR
|
\fBhelp\fR
|
||||||
return this output
|
return this output
|
||||||
|
.TP
|
||||||
|
\fBversion\fR
|
||||||
|
return the server version
|
||||||
.IP
|
.IP
|
||||||
LOGGING
|
LOGGING
|
||||||
.TP
|
.TP
|
||||||
|
|
Loading…
Reference in New Issue