mirror of
https://github.com/PurpleI2P/regi2p.git
synced 2025-02-06 06:44:14 +00:00
add BOB lookuplocal support, checker retries
Signed-off-by: r4sas <r4sas@i2pmail.org>
This commit is contained in:
parent
87a5ea1acc
commit
5166c2c57c
@ -16,6 +16,7 @@ $options = [
|
||||
'bob_port' => '2827',
|
||||
'bob_options' => 'inbound.quantity=5 outbound.quantity=5 inbound.length=1 outbound.length=1 i2cp.leaseSetType=3',
|
||||
'bob_nick' => 'hostchecker',
|
||||
'check_tries' => 1,
|
||||
'http_proxy' => 'tcp://127.0.0.1:4444', // this is HTTP proxy, which must be specified as tcp protocol because we using stream context
|
||||
|
||||
/* Service settings */
|
||||
|
13
lib/bob.php
13
lib/bob.php
@ -136,6 +136,19 @@ class BOB {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function lookuplocal(string $address): bool
|
||||
{
|
||||
$command = "lookuplocal " . $address . "\n";
|
||||
socket_write($this->sock, $command, strlen($command));
|
||||
|
||||
$response = socket_read($this->sock, 1024, PHP_NORMAL_READ);
|
||||
|
||||
if(preg_match('/^OK/', $response))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function stop()
|
||||
{
|
||||
$command = "stop\n";
|
||||
|
@ -27,9 +27,19 @@ class Checker implements Task
|
||||
public function run(Environment $environment)
|
||||
{
|
||||
$bob = new BOB($this->options);
|
||||
|
||||
$bob->getnick();
|
||||
|
||||
$result = false;
|
||||
for ($i = 0, $tries = $this->options['check_tries']; $i < $tries; ++$i) {
|
||||
$result = $bob->lookuplocal($this->base32 . ".b32.i2p");
|
||||
if(!$result) {
|
||||
$result = $bob->lookup($this->base32 . ".b32.i2p");
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$bob = null;
|
||||
echo "Processed " . $this->base32 . ": " . ($result ? "online" : "offline") . PHP_EOL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user