Commit 7bbe4309 authored by Michal TOMA's avatar Michal TOMA Committed by mats Dufberg
Browse files

Fix issue 284 (#295)

* Replace WebBackend by Backend

* Renames modules Engine to RPCAPI

* Renamed the Runner module to TestAgent

* Renamed zonemaster_backend.psgi to zonemaster_rpcapi.psgi

* Bugfix: wrongly replaced ENGINE keyword. Fixes: #284

* Fixes #284: bugfix replacing zonemaster_backend.psgi to zonemaster_rpcapi.psgi

* Fixes to take into account the comments of the pull request

* More fixes according to review

* Fixed typos

* Fixes according to review 28/09/2017

* More fixes - 28/09/2017 13h50

* Added wrongly removed and renamed files

* More fixes 28/09/2017 - 18h18
parent d25c36af
.gitignore
.travis.yml
CHANGES
CodeSnippets/client.pl
......@@ -24,22 +23,19 @@ inc/Module/Install/Scripts.pm
inc/Module/Install/Share.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
lib/Zonemaster/WebBackend.pm
lib/Zonemaster/WebBackend/Config.pm
lib/Zonemaster/WebBackend/DB.pm
lib/Zonemaster/WebBackend/DB/MySQL.pm
lib/Zonemaster/WebBackend/DB/PostgreSQL.pm
lib/Zonemaster/WebBackend/DB/SQLite.pm
lib/Zonemaster/WebBackend/Engine.pm
lib/Zonemaster/WebBackend/Runner.pm
lib/Zonemaster/WebBackend/Translator.pm
lib/Zonemaster/Backend.pm
lib/Zonemaster/Backend/Config.pm
lib/Zonemaster/Backend/DB.pm
lib/Zonemaster/Backend/DB/MySQL.pm
lib/Zonemaster/Backend/DB/PostgreSQL.pm
lib/Zonemaster/Backend/DB/SQLite.pm
lib/Zonemaster/Backend/RPCAPI.pm
lib/Zonemaster/Backend/TestAgent.pm
lib/Zonemaster/Backend/Translator.pm
LICENSE
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
META.yml
MYMETA.json
MYMETA.yml
README.md
script/add-test.pl
script/create_db_mysql.pl
......@@ -49,8 +45,8 @@ script/crontab_job_runner/execute_zonemaster_P10.pl
script/crontab_job_runner/execute_zonemaster_P5.pl
script/patch_db_mysql_for_backend_DB_version_lower_than_1.0.3.pl
script/patch_db_postgresq_for_backend_DB_version_lower_than_1.0.3.pl
script/zm_wb_daemon
script/zonemaster_webbackend.psgi
script/zonemaster_backend_rpcapi.psgi
script/zonemaster_backend_testagent
share/backend_config.ini
share/cleanup-mysql.sql
share/cleanup-postgres.sql
......@@ -62,9 +58,10 @@ share/travis_postgresql_backend_config.ini
share/travis_sqlite_backend_config.ini
share/zm-backend.sh
share/zm-centos.sh
share/zm_wb_daemon.conf
share/zonemaster_backend_testagent.conf
t/test01.data
t/test01.t
t/test_DB_backend.pl
t/test_runner.pl
t/test_validate_syntax.t
zonemaster
use inc::Module::Install;
name 'Zonemaster-WebBackend';
name 'Zonemaster-Backend';
author q{Michal TOMA <toma@nic.fr>};
version_from 'lib/Zonemaster/WebBackend/Engine.pm';
abstract 'The Zonemaster project Web Backend engine';
version_from 'lib/Zonemaster/Backend.pm';
abstract 'The Zonemaster Backend project with RPC API and Test Agents';
license 'perl';
perl_version '5.014002';
......@@ -40,8 +40,8 @@ recommends 'DBD::SQLite';
install_share;
install_script 'zonemaster_webbackend.psgi';
install_script 'zm_wb_daemon';
install_script 'zonemaster_backend_rpcapi.psgi';
install_script 'zonemaster_backend_testagent';
no_index directory => 'CodeSnippets';
no_index directory => 'Doc';
......
......@@ -58,8 +58,8 @@ The Zonemaster Backend documentation is split up into several documents:
glossary over domain specific technical terms.
* The [Getting Started](docs/GettingStarted.md) guide walks you through creating
a *test* and following it through its life cycle, all using JSON-RPC calls to
the *Web backend*.
* The [API](docs/API.md) documentation describes the *Web backend* inteface in
the *RPC API daemon*.
* The [API](docs/API.md) documentation describes the *RPC API daemon* inteface in
detail.
The [docs](docs/) directory also contains the SQL commands for manipulating the
......
......@@ -2,7 +2,7 @@
## Purpose
This document describes the JSON-RPC API provided by the Zonemaster *Web backend*.
This document describes the JSON-RPC API provided by the Zonemaster *RPC API daemon*.
This API provides means to check the health of domains and to fetch domain health reports.
Health checks are called *tests* in Zonemaster lingo.
......@@ -124,8 +124,8 @@ Properties:
Basic data type: number
This parameter is any integer that will be used by The Zonemaster Backend Worker daemon to sort the test requests from highest to lowest priority.
This parameter will typically be used in a setup where a GUI will send requests to the Backend API and would like to get response as soon as possible while at the same time using the idle time for background batch testing.
This parameter is any integer that will be used by The Zonemaster Test Agents to sort the test requests from highest to lowest priority.
This parameter will typically be used in a setup where a GUI will send requests to the RPC API and would like to get response as soon as possible while at the same time using the idle time for background batch testing.
The drawback of this setup will be that the GUI will have to wait for at least one background processing slot to become free (would be a few secods in a typical installation with up to 30 parallel zonemaster processes allowed)
### Queue
......@@ -133,7 +133,7 @@ The drawback of this setup will be that the GUI will have to wait for at least o
Basic data type: number
This parameter allows an optional separation of testing in the same database. The default value for the queue is 0. It is closely related to the *lock_on_queue* parameter of the [ZONEMASTER] section of the backend_config.ini file.
The typical use case for this parameter would be a setup with several separate Backends Worker daemons running on separate physical or virtual machines each one dedicated to a specific task, for example queue 0 for frontend tests and queue 1 dedicated to batch testing. Running several Backend Worker daemons on the same machine is currently not supported.
The typical use case for this parameter would be a setup with several separate Test Agents running on separate physical or virtual machines each one dedicated to a specific task, for example queue 0 for frontend tests and queue 1 dedicated to batch testing. Running several Test Agents on the same machine is currently not supported.
### Profile name
......@@ -223,7 +223,7 @@ Basic data type: string
## API method: `version_info`
Returns the version of the *Backend*+*Engine* software combination.
Returns the version of the Zonemaster Backend and Zonemaster Engine software combination
Example request:
```json
......@@ -251,8 +251,8 @@ Example response:
An object with the following properties:
* `"zonemaster_backend"`: A string. The version number of the running *Web backend*.
* `"zonemaster_engine"`: A string. The version number of the *Engine* used by the *Web backend*.
* `"zonemaster_backend"`: A string. The version number of the running *Zonemaster Backend*.
* `"zonemaster_engine"`: A string. The version number of the *Zonemaster Engine* used by the *RPC API daemon*.
#### `"error"`
......@@ -991,7 +991,7 @@ An object with the following properties:
Checks the `"params"` structure for syntax coherence. It is very strict on what
is allowed and what is not to avoid any SQL injection and cross site scripting
attempts. It also checks the domain name for syntax to ensure the domain name
seems to be a valid domain name and a test by the *Engine* can be started.
seems to be a valid domain name and a test by the *Zonemaster Engine* can be started.
Example request:
```json
......
......@@ -4,7 +4,7 @@ The Zonemaster *Backend* is a system for performing domain health checks and
keeping records of performed domain health checks.
A Zonemaster *Backend* system consists of at least three components: a
single *Database*, a single *Worker* and one or more *Web backends*.
single *Database*, a single *Test Agent* and one or more *RPC API daemons*.
## Components
......@@ -15,12 +15,12 @@ The *Database* stores health check requests and results. The *Backend*
architecture is oriented around a single central *Database*.
### Worker
### Test Agent
A Zonemaster *Worker* is a daemon that picks up *test* requests from the
*Database*, runs them using the *Engine* library, and records the results back
to the *Database*. A single *Worker* may handle several requests concurrently.
The *Backend* architecture supports a single *Worker* interacting with a single *Database*.
A Zonemaster *Test Agent* is a daemon that picks up *test* requests from the
*Database*, runs them using the *Zonemaster Engine* library, and records the results back
to the *Database*. A single *Test Agent* may handle several requests concurrently.
The *Backend* architecture supports a single *Test Agent* daemon interacting with a single *Database*.
>
> TODO: List all files these processes read and write.
......@@ -29,9 +29,9 @@ The *Backend* architecture supports a single *Worker* interacting with a single
>
> TODO: Describe in which order *test* are processed.
>
> TODO: Describe how concurrency, parallelism and synchronization works within a single *Worker*.
> TODO: Describe how concurrency, parallelism and synchronization works within a single *Test Agent*.
>
> TODO: Describe how synchronization works among parallel *Workers*.
> TODO: Describe how synchronization works among parallel *Test Agents*.
>
......@@ -39,7 +39,7 @@ The *Backend* architecture supports a single *Worker* interacting with a single
A Zonemaster *Web backend* is a daemon providing a JSON-RPC interface for
recording *test* requests in the *Database* and fetching *test* results from the
*Database*. The *Backend* architecture supports multiple *Web backends*
*Database*. The *Backend* architecture supports multiple *RPC API daemons*
interacting with the same *Database*.
>
......
# Getting started
This is a guide for getting started with the Zonemaster Web Backend JSON-RPC API.
This is a guide for getting started with the Zonemaster RPC API daemon.
>
> Note: This guide makes a number of assumptions about you setup:
......@@ -10,7 +10,7 @@ This is a guide for getting started with the Zonemaster Web Backend JSON-RPC API
> * that you have the tools `curl` and `jq` installed
>
First, check that the *Web backend* is running and answering properly.
First, check that the *RPC API daemon* is running and answering properly.
```sh
curl -sS -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "id": 1, "method": "version_info"}' http://localhost:5000/ | jq .
......
# Files Description
./lib/Zonemaster/WebBackend/Engine.pm
./lib/Zonemaster/Backend/RPCAPI.pm
The main module
./script/zonemaster_webbackend.psgi
./script/zonemaster_backend_rpcapi.psgi
The Plack/PSGI module. The main entry module for a Plack/PSGI server (like Starman)
./lib/Zonemaster/WebBackend/Config.pm
./lib/Zonemaster/Backend/Config.pm
The Configuration file abstraction layer
./share/backend_config.ini
......@@ -16,30 +16,30 @@
./CodeSnippets/client.pl
A sample script and library to communicate with the backend.
./lib/Zonemaster/WebBackend/DB.pm
./lib/Zonemaster/Backend/DB.pm
The Database abstraction layer.
./lib/Zonemaster/WebBackend/DB/MySQL.pm
./lib/Zonemaster/Backend/DB/MySQL.pm
The Database abstraction layer MySQL sample backend.
./lib/Zonemaster/WebBackend/DB/SQLite.pm
./lib/Zonemaster/Backend/DB/SQLite.pm
The Database abstraction layer SQLite sample backend.
./lib/Zonemaster/WebBackend/DB/PostgreSQL.pm
./lib/Zonemaster/Backend/DB/PostgreSQL.pm
The Database abstraction layer PostgreSQL backend.
./lib/Zonemaster/WebBackend/Translator.pm
./lib/Zonemaster/Backend/Translator.pm
The translation module.
./lib/Zonemaster/WebBackend/Runner.pm
The JobRunner main module.
./lib/Zonemaster/Backend/TestAgent.pm
The TestAgent main module.
./script/execute_zonemaster_P10.pl
./script/execute_zonemaster_P5.pl
The scripts to execute tests with differents priorities (application level priorities).
./script/execute_tests.pl
The main JobRunner entry point to execute from crontab.
The main Test Agent entry point to execute from crontab.
./t/test01.t
./t/test_mysql_backend.pl
......
......@@ -72,10 +72,10 @@ service mysqld status
> At this time there is no instruction for using SQLite on CentOS.
>
### 1.3 Installation of the backend
### 1.3 Installation of Zonemaster Backend
```sh
sudo cpan -i Zonemaster::WebBackend
sudo cpan -i Zonemaster::Backend
```
### 1.4 Directory and file manipulation
......@@ -85,12 +85,12 @@ sudo mkdir /etc/zonemaster
mkdir "$HOME/logs"
```
The Zonemaster::WebBackend module installs a number of configuration files in a
The Zonemaster::Backend module installs a number of configuration files in a
shared data directory. This section refers to the shared data directory as the
current directory, so locate it and go there like this:
```sh
cd `perl -MFile::ShareDir -le 'print File::ShareDir::dist_dir("Zonemaster-WebBackend")'`
cd `perl -MFile::ShareDir -le 'print File::ShareDir::dist_dir("Zonemaster-Backend")'`
```
Copy the `backend_config.ini` file to `/etc/zonemaster`.
......@@ -141,8 +141,8 @@ This creates a database called `zonemaster`, as well as a user called
user has just enough permissions to run the backend software.
>
> Note : Only run the above command during an initial installation of the
> Zonemaster backend. If you do this on an existing system, you will wipe out the
> Note : Only run the above command during an initial installation of
> Zonemaster Backend. If you do this on an existing system, you will wipe out the
> data in your database.
>
......@@ -154,7 +154,7 @@ database (obviously taking all data with it).
```sh
cd `perl -MFile::ShareDir -le 'print File::ShareDir::dist_dir("Zonemaster-WebBackend")'`
cd `perl -MFile::ShareDir -le 'print File::ShareDir::dist_dir("Zonemaster-Backend")'`
mysql --user=root --password < ./cleanup-mysql.sql
```
......@@ -243,10 +243,10 @@ sudo apt-get install libdbd-pg-perl postgresql
> At this time there is no instruction for using SQLite on Debian and Ubuntu.
>
### 2.3 Installation of the backend
### 2.3 Installation of Zonemaster Backend
```sh
sudo cpan -i Zonemaster::WebBackend
sudo cpan -i Zonemaster::Backend
```
### 2.4 Directory and file manipulation
......@@ -255,12 +255,12 @@ sudo mkdir /etc/zonemaster
mkdir "$HOME/logs"
```
The Zonemaster::WebBackend module installs a number of configuration files in a
The Zonemaster::Backend module installs a number of configuration files in a
shared data directory. This section refers to the shared data directory as the
current directory, so locate it and go there like this:
```sh
cd `perl -MFile::ShareDir -le 'print File::ShareDir::dist_dir("Zonemaster-WebBackend")'`
cd `perl -MFile::ShareDir -le 'print File::ShareDir::dist_dir("Zonemaster-Backend")'`
```
Copy the `backend_config.ini` file to `/etc/zonemaster`.
......@@ -324,7 +324,7 @@ database (obviously taking all data with it).
```sh
cd `perl -MFile::ShareDir -le 'print File::ShareDir::dist_dir("Zonemaster-WebBackend")'`
cd `perl -MFile::ShareDir -le 'print File::ShareDir::dist_dir("Zonemaster-Backend")'`
mysql --user=root --password < ./cleanup-mysql.sql
```
......@@ -393,7 +393,7 @@ curl -s -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"versi
The command is expected to give an immediate JSON response similiar to :
```sh
{"id":140715758026879,"jsonrpc":"2.0","result":"Zonemaster Test Engine Version: v1.0.2"}
{ "jsonrpc": "2.0", "id": 1, "result": { "zonemaster_backend": "1.0.7", "zonemaster_engine": "v1.0.14" } }
```
## <a name="freebsd"></a>3. FreeBSD
......@@ -439,7 +439,7 @@ service postgresql start
### 3.4 Installation of the backend
```sh
cpan -i Zonemaster::WebBackend
cpan -i Zonemaster::Backend
```
### 3.5 Directory and file manipulation
......@@ -449,12 +449,12 @@ mkdir /etc/zonemaster
mkdir "$HOME/logs"
```
The Zonemaster::WebBackend module installs a number of configuration files in a
The Zonemaster::Backend module installs a number of configuration files in a
shared data directory. This section refers to the shared data directory as the
current directory, so locate it and go there like this:
```sh
cd `perl -MFile::ShareDir -le 'print File::ShareDir::dist_dir("Zonemaster-WebBackend")'`
cd `perl -MFile::ShareDir -le 'print File::ShareDir::dist_dir("Zonemaster-Backend")'`
```
Copy the `backend_config.ini` file to `/etc/zonemaster`.
......@@ -514,8 +514,8 @@ psql -U pgsql -f ./initial-postgres.sql template1
### 3.8 Service startup
```sh
starman --error-log="$HOME/logs/error.log" --pid-file="$HOME/logs/starman.pid" --listen=127.0.0.1:5000 --daemonize /usr/local/bin/zonemaster_webbackend.psgi
zm_wb_daemon start
starman --error-log="$HOME/logs/error.log" --pid-file="$HOME/logs/starman.pid" --listen=127.0.0.1:5000 --daemonize /usr/local/bin/zonemaster_backend_rpcapi.psgi
zonemaster_backend_testagent start
```
### 3.9 Post-installation sanity check
......@@ -530,7 +530,7 @@ curl -s -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"versi
The command is expected to give an immediate JSON response similiar to :
```sh
{"id":140715758026879,"jsonrpc":"2.0","result":"Zonemaster Test Engine Version: v1.0.2"}
{ "jsonrpc": "2.0", "id": 1, "result": { "zonemaster_backend": "1.0.7", "zonemaster_engine": "v1.0.14" } }
```
## What to do next?
......
package Zonemaster::WebBackend;
package Zonemaster::Backend;
our $VERSION = '1.2.0';
......
package Zonemaster::WebBackend::Config;
package Zonemaster::Backend::Config;
our $VERSION = '1.1.0';
use strict;
......@@ -16,7 +16,7 @@ elsif ( -e '/etc/zonemaster/backend_config.ini' ) {
$path = '/etc/zonemaster/backend_config.ini';
}
else {
$path = dist_file('Zonemaster-WebBackend', "backend_config.ini");
$path = dist_file('Zonemaster-Backend', "backend_config.ini");
}
......
package Zonemaster::WebBackend::DB;
package Zonemaster::Backend::DB;
our $VERSION = '1.2.0';
......@@ -42,7 +42,7 @@ sub _get_allowed_id_field_name {
$id_field = 'hash_id';
}
else {
if ($test_id <= Zonemaster::WebBackend::Config->force_hash_id_use_in_API_starting_from_id()) {
if ($test_id <= Zonemaster::Backend::Config->force_hash_id_use_in_API_starting_from_id()) {
$id_field = 'id';
}
else {
......@@ -60,7 +60,7 @@ sub get_test_request {
my ( $id, $hash_id );
my $lock_on_queue = Zonemaster::WebBackend::Config->lock_on_queue();
my $lock_on_queue = Zonemaster::Backend::Config->lock_on_queue();
if ( defined $lock_on_queue ) {
( $id, $hash_id ) = $dbh->selectrow_array( qq[ SELECT id, hash_id FROM test_results WHERE progress=0 AND queue=? ORDER BY priority DESC, id ASC LIMIT 1 ], undef, $lock_on_queue );
}
......@@ -71,7 +71,7 @@ sub get_test_request {
if ($id) {
$dbh->do( q[UPDATE test_results SET progress=1 WHERE id=?], undef, $id );
if ( $id > Zonemaster::WebBackend::Config->force_hash_id_use_in_API_starting_from_id() ) {
if ( $id > Zonemaster::Backend::Config->force_hash_id_use_in_API_starting_from_id() ) {
$result_id = $hash_id;
}
else {
......
package Zonemaster::WebBackend::DB::MySQL;
package Zonemaster::Backend::DB::MySQL;
our $VERSION = '1.1.0';
......@@ -10,19 +10,19 @@ use DBI qw(:utils);
use JSON::PP;
use Digest::MD5 qw(md5_hex);
use Zonemaster::WebBackend::Config;
use Zonemaster::Backend::Config;
with 'Zonemaster::WebBackend::DB';
with 'Zonemaster::Backend::DB';
has 'dbhandle' => (
is => 'rw',
isa => 'DBI::db',
);
my $connection_string = Zonemaster::WebBackend::Config->DB_connection_string( 'mysql' );
my $connection_string = Zonemaster::Backend::Config->DB_connection_string( 'mysql' );
my $connection_args = { RaiseError => 1, AutoCommit => 1 };
my $connection_user = Zonemaster::WebBackend::Config->DB_user();
my $connection_password = Zonemaster::WebBackend::Config->DB_password();
my $connection_user = Zonemaster::Backend::Config->DB_user();
my $connection_password = Zonemaster::Backend::Config->DB_password();
sub dbh {
my ( $self ) = @_;
......@@ -123,7 +123,7 @@ SELECT id, hash_id FROM test_results WHERE params_deterministic_hash = ? AND (TO
if ( $recent_id ) {
# A recent entry exists, so return its id
if ( $recent_id > Zonemaster::WebBackend::Config->force_hash_id_use_in_API_starting_from_id() ) {
if ( $recent_id > Zonemaster::Backend::Config->force_hash_id_use_in_API_starting_from_id() ) {
$result_id = $recent_hash_id;
}
else {
......@@ -148,7 +148,7 @@ SELECT id, hash_id FROM test_results WHERE params_deterministic_hash = ? AND (TO
my ( $id, $hash_id ) = $dbh->selectrow_array(
"SELECT id, hash_id FROM test_results WHERE params_deterministic_hash='$test_params_deterministic_hash' ORDER BY id DESC LIMIT 1" );
if ( $id > Zonemaster::WebBackend::Config->force_hash_id_use_in_API_starting_from_id() ) {
if ( $id > Zonemaster::Backend::Config->force_hash_id_use_in_API_starting_from_id() ) {
$result_id = $hash_id;
}
else {
......@@ -221,7 +221,7 @@ sub get_test_history {
my @results;
my $use_hash_id_from_id = Zonemaster::WebBackend::Config->force_hash_id_use_in_API_starting_from_id();
my $use_hash_id_from_id = Zonemaster::Backend::Config->force_hash_id_use_in_API_starting_from_id();
my $sth = $self->dbh->prepare(
q[SELECT
......
package Zonemaster::WebBackend::DB::PostgreSQL;
package Zonemaster::Backend::DB::PostgreSQL;
our $VERSION = '1.1.0';
......@@ -10,20 +10,20 @@ use JSON::PP;
use Digest::MD5 qw(md5_hex);
use Encode;
use Zonemaster::WebBackend::DB;
use Zonemaster::WebBackend::Config;
use Zonemaster::Backend::DB;
use Zonemaster::Backend::Config;
with 'Zonemaster::WebBackend::DB';
with 'Zonemaster::Backend::DB';
has 'dbhandle' => (
is => 'rw',
isa => 'DBI::db',
);
my $connection_string = Zonemaster::WebBackend::Config->DB_connection_string( 'postgresql' );
my $connection_string = Zonemaster::Backend::Config->DB_connection_string( 'postgresql' );
my $connection_args = { RaiseError => 1, AutoCommit => 1 };
my $connection_user = Zonemaster::WebBackend::Config->DB_user();
my $connection_password = Zonemaster::WebBackend::Config->DB_password();
my $connection_user = Zonemaster::Backend::Config->DB_user();
my $connection_password = Zonemaster::Backend::Config->DB_password();
sub dbh {
my ( $self ) = @_;
......@@ -144,7 +144,7 @@ sub create_new_test {
my ( $id, $hash_id ) = $dbh->selectrow_array(
"SELECT id, hash_id FROM test_results WHERE params_deterministic_hash='$test_params_deterministic_hash' ORDER BY id DESC LIMIT 1" );
if ( $id > Zonemaster::WebBackend::Config->force_hash_id_use_in_API_starting_from_id() ) {
if ( $id > Zonemaster::Backend::Config->force_hash_id_use_in_API_starting_from_id() ) {
$result = $hash_id;
}
else {
......@@ -197,7 +197,7 @@ sub get_test_history {
$p->{offset} //= 0;
$p->{limit} //= 200;
my $use_hash_id_from_id = Zonemaster::WebBackend::Config->force_hash_id_use_in_API_starting_from_id();
my $use_hash_id_from_id = Zonemaster::Backend::Config->force_hash_id_use_in_API_starting_from_id();
my $undelegated =
( defined $p->{frontend_params}->{nameservers} )
? ( "AND (params->'nameservers') IS NOT NULL" )
......
package Zonemaster::WebBackend::DB::SQLite;
package Zonemaster::Backend::DB::SQLite;
our $VERSION = '1.1.0';
......@@ -9,11 +9,11 @@ use DBI qw(:utils);
use JSON::PP;
use Digest::MD5 qw(md5_hex);
use Zonemaster::WebBackend::Config;
use Zonemaster::Backend::Config;
with 'Zonemaster::WebBackend::DB';
with 'Zonemaster::Backend::DB';
my $connection_string = Zonemaster::WebBackend::Config->DB_connection_string( 'sqlite' );
my $connection_string = Zonemaster::Backend::Config->DB_connection_string( 'sqlite' );
has 'dbh' => (
is => 'ro',
......
package Zonemaster::WebBackend::Engine;
package Zonemaster::Backend::RPCAPI;
our $VERSION = '1.1.0';
......@@ -21,8 +21,8 @@ use Zonemaster;
use Zonemaster::Nameserver;
use Zonemaster::DNSName;
use Zonemaster::Recursor;
use Zonemaster::WebBackend::Config;
use Zonemaster::WebBackend::Translator;
use Zonemaster::Backend::Config;
use Zonemaster::Backend::Translator;
my $recursor = Zonemaster::Recursor->new;
......@@ -42,7 +42,7 @@ sub new {
}
else {
eval {
my $backend_module = "Zonemaster::WebBackend::DB::" . Zonemaster::WebBackend::Config->BackendDBType();
my $backend_module = "Zonemaster::Backend::DB::" . Zonemaster::Backend::Config->BackendDBType();
eval "require $backend_module";
die $@ if $@;
$self->{db} = $backend_module->new();
......@@ -58,7 +58,7 @@ sub version_info {
my %ver;
$ver{zonemaster_engine} = Zonemaster->VERSION;
$ver{zonemaster_backend} = Zonemaster::WebBackend::Engine->VERSION;
$ver{zonemaster_backend} = Zonemaster::Backend::RPCAPI->VERSION;
return \%ver;
}
......@@ -247,17 +247,17 @@ sub add_user_ip_geolocation {
my ( $self, $params ) = @_;
if ($params->{user_ip}
&& Zonemaster::WebBackend::Config->Maxmind_ISP_DB_File()
&& Zonemaster::WebBackend::Config->Maxmind_City_DB_File()
&& Zonemaster::Backend::Config->Maxmind_ISP_DB_File()
&& Zonemaster::Backend::Config->Maxmind_City_DB_File()
) {
my $ip = new Net::IP::XS($params->{user_ip});
if ($ip->iptype() eq 'PUBLIC') {
require Geo::IP;
my $gi = Geo::IP->new(Zonemaster::WebBackend::Config->Maxmind_ISP_DB_File());
my $gi = Geo::IP->new(Zonemaster::Backend::Config->Maxmind_ISP_DB_File());
my $isp = $gi->isp_by_addr($params->{user_ip});
require GeoIP2::Database::Reader;