Commit Graph

56 Commits (main)

Author SHA1 Message Date
Simon Rusinov 6f9d11a6ed
Optionally build obfs4proxy in docker (#1032) 9 months ago
Ben Busby 74f7975e62
Split crypto + pyopenssl reqs for armv7 builds
Since including rust in the builder stage of the image didn't address
the issues with building the cryptography library on armv7, that
architecture will just use the last supported version of the affected
libraries. May want to revisit this later.
1 year ago
Ben Busby 0c65eb9616
[Docker] Include cargo in builder stage
Cryptography package also requires cargo to be present (in addition
to rust) when building.
1 year ago
Ben Busby 3f827bbf19
[Docker] Include rust in builder stage
The python cryptography library isn't able to be built without the rust
compiler for some stages the cross-platform buildx workflow. This hasn't
been the case in the past, but for some reason since upgrading to the
latest cryptography version there are now errors with installing that
package. Since dependencies in the builder stage are not included in the
final build, we can safely include rust as a fallback to ensure this
doesn't happen without bloating the size of the final build.
1 year ago
Ben Busby 6b56dab4c1
Remove ig->bibliogram redirects
Bibliogram has been discontinued, and the remaining instances aren't
very reliable. As a result, all instagram redirects have been removed.

Fixes #955
1 year ago
Ben Busby fdc63b862e
Autoload `whoogle.env` if it exists
The whoogle.env file previously needed to be created and enabled using
the WHOOGLE_DOTENV var. This removes the second step and loads the env
file if it's found during app init.

The Dockerfile has also been updated to copy in whoogle.env if it
exists.

Fixes #909
1 year ago
João 74503d542e
Encode config params in URL (#842)
Adds support for encoding (and optionally encrypting) user config values as
a single string that can be passed to any endpoint with the "preferences" url
param.

Co-authored-by: Ben Busby <contact@benbusby.com>
2 years ago
Ben Busby bf92944b95
Support quora and imdb alts through Farside
Farside can now redirect quora links to querte instances and imdb links
to libremdb instances. This updates Whoogle to perform link replacements
for both services when site alts are configured.
2 years ago
gdm85 6d362ca5c7
Add support for relative search results (#715)
* Relativization of search results

* Fix JavaScript error when opening images

* Replace single-letter logo and remove sign-in link

* Add `WHOOGLE_URL_PREFIX` env var to support relative path redirection

The `WHOOGLE_URL_PREFIX` var can now be set to fix internal app
redirects, such as the `/session` redirect performed on the first visit
to the Whoogle home page.

Co-authored-by: Ben Busby <contact@benbusby.com>
2 years ago
Ben Busby 788730cdc2
Update default bibliogram link in Dockerfile
Bibliogram uses a slightly different URL format than Instagram, and
requires a "u/" before the username when replacing Instagram links. This
was already implemented everywhere else except the Dockerfile.
2 years ago
Ben Busby 0048c2f9aa
Update remaining alternative frontends to use Farside
Wikipedia, imgur, and translate alternatives were all still using
hardcoded URLs when replaced with their respective alternative frontend.
This updates them to use farside instead.
2 years ago
Albony Cal c3634a5135
Upgrade Python image in Dockerfile (#669)
Vulnerable Python image upgraded to python:3.11.0a5-alpine
2 years ago
Ben Busby e72d8437f7
[Docker] Split config dir creation/set permissions
If the config dir already exists, setting the mode (`-m 777`) doesn't
actually work as it should. This change splits the command into two
separate commands for directory creation and enabling the directory to
be writable by all.

Fixes #658
2 years ago
Ben Busby 9cbd7bd9d3
Remove bash dependency
Depending on bash wasn't strictly necessary, as the two minimal scripts
in the repo were both nearly POSIX anyways.

Aside from simplifying the repo's dependencies a little bit, this also
helps reduce the overall Docker image size as an added bonus.
2 years ago
ras07 ecb4277e69
Run container as non-root `whoogle` user (#617)
Creates a non-root user ("whoogle"), and runs the container as that user.
2 years ago
ras07 09a0039a38
Make `/config` directory writable by all (#616)
The `/config` directory needs to be writable by all in order to run the container
as a non-root user.
2 years ago
Ben Busby 4dd01cdfda
Fix Dockerfile syntax errors 2 years ago
DUO Labs 74cb48086c
Introduce site alts for imgur and wikipedia (#609)
* Add `WHOOGLE_ALT_IMG` for a replacement for imgur.

* Add `WHOOGLE_ALT_WIKI` for Wikipedia
2 years ago
Ben Busby a2d5a23c43
docker: Upgrade pip before installing requirements
Outdated pip versions require a rust compiler to install the
cryptography package. Ensuring that pip is up to date should eliminate
the recent buildx errors where a prebuilt cryptography wheel is not
available.
2 years ago
Roy Zuo dec6d80dda
Use alpine docker image (#573) 2 years ago
Ben Busby 634d179568
Use farside.link for frontend alternatives in results (#560)
* Integrate Farside into Whoogle

When instances are ratelimited (when a captcha is returned instead of
the user's search results) the user can now hop to a new instance via
Farside, a new backend service that redirects users to working instances
of a particular frontend. In this case, it presents a user with a
Farside link to a new Whoogle (or Searx) instance instead, so that the
user can resume their search.

For the generated Farside->Whoogle link, the generated link includes the
user's current Whoogle configuration settings as URL params, to ensure a
more seamless transition between instances. This doesn't translate to
the Farside->Searx link, but potentially could with some changes.

* Expand conversion of config<->url params

Config settings can now be translated to and from URL params using a
predetermined set of "safe" keys (i.e. config settings that easily
translate to URL params).

* Allow jumping instances via Farside when ratelimited

When instances are ratelimited (when a captcha is returned instead of
the user's search results) the user can now hop to a new instance via
Farside, a new backend service that redirects users to working instances
of a particular frontend. In this case, it presents a user with a
Farside link to a new Whoogle (or Searx) instance instead, so that the
user can resume their search.

For the generated Farside->Whoogle link, the generated link includes the
user's current Whoogle configuration settings as URL params, to ensure a
more seamless transition between instances. This doesn't translate to
the Farside->Searx link, but potentially could with some changes.

Closes #554

Closes #559
2 years ago
Ben Busby 6a229eba5f
Skip copying whoogle.env in Dockerfile 3 years ago
Ben Busby ca782875c2
Conditionally load .env file in Dockerfile
With 843632a, whoogle.env is now gitignored and should only be created
by users from the whoogle.template.env file. Since the file no longer
exists, the docker build cannot copy it in by default. This just
conditionally copies the file in if it exists.
3 years ago
Vansh Comar 79fb7531be
Implement scribe.rip replacement for medium.com results (#463)
scribe.rip is a privacy respecting front end for medium.com. This
feature allows medium.com results to be replaced with scribe.rip links,
and works for both regular medium.com domains as well as user specific
subdomains (i.e. user.medium.com).

[scribe.rip website](https://scribe.rip)
[scribe.rip source code](https://git.sr.ht/~edwardloveall/scribe)

Co-authored-by: Ben Busby <noreply+git@benbusby.com>
3 years ago
Ben Busby 958faed1b6
Set user ownership of static build dir 3 years ago
Ben Busby bcb1d8ecc9
Add lingva translation support in search (#360)
* Add support for Lingva translations in results

Searches that contain the word "translate" and are normal search queries
(i.e. not news/images/video/etc) now create an iframe to a Lingva url to
translate the user's search using their configured search language.

The Lingva url can be configured using the WHOOGLE_ALT_TL env var, or
will fall back to the official Lingva instance url (lingva.ml).

For more info, visit https://github.com/TheDavidDelta/lingva-translate

* Add basic test for lingva results

* Allow user specified lingva instances through csp frame-src

* Fix pep8 issue
3 years ago
Ben Busby 1fdf226802
Use curl-based healthcheck w/ new non-auth route
The wget method seemed to have a possible issue with creating endless
index.html copies (despite being specified to output to console only),
so this has been updated to use curl instead.

Also uses new non-authenticated "healthz" route to perform the
healthcheck.

Fix #316

Fix #313
3 years ago
Ben Busby cb80c181a6
Direct wget output in Docker healthcheck to stdout
wget's default behavior to download contents to a file is not always a
valid method to use as a Docker healthcheck, due to permission issues.
This circumvents any issues there by redirecting the healthcheck output
to stdout, which shouldn't cause any issues regardless of context.

Fixes #272
3 years ago
Ben Busby 0baba58896
Reduce docker healthcheck interval from 5m to 30s
See #270
3 years ago
Suika b6b175a2ee
Add wget to container build (#264) 3 years ago
Shimul 8a10efaa01 Allow setting environment variables in whoogle.env (#237)
This allows the user to enable their preferred settings in a variety of
ways, depending on their deployment preference. Values added to
whoogle.env can be enabled using WHOOGLE_DOTENV=1, in which case all
values in the env var file will overwrite defaults or user provided
settings.

Co-authored-by: Ben Busby <benbusby@protonmail.com>
3 years ago
Shimul c89e5b3f4e Fixing typo in Dockerfile (#235) 3 years ago
Ben Busby b87619a133 Add heroku-regen script, rename config/ -> misc/
Introduces a new script for quickly regenerating a Heroku instance
(typically with a new IP) to handle the rare circumstances where an
instance is flagged by Google and prompted for a captcha.

The config/ dir was renamed to misc/ to avoid confusion with the Docker
mounted config volume, and to more closely match its intended purpose
(which is to contain all miscellaneous features/scripts/etc that add
functionality to Whoogle, but are not critical for general use).
3 years ago
Ben Busby e5d1f6a292 Add healthcheck to Dockerfile
See #184
3 years ago
Ben Busby b7b6fb7c04 Move ssl install to Dockerfile build stage 3 years ago
Basti 36b350e1cd Use multi-stage container build (#210)
This only adds necessary packages and files from the repo to reduce the image size.

Co-authored-by: pred2k <does@not.exists>
3 years ago
Ben Busby 6600d8580c Add ability to redirect reddit.com to libredd.it (#180)
* Adds the ability to redirect reddit.com to libredd.it using the existing
 "site alts" config setting.

This adds the WHOOGLE_ALT_RD environment variable for optionally
redirecting reddit links to libreddit
(https://github.com/spikecodes/libreddit).

* Include libreddit in home page site alt note
3 years ago
Ben Busby 0a6575d219
Hotfix: Move language/country json to app dir
Pip installs of whoogle search were missing access to the misc/ folder,
which previously contained the language and country json files. These
have been moved to app/misc, and the previous root level misc/ was
renamed to config/ (since it now only contains the tor config files).

Bump to 0.3.1.
3 years ago
Ben Busby 7e39b4e7a0
Fix default site alts in Dockerfile
The Dockerfile was incorrectly assigning an empty string to the site alt
values, which caused the filter to update relevant sites with an empty
host. This replaces the empty string with the correct domain for each
site alternative.
3 years ago
Ben Busby 934749e0b8
Add docker buildx gh action
This automatically builds and pushes a cross platform image to Docker
Hub.
3 years ago
Ben Busby 6c429e6dd1
Allow setting site alts using environment vars (#155)
* Add ability to configure site alts w/ env vars

Site alternatives (i.e. twitter.com -> nitter.net) can now be configured
using environment variables:

WHOOGLE_ALT_TW='nitter.net' # twitter alt
WHOOGLE_ALT_YT='invidio.us' # youtube alt
WHOOGLE_ALT_IG='bibliogram.art/u' # instagram alt

Updated testing to confirm results have been modified.

* Add site alt vars to docker settings and readme
3 years ago
Ben Busby 7a61220aa5 Update Dockerfile tor service init, refactor rc/ -> misc/
The tor service is now started by calling a script which runs tor
according to the current container user. If the user is root, the script
will begin the tor service as normal. Otherwise, it runs tor as the
current user. This primarily is meant to address the issue with Heroku
builds (which don't have a root user) not being able to start tor as a
service.

Also refactored the rc/ dir to misc/ (with a tor/ subdir) since that
makes more sense.
4 years ago
Ben Busby 0ef098069e
Add tor and http/socks proxy support (#137)
* Add tor and http/socks proxy support

Allows users to enable/disable tor from the config menu, which will
forward all requests through Tor.

Also adds support for setting environment variables for alternative
proxy support. Setting the following variables will forward requests
through the proxy:
    - WHOOGLE_PROXY_USER (optional)
    - WHOOGLE_PROXY_PASS (optional)
    - WHOOGLE_PROXY_TYPE (required)
      - Can be "http", "socks4", or "socks5"
    - WHOOGLE_PROXY_LOC  (required)
      - Format: "<ip address>:<port>"

See #30

* Refactor acquire_tor_conn -> acquire_tor_identity

Also updated travis CI to set up tor

* Add check for Tor socket on init, improve Tor error handling

Initializing the app sends a heartbeat request to Tor to check for
availability, and updates the home page config options accordingly. This
heartbeat is sent on every request, to ensure Tor support can be
reconfigured without restarting the entire app.

If Tor support is enabled, and a subsequent request fails, then a new
TorError exception is raised, and the Tor feature is disabled until a
valid connection is restored.

The max attempts has been updated to 10, since 5 seemed a bit too low
for how quickly the attempts go by.

* Change send_tor_signal arg type, update function doc

send_tor_signal now accepts a stem.Signal arg (a bit cleaner tbh). Also
added the doc string for the "disable" attribute in TorError.

* Fix tor identity logic in Request.send

* Update proxy init, change proxyloc var name

Proxy is now only initialized if both type and location are specified,
as neither have a default fallback and both are required. I suppose the
type could fall back to http, but seems safer this way.

Also refactored proxyurl -> proxyloc for the runtime args in order to
match the Dockerfile args.

* Add tor/proxy support for Docker builds, fix opensearch/init

The Dockerfile is now updated to include support for Tor configuration,
with a working torrc file included in the repo.

An issue with opensearch was fixed as well, which was uncovered during
testing and was simple enough to fix here. Likewise, DDG bang gen was
updated to only ever happen if the file didn't exist previously, as
testing with the file being regenerated every time was tedious.

* Add missing "@" for socks proxy requests
4 years ago
Ben Busby 38b7b19e2a
Added basic authentication (#51)
Username/password can be set either as Dockerfile build arguments or
passed into the run script as "--userpass <username:password>"
4 years ago
Ben Busby 601923e074
Update Dockerfile
Fixed mkdir call to not error if config dir already exists
4 years ago
Ben Busby 11fa44eec1 Minor refactoring for clarification
Executable renamed to "run" to avoid confusion with pip installed script

Updated heroku deploy button to use the heroku-app branch, which by
default enforces HTTPS

Added instructions for enforcing HTTPS on various deployment options,
with note about how this isn't a required task.

Updated setup.py description to use improved app description
4 years ago
Ben Busby 1ed6178e9a
Feature: https only -- adds option to enforce https on running instances (#48)
* Adding HTTPS enforcement

Command line runs of Whoogle Search through pip/pipx/etc will need the
`--https-only` flag appended to the run command.

Docker runs require the `use_https` build arg applied.

* Update README.md

Moved https-only note to top of docker run command, updated pip runner help output

* Dockerfile: removed HTTPS enforcement, updated PORT setting

Dockerfile no longer enforces an HTTPS connection, but still allows for
setting via a build arg. The Flask server port is now configurable as a
build arg as well, by setting a port number to "whoogle_port"

* Fixed incorrect port assignment
4 years ago
Ben Busby 87f0a8d496
Added volume mounted config to Dockerfile (#39) 4 years ago
Jake Howard ab47153141
Use slim version of docker container (#34)
* Use slim version of docker container

This massively reduces the size of the final container (330mb -> 60mb)

* Install libcurl and libssl explicitly in container

They appear to be missing from `-slim` variant containers

Co-authored-by: Ben Busby <benbusby@pm.me>

Co-authored-by: Ben Busby <benbusby@pm.me>
4 years ago
Jake Howard 14a41a89b6
No need to chmod `whoogle-search` script inside container (#33) 4 years ago