Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0db6a1e
First updates to port to python 3-9. The server boots
LucChoubert Sep 26, 2021
d47d765
Migration of tests to python3. All Running, but test_peering are fail…
LucChoubert Sep 27, 2021
60ef3a1
Fix getChild syntax
LucChoubert Sep 28, 2021
dd223a4
Migration to python3
LucChoubert Sep 28, 2021
9db89ed
migration to python3
LucChoubert Sep 28, 2021
1e9cbec
Tune some test
LucChoubert Sep 28, 2021
b06aa28
migraation to python3
LucChoubert Sep 29, 2021
c25b416
migrate to python3
LucChoubert Sep 29, 2021
2e75561
remove setup.cfg which makes setup.py fail due to minify not existing
LucChoubert Sep 30, 2021
dc32399
commit minified static ressource to avoid a dependency on the setuptool
LucChoubert Sep 30, 2021
4614d3c
Include minified file in the repo
LucChoubert Sep 30, 2021
2f62000
migration to python3
LucChoubert Sep 30, 2021
2745fc2
Update of the installation procedure
LucChoubert Sep 30, 2021
7ca28b9
Updated install procedure
LucChoubert Sep 30, 2021
49cc1d1
Improving the documentation
LucChoubert Sep 30, 2021
2e70723
Migrate test_peering to python3
LucChoubert Oct 3, 2021
0634f4d
Bug fix on server side to ignore resiliency parameter in nb of report…
LucChoubert Oct 7, 2021
90d5955
Convert FQDN to IP via a DNS resolution
LucChoubert Oct 12, 2021
2907df3
Added transacion Id in logs to follow execution in asynchronous call …
LucChoubert Oct 17, 2021
fbb0244
cosmetic change
LucChoubert Oct 17, 2021
2aa0bc9
Add one log for investigation purpose
LucChoubert Oct 17, 2021
61947c7
Perf improvment by removing the multiple database call and replacing …
LucChoubert Oct 18, 2021
c24dd49
Improve add_hosts by removing dupes in the input
LucChoubert Nov 22, 2021
104833a
Cap maximum time of get_new_hosts to something close to 30secs as the…
LucChoubert Nov 22, 2021
d5f5e17
Add config parameter to tune the max elapsed time authorized
LucChoubert Nov 24, 2021
ef87c60
Cleanup in the various temporary comments
LucChoubert Nov 24, 2021
87859d9
Log improvment
LucChoubert Nov 24, 2021
9d18898
Bump minor version number
LucChoubert Nov 26, 2021
ca78cba
Merge pull request #1 from LucChoubert/python_39
josev814 Jun 29, 2022
e580213
Merge pull request #2 from LucChoubert/master
josev814 Jun 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ MANIFEST
htmlcov
static/graph/*.svg
static/graph/*.png
static/css/*.min.css
static/js/*.min.js
.venv
.vscode
TODO
mynotes.txt
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ of `denyhosts`.
- Dynamically generated statistics web page
- Peering mode: multiple servers can shared their information for load-balancing
and to prevent a single point of failure
- `denyhosts-server` is developed and tested on a Debian GNU/Linux system. It should
work on any Linux system with Python. Microsoft Windows is not a supported
platform, although it should work without major modifications.

## Prerequisites
- MySQL database is preferred for large sites. For testing purposes sqlite is
also supported
- Python 2.7 with setuptools
- The other Python libraries are installed automatically by the setup.py script.
The GeoIP library needs the libgeoip development headers. On a Debian system,
- Python 3 with setuptools (tested with Python 3.9). On an Ubuntu 21.04 system, run `apt install python-is-python3 python3-setuptools`
- The GeoIP library needs the libgeoip development headers. On a Debian system,
install them by running `apt-get install libgeoip-dev`. To install the
free GeoIP database, run `apt-get install geoip-database`.
Note: To install the Python GeoIP library on FreeBSD, edit your
Expand All @@ -33,38 +35,36 @@ and to prevent a single point of failure
include_dirs=/usr/local/include
library_dirs=/usr/local/lib
```
- `denyhosts-server` is developed and tested on a Debian GNU/Linux system. It should
work on any Linux system with Python. Microsoft Windows is not a supported
platform, although it should work without major modifications.
- On most installations the sqlite3 Python library comes with Python 2.7. If
not, you need to install it manually, possibly with using pip:
`pip install pysqlite` or, on Debian/Ubuntu, `apt-get install python-pysqlite2`.
- The libnacl used to manage encryption key relies on libsodium. Make sure you install it. On a Ubuntu system, run `apt install libsodium23`.
- The other Python libraries will be installed automatically by the setup.py script.
- On most installations the sqlite3 Python library comes with Python 3.
- If you use a MySQL database, you need to install the appropriate Python
library. possibly by running `pip install MySQL-python`. On Debian/Ubuntu,
use `apt-get install python-mysqldb`.
- If you're on a Debian, and possible also Ubuntu system, you'll make your life
easier when you install the some packages:
apt-get install python-dev python-pip python-setuptools libgeoip-dev \
geoip-database libpng-dev libxft-dev python-matplotlib python-twisted \
libsodium-dev libffi-dev yui-compressor
- If you're on a Debian, and possible also Ubuntu system, you can install all pre-requisite like this: `apt install python-is-python3 python3-setuptools libgeoip-dev libsodium23 libpython3.9-dev`


## Installation
Run the following command: `sudo setup.py develop` to download the needed
Python libraries. Then run `sudo setup.py minify_js minify_css install` to
minify the used JavaScript and CSS libraries, install the Python scripts
onto your system (usually in `/usr/local/lib/python2.7/dist-packages`)
and the Python script `/usr/local/bin/denyhosts-server`.
To do a global installation on your machine:
- After cloning the repo, go in the root dir of the repo and run the following command: `sudo setup.py install` to download the needed
Python libraries. It will install all pre-req python libraries in you local dist-packages location (`/usr/local/lib/python3.9/dist-packages`)
as well as deploy `denyhosts-server` in you executable location (`/usr/local/bin`).

If you want to isolate in a virtual environment (make sure you have venv module installed: `apt install python3.9-venv`), run first `python -m venv .venv` and activate your environment (`source .venv/bin/activate`)


## Configuration
Create the database and a database user with full rights to it. Copy the
`denyhosts-server.conf.example` file to `/etc/denyhosts-server.conf` and edit it.
- Create the database and a database user with full rights to it.
- Copy the `denyhosts-server.conf.example` file to `/etc/denyhosts-server.conf` and edit it.
Fill in the database parameters, the location of the log file (which should be
writable by the system user that will be running denyhosts-server) and
other settings you wish to change. `graph_dir` in the `stats` sections is
another location that should be writable by `denyhosts-server`.

Prepare the database for first use with the command `denyhosts-server
--recreate-database`. This will create the tables needed by denyhosts-server.
- If you haven change the default logging configuration, make sure `/var/log/denyhosts-server` is created and write accessible
from the user running `denyhosts-server`
- If you haven change the default logging configuration, make sure `/var/lib/denyhosts-server` is created and write accessible
from the user running `denyhosts-server`
- Prepare the database for first use with the command `denyhosts-server --recreate-database`. This will create the tables needed by denyhosts-server.

## Running denyhosts-server
Simply run `denyhosts-server`. Unless there are unexpected errors, this will give no
Expand Down
5 changes: 5 additions & 0 deletions denyhosts-server.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
# denyhosts clients per sync. Default: 50
#max_reported_crackers: 50

#Maximum processing time of the get_New_Hosts service. The timeout value is set to 30seonds on the cliend side so any answer after that would be ignored.
#Also, without capping, the database is so huge that building the list can go super high (several minutes)
#Default: 28
#max_processing_time_get_new_hosts: 28

# TCP port to listen on. Default: 9911
#listen_port: 9911

Expand Down
2 changes: 1 addition & 1 deletion denyhosts_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

@author: Jan-Pascal van Best U{janpascal@vanbest.org}
"""
version_info = (2, 2, 3)
version_info = (3, 0, 1)
version = '.'.join(map(str, version_info))
19 changes: 11 additions & 8 deletions denyhosts_server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import ConfigParser
import configparser
import inspect
import logging
import os.path
Expand All @@ -24,44 +24,45 @@
def _get(config, section, option, default=None):
try:
result = config.get(section, option)
except ConfigParser.NoOptionError:
except configparser.NoOptionError:
result = default
return result

def _gethex(config, section, option, default=None):
try:
result = config.get(section, option)
except ConfigParser.NoOptionError:
except configparser.NoOptionError:
result = default
if result is not None:
result = result.decode('hex')
result = bytes.fromhex(result)
return result

def _getint(config, section, option, default=None):
try:
result = config.getint(section, option)
except ConfigParser.NoOptionError:
except configparser.NoOptionError:
result = default
return result

def _getboolean(config, section, option, default=None):
try:
result = config.getboolean(section, option)
except ConfigParser.NoOptionError:
except configparser.NoOptionError:
result = default
return result

def _getfloat(config, section, option, default=None):
try:
result = config.getfloat(section, option)
except ConfigParser.NoOptionError:
except configparser.NoOptionError:
result = default
return result

def read_config(filename):
global dbtype, dbparams
global maintenance_interval, expiry_days, legacy_expiry_days
global max_reported_crackers
global max_processing_time_get_new_hosts
global logfile
global loglevel
global xmlrpc_listen_port
Expand All @@ -75,7 +76,7 @@ def read_config(filename):
global static_dir, graph_dir, template_dir
global key_file, peers

_config = ConfigParser.SafeConfigParser()
_config = configparser.SafeConfigParser()
_config.readfp(open(filename,'r'))

dbtype = _get(_config, "database", "type", "sqlite3")
Expand Down Expand Up @@ -113,6 +114,8 @@ def read_config(filename):
legacy_expiry_days = _getfloat(_config, "maintenance", "legacy_expiry_days", 30)

max_reported_crackers = _getint(_config, "sync", "max_reported_crackers", 50)
#That default value is set because in the client part the timeout is 30 seconds
max_processing_time_get_new_hosts = _getint(_config, "sync", "max_processing_time_get_new_hosts", 28)
xmlrpc_listen_port = _getint(_config, "sync", "listen_port", 9911)
enable_debug_methods = _getboolean(_config, "sync", "enable_debug_methods", False)
legacy_server = _get(_config, "sync", "legacy_server", None)
Expand Down
Loading