Skip to content

Commit

Permalink
Merge branch 'main' into mmatteini-fix-qwantapi
Browse files Browse the repository at this point in the history
  • Loading branch information
michelematteini authored Dec 19, 2023
2 parents 1d3e61c + 18dda2c commit ecf1725
Show file tree
Hide file tree
Showing 72 changed files with 2,256 additions and 1,515 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.github/
.git/
.gitignore
.dockerignore
config.php.example
docker-compose.yml
Dockerfile
opensearch.xml.example
README.md
docker-old/
35 changes: 35 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Docker Image CI
on:
push:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v3
- uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: owner
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository_owner }}
- id: repo
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.event.repository.name }}

- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ steps.owner.outputs.lowercase }}/${{ steps.repo.outputs.lowercase }}:latest
44 changes: 20 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,46 +1,42 @@
# syntax = edrevo/dockerfile-plus
ARG VERSION="3.18"
FROM alpine:${VERSION} AS librex
FROM alpine:3.18

WORKDIR "/var/www/html"

ADD "." "."

# Docker metadata contains information about the maintainer, such as the name, repository, and support email
# Please add any necessary information or correct any incorrect information
# See more: https://docs.docker.com/config/labels-custom-metadata/
LABEL name="LibreX" \
LABEL name="LibreY" \
description="Framework and javascript free privacy respecting meta search engine" \
version="1.0" \
vendor="Hnhx Femboy<femboy.hu>" \
maintainer="Hnhx Femboy<femboy.hu>, Junior L. Botelho<juniorbotelho.com.br>" \
url="https://github.com/hnhx/librex" \
usage="https://github.com/hnhx/librex/wiki" \
authors="https://github.com/hnhx/librex/contributors"
vendor="Ahwx <ahwx.org>" \
maintainer="Ahwx <ahwx.org>" \
url="https://github.com/Ahwxorg/LibreY" \
authors="https://github.com/Ahwxorg/LibreY/contributors"

# Include arguments as temporary environment variables to be handled by Docker during the image build process
# Change or add new arguments to customize the image generated by 'docker build' command
ARG DOCKER_SCRIPTS="docker"
ARG NGINX_PORT=8080
# Set this argument during build time to indicate that the path is for php's www.conf
ARG WWW_CONFIG="/etc/php82/php-fpm.d/www.conf"

# Customize the environment during both execution and build time by modifying the environment variables added to the container's shell
# When building your image, make sure to set the 'TZ' environment variable to your desired time zone location, for example 'America/Sao_Paulo'
# See more: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
ENV TZ="America/New_York"

RUN apk add gettext --no-cache

# The following lines import all Dockerfiles from other folders so that they can be built together in the final build
INCLUDE+ docker/php/php.dockerfile
INCLUDE+ docker/server/nginx.dockerfile

# Include docker scripts, docker images, and the 'GNU License' in the Librex container
ADD "." "/var/www/html"
# Install required packages
RUN apk add gettext php82 php82-fpm php82-dom php82-curl php82-json php82-apcu nginx --no-cache

# Set permissions for script files as executable scripts inside 'docker/scripts' directory
RUN chmod u+x "${DOCKER_SCRIPTS}/php/prepare.sh" &&\
chmod u+x "${DOCKER_SCRIPTS}/server/prepare.sh" &&\
chmod u+x "${DOCKER_SCRIPTS}/entrypoint.sh" &&\
chmod u+x "${DOCKER_SCRIPTS}/attributes.sh"
# Configure PHP-FPM to listen on a Unix socket instead of a TCP port, which is more secure and efficient
RUN touch /run/php-fpm82.sock && chown nginx:nginx "/run/php-fpm82.sock"
RUN sed -i 's/^\s*listen = 127.0.0.1:9000/listen = \/run\/php-fpm82.sock/' ${WWW_CONFIG} &&\
sed -i 's/^\s*;\s*listen.owner = nobody/listen.owner = nginx/' ${WWW_CONFIG} &&\
sed -i 's/^\s*;\s*listen.group = nobody/listen.group = nginx/' ${WWW_CONFIG} &&\
sed -i 's/^\s*;\s*listen.mode = 0660/listen.mode = 0660/' ${WWW_CONFIG}

EXPOSE ${NGINX_PORT}

# Configures the container to be run as an executable.
ENTRYPOINT ["/bin/sh", "-c", "docker/entrypoint.sh"]
ENTRYPOINT ["/bin/sh", "-c", "docker/entrypoint.sh"]
69 changes: 26 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,48 @@
<h1 align="center">LibreX</h1>
<h1 align="center">LibreY</h1>

# Disclaimer

> LibreY is a fork of LibreX, a framework-less and javascript-free privacy respecting meta search engine, made by [hnhx](https://github.com/hnhx). LibreY changed some features like automatic redirection. The original code is written by [hnhx and contributors](https://github.com/hnhx/LibreX/contributors)
<p align="center">
<img src="https://user-images.githubusercontent.com/49120638/215327189-76c54dec-8b19-4faf-8c39-29a61aa3b143.png" width="400">
<img src="https://user-images.githubusercontent.com/49120638/215327239-b2a1cb07-3773-4ae7-bb3b-738de2cc3161.png" width="400">
</p>

<p align="center">Framework and javascript free privacy respecting meta search engine</p>

<br>

### Instances
<p align="center"></p>

| Clearnet | TOR | I2P | Country |
|-|-|-|-|
| [librex.zzls.xyz](https://librex.zzls.xyz/) | [](http://librex.zzlsghu6mvvwyy75mvga6gaf4znbp3erk5xwfzedb4gg6qqh2j6rlvid.onion/) | [](http://zzlsaymhcfla7vibo3a223bybeecu3bd5z6rmw2u4y76maqeu76q.b32.i2p) | 🇨🇱 CL |
| [librex.me](https://librex.me/) | [](http://librex.revvybrr6pvbx4n3j4475h4ghw4elqr4t5xo2vtd3gfpu2nrsnhh57id.onion/) | [](http://revekebotog64xrrammtsmjwtwlg3vqyzwdurzt2pu6botg4bejq.b32.i2p/) | 🇨🇦 CA |
| [s.dyox.in](https://s.dyox.in/) | [](http://ddhigxwjz7elcl2erm7qzzukda4qmovoy4cepcueahggpwrpu24mi6qd.onion/) | [](http://s.dyoxin.i2p/) | 🇮🇸 IS |
| [lx.vern.cc](https://lx.vern.cc/) | [](http://lx.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/) | [](http://vernziqfqvweijfaacmwazohgpdo2bt2ib2jlupt2pwwu27bhgxq.b32.i2p/) | 🇺🇸 US |
| [search.ahwx.org](https://search.ahwx.org/) | [](http://cosrpybbddzdfjquer3zfmb2h5avtacnctnbu4gucwocdb42s63gcqqd.onion/) || 🇳🇱 NL |
| [search.spaceint.fr](https://search.spaceint.fr/) | [](http://6d4nqt2rndvmhogpwrbqfvj2ur6e6nm2r6dzi7ny4wj6ai3j5hnvbhyd.onion/) || 🇫🇷 FR |
| [search.davidovski.xyz](https://search.davidovski.xyz/) ||| 🇬🇧 UK |
| [search.madreyk.xyz](https://search.madreyk.xyz/) ||| 🇩🇪 DE |
| [search.pabloferreiro.es](https://search.pabloferreiro.es/) ||| 🇩🇪 DE |
| [librex.pufe.org](https://librex.pufe.org/) ||| :new_zealand: NZ |
| [librex.ratakor.com](https://librex.ratakor.com/) ||| 🇫🇷 FR |
| [search.tildevarsh.in](https://search.tildevarsh.in/) ||| 🇮🇳 IN |
| [librex.myroware.eu](https://librex.myroware.eu/) ||| 🇩🇪 DE |
| [librex.bloatcat.tk](https://librex.bloatcat.tk/) ||| 🇮🇸 IS |
| [librex.retro-hax.net](https://librex.retro-hax.net/) ||| 🇩🇪 DE |
| [search.funami.tech](https://search.funami.tech/) ||| 🇰🇷 KR |
| [search.zeroish.xyz](https://search.zeroish.xyz/) ||| 🇺🇸 US |
| [librex.baczek.me](https://librex.baczek.me/) ||| 🇵🇱 PL |
| [librex.yogeshlamichhane.com.np](https://librex.yogeshlamichhane.com.np/) ||| 🇺🇸 US |
| [lx.benike.monster](https://lx.benike.monster/) ||| 🇩🇪 DE |
| [librex.nohost.network](https://librex.nohost.network/) ||| 🇲🇽 MX |
| [search.decentrala.org](https://search.decentrala.org/) ||| 🇺🇸 US |
<br>

### Thanks rms
## Matrix

Huge thanks to Richard Stallman for using LibreX and featuring it on his [website](https://stallman.org/stallman-computing.html)!
If there's an important announcement, we do have a Matrix chatroom which you can join over at #librey:ahwx.org.

> However, the Librex proxies have worked around that problem. They enable me to access Google Search indirectly, and they work correctly through Tor with LibreJS enabled.
### Instances

You can find a list of instances on any LibreY instance by accessing /instances.php.<br>
Alternatively look at `instances.json` where the list is generated from.<br><br>
While the official instances may be more updated and have better uptime, please consider using another person's instances as these are heavily overloaded.<br>
Support the community. ❤️<br><br>
[@Ahwxorg](https://github.com/Ahwxorg)'s instances:<br>
[search.ahwx.org](https://search.ahwx.org/instances.php)<br>
[Tor](http://wn5jl6fxlzzfenlyu3lc4q7jpw2saplrywxvxtvqbguotwd4y5cjeuqd.onion/instances.php)<br>
[search2.ahwx.org](https://search.ahwx.org/instances.php)<br>
[Tor](http://hyy7rcvknwb22v4nnoar635wntiwr4uwzhiuyimemyl4fz6k7tahj5id.onion/instances.php)<br>
<br>
[@davidovski](https://github.com/davidovski)'s instance:<br>
[search.davidovski.xyz](https://search.davidovski.xyz/instances.php)<br>
<br>

### About LibreX

LibreX gives you results from Google, Qwant, Ahmia and popular torrent sites without spying on you.
<br>LibreX doesn't save any type of data about the user, there are no logs, no caches.
<br>
<br>
If you would like to learn more about LibreX check out the [Wiki](https://github.com/hnhx/librex/wiki).
<br>
<br>
### About LibreY

LibreY gives you text results from DuckDuckGo or Google, images from Qwant, and torrents from i.e. Ahmia and popular torrent sites without spying on you.
<br>LibreY doesn't save **any** type of data about the user, there are no logs (except NGINX logs if the host sets them).

### LibreX compared to other metasearch engines
### LibreY compared to other metasearch engines

| Name | Works without JS | Privacy frontend redirect | Torrent results | API | No 3rd party libs used |
|-|-|-|-|-|-|
| LibreX ||||||
| LibreY ||||||
| SearXNG | ❓ Not user friendly | ❓ Only host can set it ||||
| Whoogle || ❓ Only host can set it ||||
9 changes: 9 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Security Policy

## Supported Versions

Basically the latest commit. We don't really do versioning with LibreY.

## Reporting a Vulnerability

Please join #librey:ahwx.org on Matrix and please DM me (@ahwx:ahwx.org) or if Matrix is absolutely impossible, email me; ahwx *at* ahwx *dot* org
59 changes: 11 additions & 48 deletions api.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<?php
$config = require "config.php";
require "misc/search_engine.php";
require "locale/localization.php";

$opts = load_opts();
if ($opts->disable_api) {
echo "<p>" . TEXTS["api_unavailable"] . "</p>";
die();
}

require "misc/tools.php";

if (!isset($_REQUEST["q"]))
{
if (!$opts->query) {
echo "<p>Example API request: <a href=\"./api.php?q=gentoo&p=2&t=0\">./api.php?q=gentoo&p=2&t=0</a></p>
<br/>
<p>\"q\" is the keyword</p>
Expand All @@ -16,51 +23,7 @@
die();
}

$query = $_REQUEST["q"];
$query_encoded = urlencode($query);
$page = isset($_REQUEST["p"]) ? (int) $_REQUEST["p"] : 0;
$type = isset($_REQUEST["t"]) ? (int) $_REQUEST["t"] : 0;

$results = array();

switch ($type)
{
case 0:
require "engines/google/text.php";
$results = get_text_results($query, $page);
break;
case 1:
require "engines/qwant/image.php";
$results = get_image_results($query_encoded, $page);
break;
case 2:
require "engines/invidious/video.php";
$results = get_video_results($query_encoded);
break;
case 3:
if ($config->disable_bittorent_search)
$results = array("error" => "disabled");
else
{
require "engines/bittorrent/merge.php";
$results = get_merged_torrent_results($query_encoded);
}
break;
case 4:
if ($config->disable_hidden_service_search)
$results = array("error" => "disabled");
else
{
require "engines/ahmia/hidden_service.php";
$results = get_hidden_service_results($query_encoded);
}
break;
default:
require "engines/google/text.php";
$results = get_text_results($query_encoded, $page);
break;
}

$results = fetch_search_results($opts, false);
header("Content-Type: application/json");
echo json_encode($results);
?>
6 changes: 6 additions & 0 deletions auto_updater.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
while true; do
git stash
git pull
sleep 60
done
Loading

0 comments on commit ecf1725

Please sign in to comment.