From 3b8f0c65c930696ee733947607a57480fc86f1d8 Mon Sep 17 00:00:00 2001 From: Davide Aprea <davide@suma-ev.de> Date: Mon, 1 Mar 2021 13:10:06 +0100 Subject: [PATCH] restrict list of searx instances --- app/Console/Commands/SearxInstances.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/SearxInstances.php b/app/Console/Commands/SearxInstances.php index cd7f637..bc4c066 100644 --- a/app/Console/Commands/SearxInstances.php +++ b/app/Console/Commands/SearxInstances.php @@ -45,15 +45,29 @@ class SearxInstances extends Command curl_close($ch); $response = json_decode($response); if($response !== null){ - $f = fopen('storage/instances.txt', 'w'); + $instances = []; foreach($response->instances as $instance => $data) { - if(!isset($data->{'error'}) && $data->{'network_type'} !== 'tor') { - fwrite($f, $instance . "\n"); + if(!isset($data->{'error'}) && + $data->{'network_type'} !== 'tor' && + isset($data->{'timing'}->{'search_go'}) && + isset($data->{'timing'}->{'search_go'}->{'all'}) && + isset($data->{'timing'}->{'search_go'}->{'all'}->{'median'}) && + $data->{'timing'}->{'search_go'}->{'all'}->{'median'} <= 1.8) { + try{ + $opensearch = file_get_contents($instance . 'opensearch.xml'); + if(!str_contains($opensearch, 'SyndicationRight')) { + $instances[] = $instance; + } + }catch(\Exception $e) { + + } } } + $f = fopen('storage/instances.txt', 'w'); + fwrite($f, implode("\n", $instances)); fclose($f); } else { echo "Unable to locate file. Check https://searx.space/data/instances.json for more info\n"; } } -} +} \ No newline at end of file -- GitLab