Closed davidovski closed 1 year ago
Great job here! Unfortunately, there is also an issue I mentioned in https://github.com/hnhx/librex/issues/251#issuecomment-1659694405: When librex accessed through API, user can end up redirected to the search page, not the api.
Thanks for pointing that out. While I was trying to think about how to implement that elegantly using the existing system, I came up with a better solution for the whole redirection system.
Rather than redirecting the user to a different instance, librex itself can fallback to using a different librex instance's API to generate search results. That way if one instance stops being able to access google, then it will still be able to display results to the user and all of these requests to other instances will be proxied by the librex instance itself. Since the api has already existed for a while, it will be backwards compatible so it should prove to give reliable results. Also, since it will just be collecting results from these instances, it should work with both the api and normal results.
There are a few issues with this however, for example, if not enough instances can access google, there is a potential for a loop of inter-instance requests that will cause the user to wait an indefinite amount of time for the results.
I'll try and figure something out, but I'm open to other ideas or suggestions.
Since the other PR (#261) conflicts with this one, I'm going to close this one for now.
Adresses #251 and other minor adjustments:
config.php.example
)I believe that the automatic redirection should be completely opt-in by users of an instance, since redirecting to another, potentially unknown, site can be a major security and privacy concern. Imagine if one instance went rouge and was still listed in
instances.json
, users of a completely unrelated instance may be redirected to this instance unwillingly and this may lead to this user's search results getting compromised, among other things. That's why I have set the defaults as above, allowing the user the choice to redirect to other instances if they want, while also allowing instance maintainers themselves to disable the feature entirely.As far as "trusted instances" go, I urge any instance maintainers that do wish to keep redirection on to maintain
instances.json
as they see fit, though unfortunately this is not configurable by the user themselves.Please test out this PR and let me know if there is anything broken / missing, especially since I am not all that confident in php myself. Thank you