Commit graph

46 commits

Author SHA1 Message Date
Ben Busby
a843b322c9
Redirect x.com links to nitter instances
Closes #136
2023-09-28 14:24:01 -06:00
Ben Busby
7e47e9536a
Poll nitter instances only in nightly build
From the recent changes to twitter/X, it sounds like guest accounts are
now required for nitter, which are more easily rate limited. To avoid
any impact from Farside, the instances are now health checked in the
nightly build using https://status.d420.de (this doesn't seem to be
directly associated with the nitter maintainers, so might not be
entirely future-proof).
2023-08-23 13:46:51 -06:00
Ben Busby
7693a6b063
Add env var for toggling cron task on/off
FARSIDE_CRON allows turning on/off the scheduled instance availability
check that occurs every 5 minutes by setting the variable to 1 (on) or 0
(off). The default behavior is "on".
2023-07-17 17:46:39 -06:00
NoPlagiarism
9104650cfe
Add GotHub support (#116)
Adds support for GotHub, an alternative frontend for GitHub

---------

Co-authored-by: Ben Busby <contact@benbusby.com>
2023-07-17 15:15:51 -06:00
Ben Busby
c0706bfe9b
Allow separation of instance and API URLs
Instance URLs and API URLs are not always the same, and require
different testing strategies. This allows the two types of URLs for an
instance, as well as the testing path, to be separated by a "|" character.
When Farside runs the instance checker, it will split instance strings
by that character and perform separate tests. Instances without a
separate API URL will only be tested once against their primary instance
URL.

Currently the only service using this paradigm is Piped, but allows for
others using the same approach to be added/tested in Farside in the
future.

Closes #115
2023-07-11 12:34:31 -06:00
Ben Busby
dcc4a9f4b1
Mark redirecting instances as inacessible
Too many instances redirect to either non-functional or spam sites. The
new behavior is to only allow 200-300 responses to mark an instance as
accessible.
2023-07-11 11:27:45 -06:00
Ben Busby
6f647f52ae
Add support for Anonymous Overflow
A Stack Overflow frontend, see:
https://github.com/httpjamesm/AnonymousOverflow
2023-05-19 12:42:06 -06:00
Ben Busby
0ce0832a28
Add support for BreezeWiki
Includes nightly build support for automatically pulling the most up to
date instance list.

Closes #104
2023-05-19 10:57:43 -06:00
Ben Busby
bb3a01f8c1
Move SearXNG instance check to nightly build
searx.space includes metrics for instance uptime, which is now
implemented as part of farside's nightly build. Accordingly, the
instance availability task built into farside now excludes searxng
instances.

Closes #95
2023-04-05 13:04:17 -06:00
Ben Busby
7f430a5c41
Fix auto-redirect regex for gtranslate vs gsearch
The redirect regex for google search (~r/google.com) would also match
for google translate requests. This updates the search regex to also
require the "/search" path to be present in the original link.
2023-03-14 12:38:02 -06:00
FriendlyPigeon
16cc680c7d
Add parent relation for whoogle (#84) 2023-01-13 19:49:35 -07:00
Ben Busby
2a858b89d2
Ignore request types in router
Request types don't really matter in Farside, and should be ignored.
This updates the router to handle all request types (GET, HEAD, POST,
etc) the same as GET requests were handled previously.
2022-12-11 13:14:40 -07:00
Ben Busby
d9f0291853
Enable auto compact for cubdb
This reduces the number of redundant db files created by cubdb.
2022-12-09 11:30:25 -07:00
Ben Busby
e58d6e23ed
Remove Redis dep, replace w/ native Elixir lib
This removes the dependency on Redis for core app functionality. Rather
than using the key/value store provided by Redis, Farside now uses a
key/val store provided by [cubdb](https://github.com/lucaong/cubdb) for
identical functionality but without reliance on a non-Elixir service.

This solution was chosen instead of ets, because storing instance data
in memory leads to a period of broken functionality whenever the app
restarts and hasn't re-populated instance data yet. It was also chosen
instead of dets, because the documentation for dets was pretty hard to
understand at first glance.

Tests and the CI build were updated to reflect the removed dependency on
Redis.

New environment variable `FARSIDE_DATA_DIR` can be used to point to a
directory where the instance data can be stored by cubdb.

Co-authored-by: Jason Clark <mithereal@gmail.com>
2022-10-31 16:45:31 -06:00
Kian-Meng Ang
9d13d60a25
Fix typo [skip ci] (#72)
"Runing" -> "Running"

Found via `codespell -S deps -L neet`
2022-10-26 10:14:30 -06:00
alvv-z
431ea613d1
Fix spelling of quetre (#55) 2022-07-31 11:05:48 -06:00
Ben Busby
8fbe016cdb
Support libremdb and querte (imdb and quora alts)
Includes support for redirecting via full url, ie:

-> farside.link/https://www.imdb.com/title/tt0133093/

will redirect to a libremdb instance.

Closes #48
2022-07-27 17:14:15 -06:00
Ben Busby
a6dabe8bf3
Make conn values and services path configurable at runtime
Connection values (such as redis server port and the port to run farside
on) as well as the services json file to use can now be set via
environment variables:

FARSIDE_PORT sets the port for Farside to run on
FARSIDE_REDIS_PORT sets the redis server port for Farside to use
FARSIDE_SERVICES_JSON sets the services json file for Farside to use

This partially addresses the move towards de-listing Cloudflare
instances by default by allowing different services json files to be
used with different redis servers.

See #43
2022-07-27 13:53:33 -06:00
Ben Busby
32259f849b
Add proxitok (TikTok frontend)
Closes #19
2022-06-21 16:12:12 -06:00
Ben Busby
d280f961f5
Prepend /u/ for Bibliogram redirects if not present
Bibliogram links require a "/u/" prefix when viewing a user's profile,
which does not match Instagram's URL paradigm. This adds a bit of logic
for Bibliogram links to prepend this prefix if the user is not visiting
a post (indicated by a "/p/" prefix, which Bibliogram and Instagram BOTH
use) or the home page of an instance (indicated by an empty path value).
2022-06-21 15:53:16 -06:00
Ben Busby
52833ef89e
Redirect youtu.be links to the correct instance
Farside was previously only looking for links containing "youtube.com"
when performing the redirect for full URLs to youtube, which obviously
doesn't work for youtu.be shortened links. This updates the matching
logic to use a regex element for every key in the services map in order
to match against multiple possible domains for each parent service.

Fixes #40
2022-06-21 15:01:23 -06:00
Ben Busby
6210ed56e7
Include query params for all /_/ prefixed links
Query params were not included when using the "/_/" prefix for farside
links. This extracts the logic for parsing query params into a function
that is then used for both /_/ and non-/_/ links.
2022-06-13 10:20:39 -06:00
Ben Busby
5006b97dfa
Auto select frontend for links to "parent" service
Farside now supports redirecting based on a provided link to a "parent"
service, if such a parent service is supported.

For example, a link such as:

farside.link/https://www.youtube.com/watch?v=dQw4w9WgXcQ

will now redirect to any of the available YouTube related frontends.

This works by matching against a mapping of "parent" service domains
("youtube.com", "reddit.com", etc) to a list of their respective frontend
alternatives (["invidious", "piped"], ["libreddit", "teddit"], etc). A
random element is chosen from this list, and the remainder of Farside's
routing logic proceeds as if the user had chosen the service directly to
begin with.

Closes #37
2022-06-09 13:08:01 -06:00
Ben Busby
1be19a8a29
Update throttle test to reflect new behavior
The "throttling" performed by Farside now redirects to the same instance
as before, rather than outright blocking the connection.
2022-03-18 13:59:35 -06:00
Ben Busby
22e9135e0c
Reuse previous instance within rate-limit interval
Rather than blocking <1s back-to-back queries from the same IP, Farside
will now re-use the previously selected instance.

Fixes #20
2022-03-18 13:51:37 -06:00
Ben Busby
5235f5a3bf
Replace poison dependency w/ jason
The dependency took a long time to compile, and was causing problems for
a user who was attempting to build the project.

Since it wasn't a strictly necessary dependency, and `jason` was already
included in the project, all instances of `poison` have been replaced
with `jason`.

The only additional code that this introduced was converting from
generic maps returned by `Jason.decode` into Service structs.
2022-02-14 11:21:32 -07:00
Ben Busby
932f3bbcab
Preserve redirect with /_/ path prefix (#13)
This adds a straightforward way of preserving Farside's redirecting
behavior in the user's browser history. That way if an instance becomes
unavailable between the 5 min scans, the user can opt to navigate back
one page and be taken to a new instance.

This is accomplished using a single line of JS, and could potentially
work as the default behavior of Farside (with the current default
behavior requiring a path prefix instead). This should be revisited down
the road when more people are using this service.
2022-01-27 11:57:41 -07:00
Ben Busby
1fb9051ae1
Broaden HTTPoison status code inspection
Rather than enforcing a 200 status code, the instance query is deemed a
success if the status code is <400. Various services return 200-399
status codes that don't necessarily indicate an error, but may have to
do with how the instance was configured.
2021-12-28 12:33:04 -07:00
Ben Busby
1092350fcd
Remove FARSIDE_NO_ROUTER env var
The FARSIDE_NO_ROUTER variable wasn't terribly useful after refactoring
the app to include the update routine internally (rather than available
externally as an elixir script).

Now the only supported environment variable is FARSIDE_TEST, which is
still useful for tests and quick validation of functionality.
2021-12-09 15:33:58 -07:00
Ben Busby
04388fcf3c
Use format str for search engine queries
Although the current list of queries is only 2 elements ("time" and
"weather"), this allows searches for Whoogle and Searx to be slightly
more random, and potentially avoid any issues with their parent engine
rate limiting them.
2021-11-29 16:31:55 -07:00
Ben Busby
8e3455a790
Automate updates for list of searx instances (#3)
* Create nightly update workflow for instances

A nightly GitHub Actions CI workflow has been added to fetch new
instances of supported services within Farside.

Currently only Searx is supported, but obviously others could be added
if there are similarly easy ways to fetch and filter instances
programmatically.

services.json has also been updated with the initial results of the
workflow script.

* Set headers for every HTTPoison request

This serves as a workaround for bot blocking via filtron.

* Expand filtering of searx instances

New filter enforces:
- No Cloudflare
- Good TLS config
- Good HTTP header config
- Vanilla instances or forks
- Instances with 100% search success
2021-11-26 09:12:46 -07:00
Ben Busby
ff97d258f0
Use quantum core for update scheduling
Rather than requiring a traditional crontab install, the app now
leverages quantum-core (link below) to schedule the instance update/sync
task every 5 minutes. Some updates as a result:

  - The new job is scheduled at runtime in server.ex.
  - The update.exs script was refactored to be compiled along with the
    rest of the app as instances.ex.
  - Scheduler and Server modules were added for creating and executing
    the new update task
  - All shell scripts were removed, as they are no longer needed

https://github.com/quantum-elixir/quantum-core
2021-11-24 09:35:21 -07:00
Ben Busby
d4581797e7
Allow bypassing app router with FARSIDE_NO_ROUTER
Setting the aforementioned env var skips creation of the app router,
which is useful for running update.exs when the main app is already
running (otherwise there's a port conflict).
2021-11-15 20:09:34 -07:00
Ben Busby
97f1d26cbc
Include query params in service instance redirect
Query params ("/watch?v=dQw4w9WgXcQ" for instance) would previously be
lost in Farside redirects. This now includes them if they were included
in the original request.
2021-11-15 17:15:36 -07:00
Ben Busby
fec966ae59
Fix formatting 2021-11-12 14:40:05 -07:00
Ben Busby
2d988a1239
Throttle incoming requests to 1/sec per ip
This introduces a way of throttling requests in a way that makes sense
for the purpose of the app. The app only supports redirecting to one
particular service when browsing, which would seldom be required more
than once per second for normal "human" browsing.

Without this, the service could easily be used to DOS multiple instances
at once. That being said, anyone concerned about someone DOS-ing
multiple instances at once should be aware that this would be trivial to
do with a simple bash script. This is simply a preventative measure to
hopefully deter people from trying to attack all public instances of
private frontends using farside.link.

Note that this throttling applies to all routes in the app, including
the homepage. This could be updated to exclude the homepage I guess,
but I'm not really sure what the use case would be for that.
2021-11-12 14:34:36 -07:00
Ben Busby
8ee4f308a4
Prevent same instance from being selected twice in a row
Introduces a new db key "<service>-previous" to track which instance was
last selected for a particular service. This allows for filtering the
list of available instances to exclude the instance that was last
picked, to ensure a (slightly) more even distribution of traffic.
There's still the possiblity of the following scenario, however:

:service instances > 2

/:service request #1 -> instance #1
/:service request #2 -> instance #2
/:service request #3 -> instance #1
/:service request #4 -> instance #2

where there are many ignored instances for a particular service. One
possible solution would be to implement the "<service>-previous" value
to be a list, rather than a single value, and push to that list until
only one element is left in the original "instance" array after
filtering, and then delete the "<service>-previous" key.
2021-11-10 12:19:37 -07:00
Ben Busby
71fb89e028
Move instance selection logic out of router
The process of selecting a random (working) instance for a specified
service has been moved out of the router and into lib/farside.ex. Moving
forward, the router itself should have very simple and easy to follow
logic for all paths.
2021-11-10 11:50:19 -07:00
Ben Busby
d334fc7695
Move Service struct def to its own module
Service struct now defined in lib/service.ex

This makes a bit more sense now that its a shared resource, rather than
just defining it only in the update.exs script.
2021-11-10 11:48:39 -07:00
Ben Busby
2189c9ddca
Simplify retrieval of service keys from redis
Can just use a wildcard in the initial keys query, rather than grabbing
all keys and filtering by service prefix.
2021-11-10 10:47:04 -07:00
Ben Busby
56b9c52528
Display list of available instances on home page
This introduces a number of new changes:
- Services are now inserted into redis with a prefix prepended to the
key name. This allows for easier filtering to get only live instances.
- The home page now uses an eex template for displaying all live
instances for every service, determined by the last update
- A "last_updated" field was added
- farside.ex was added to contain all functionality related to querying
for instances (WIP)
- Other improvements
2021-11-08 17:08:19 -07:00
Ben Busby
8042dcad0c
Refactor project to new name
The name of the project is being refactored from Privacy Revolver to
Farside. The reasoning behind this is:
1. A shorter name is easier to remember
2. It can stand for "FOSS alternative redirecting service" (which I know
doesn't encapsulate all letters from "farside", but it's close enough).

This commit also includes improvements to the update script for
determining how far along the script is.
2021-11-07 12:29:06 -07:00
Ben Busby
2ea805bd88
Format with mix format 2021-10-23 15:18:13 -06:00
Ben Busby
76faebd234
Move constants to config, update string formatting
Not sure if this is the Elixir-y way to do this, but seems more logical
than hardcoding values such as redis connection.

Also went through and improved how string formatting was performed
throughout the app. Rather than "combining" <> "strings" this way, I'm
now just doing "#${variable}#{formatting}", which looks a lot cleaner.
2021-10-22 20:07:07 -06:00
Ben Busby
9a6d680213
Route service requests to an available instance
Router has been updated with a basic /:service/*glob endpoint, which
retrieves a list of instances for the requested service and picks a
random one to forward the user to (or falls back to a default instance
if none are found).

Should probably add a check to make sure the requested service exists
first.
2021-10-22 19:18:33 -06:00
Ben Busby
8f762d47fa
Setup basic Plug.Router framework for serving requests
Rather than use a full blown framework*, adding basic routing with
Plug.Router seems to make more sense, since I'm not planning on hosting
any content through this app. The app itself will just be endpoints for
all available services that redirect the user to an available instance
for the requested service.

Note that I might change my mind about this, but that's unlikely. At
most there would just be a home page with info about available
instances, but even then that seems kinda pointless. Trying to keep this
as absolutely simple as possible.

*like Phoenix
2021-10-22 18:28:12 -06:00