Skip to content
Snippets Groups Projects
Commit 3b8f0c65 authored by Davide Aprea's avatar Davide Aprea
Browse files

restrict list of searx instances

parent 4782b136
No related branches found
No related tags found
1 merge request!1Development
...@@ -45,15 +45,29 @@ class SearxInstances extends Command ...@@ -45,15 +45,29 @@ class SearxInstances extends Command
curl_close($ch); curl_close($ch);
$response = json_decode($response); $response = json_decode($response);
if($response !== null){ if($response !== null){
$f = fopen('storage/instances.txt', 'w'); $instances = [];
foreach($response->instances as $instance => $data) { foreach($response->instances as $instance => $data) {
if(!isset($data->{'error'}) && $data->{'network_type'} !== 'tor') { if(!isset($data->{'error'}) &&
fwrite($f, $instance . "\n"); $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); fclose($f);
} else { } else {
echo "Unable to locate file. Check https://searx.space/data/instances.json for more info\n"; echo "Unable to locate file. Check https://searx.space/data/instances.json for more info\n";
} }
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment