mirror of
https://github.com/PurpleI2P/regi2p.git
synced 2025-02-11 11:44:14 +00:00
add marking disabled for long time domains, add periodic checks for them
Signed-off-by: r4sas <r4sas@i2pmail.org>
This commit is contained in:
parent
23d12d66c7
commit
ee04d00c70
@ -10,6 +10,7 @@ Requirements
|
|||||||
* i2pd with enabled BOB protocol
|
* i2pd with enabled BOB protocol
|
||||||
* `verifyhost` binary built inside i2pd-tools project folder
|
* `verifyhost` binary built inside i2pd-tools project folder
|
||||||
* PHP and php-fpm 7.2+
|
* PHP and php-fpm 7.2+
|
||||||
|
* php-intl package on PHP 7.4+ (php7.4-intl as example on Debian with PHP 7.4)
|
||||||
* Composer
|
* Composer
|
||||||
* Corntab (for jobs)
|
* Corntab (for jobs)
|
||||||
|
|
||||||
|
@ -14,7 +14,12 @@ $pdo = (new DB($options))->pdo;
|
|||||||
|
|
||||||
$results = [];
|
$results = [];
|
||||||
|
|
||||||
$STH = $pdo->query("SELECT `host`, `base32` FROM `hosts`");
|
/* Fetch hosts for check from database */
|
||||||
|
if ((($options['fullhour'] >= 0) && ($options['fullhour'] <= 23)) && date('H') == $options['fullhour']) { // check all hosts at full check hour
|
||||||
|
$STH = $pdo->query("SELECT `host`, `base32` FROM `hosts`");
|
||||||
|
} else {
|
||||||
|
$STH = $pdo->query("SELECT `host`, `base32` FROM `hosts` WHERE `disabled` = '0'");
|
||||||
|
}
|
||||||
$hosts = $STH->fetchAll(PDO::FETCH_KEY_PAIR);
|
$hosts = $STH->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||||
|
|
||||||
/* Start temporary BOB tunnel for checking */
|
/* Start temporary BOB tunnel for checking */
|
||||||
|
@ -31,4 +31,6 @@ $options = [
|
|||||||
'newdays' => 7, // assume host as new for that amout of days
|
'newdays' => 7, // assume host as new for that amout of days
|
||||||
'delnewdays' => 3, // if new host not seen more than X days, disable it and disapprove
|
'delnewdays' => 3, // if new host not seen more than X days, disable it and disapprove
|
||||||
'delolddays' => 30, // same as above, but for old hosts
|
'delolddays' => 30, // same as above, but for old hosts
|
||||||
|
|
||||||
|
'fullhour' => 8, // make hosts full-check at that hour (0-23). Usage of out-of-range value or at other hours, checker will validate only enabled domains.
|
||||||
];
|
];
|
||||||
|
34
export.php
34
export.php
@ -8,16 +8,16 @@ date_default_timezone_set ('UTC');
|
|||||||
$pdo = (new App\DB($options))->pdo;
|
$pdo = (new App\DB($options))->pdo;
|
||||||
$util = new App\Utils;
|
$util = new App\Utils;
|
||||||
|
|
||||||
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `add_date`, `last_seen`, `approved`, `initial` FROM hosts");
|
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `add_date`, `last_seen`, `approved`, `initial`, `disabled` FROM hosts");
|
||||||
$hosts = $STH->fetchAll(PDO::FETCH_ASSOC);
|
$hosts = $STH->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
// for automatic approving
|
// for automatic approving
|
||||||
$approffs = date ("Y-m-d H:i:s", strtotime ("-" . $options["approvedelay"] . " hour")); // approval offset
|
$approffs = date ("Y-m-d H:i:s", strtotime ("-" . $options["approvedelay"] . " hour")); // approval offset
|
||||||
$apprseen = date ("Y-m-d H:i:s", strtotime ("-" . $options["approveseen"] . " hour")); // approval maxseen offset
|
$apprseen = date ("Y-m-d H:i:s", strtotime ("-" . $options["approveseen"] . " hour")); // approval maxseen offset
|
||||||
|
|
||||||
$newregoffs = date ("Y-m-d H:i:s", strtotime ("-" . $options["newdays"] . " day"));
|
$newregoffs = date ("Y-m-d H:i:s", strtotime ("-" . $options["newdays"] . " day")); // 7
|
||||||
$newseenlim = date ("Y-m-d H:i:s", strtotime ("-" . $options["delnewdays"] . " day"));
|
$newseenlim = date ("Y-m-d H:i:s", strtotime ("-" . $options["delnewdays"] . " day")); // 3
|
||||||
$oldseenlim = date ("Y-m-d H:i:s", strtotime ("-" . $options["delolddays"] . " day"));
|
$oldseenlim = date ("Y-m-d H:i:s", strtotime ("-" . $options["delolddays"] . " day")); // 30
|
||||||
|
|
||||||
$export_full = $export_live = $export_init = [];
|
$export_full = $export_live = $export_init = [];
|
||||||
$export_addr_full = $export_addr_live = $export_addr_init = [];
|
$export_addr_full = $export_addr_live = $export_addr_init = [];
|
||||||
@ -31,10 +31,13 @@ foreach ($hosts as $host)
|
|||||||
array_push($export_addr_full, $domain . "," . $host["base32"]);
|
array_push($export_addr_full, $domain . "," . $host["base32"]);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
($options["approval"] == false || $host["approved"] == 1) && (
|
($options["approval"] == false || $host["approved"] == 1) &&
|
||||||
($host["add_date"] > $newregoffs && $host["last_seen"] > $newseenlim) ||
|
($host["disabled"] == 0 ||
|
||||||
($host["add_date"] < $newregoffs && $host["last_seen"] > $oldseenlim)
|
(
|
||||||
)
|
($host["add_date"] > $newregoffs && $host["last_seen"] > $newseenlim) ||
|
||||||
|
($host["add_date"] < $newregoffs && $host["last_seen"] > $oldseenlim)
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
array_push($export_live, $domain . "=" . $host["base64"]);
|
array_push($export_live, $domain . "=" . $host["base64"]);
|
||||||
@ -45,6 +48,11 @@ foreach ($hosts as $host)
|
|||||||
array_push($export_init, $domain . "=" . $host["base64"]);
|
array_push($export_init, $domain . "=" . $host["base64"]);
|
||||||
array_push($export_addr_init, $domain . "," . $host["base32"]);
|
array_push($export_addr_init, $domain . "," . $host["base32"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($host["disabled"] == 1)
|
||||||
|
{
|
||||||
|
$pdo->exec ("UPDATE `hosts` SET `disabled` = 0 WHERE `host` = '" . $host["host"] . "'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
$host["approved"] == 0 && (
|
$host["approved"] == 0 && (
|
||||||
@ -56,6 +64,16 @@ foreach ($hosts as $host)
|
|||||||
array_push($export_live, $domain . "=" . $host["base64"]);
|
array_push($export_live, $domain . "=" . $host["base64"]);
|
||||||
array_push($export_addr_live, $domain . "," . $host["base32"]);
|
array_push($export_addr_live, $domain . "," . $host["base32"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
$host["disabled"] == 0 &&
|
||||||
|
($host["add_date"] > $newregoffs && $host["last_seen"] < $newseenlim) ||
|
||||||
|
($host["add_date"] < $newregoffs && $host["last_seen"] < $oldseenlim)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$pdo->exec ("UPDATE `hosts` SET `disabled` = 1 WHERE `host` = '" . $host["host"] . "'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$STH = null;
|
$STH = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user