59 Commits

Author SHA1 Message Date
mithereal
65f6e3adfd filter out duplicate services 2022-09-25 17:16:05 -07:00
mithereal
d5bac455a9 fix backup 2022-09-17 17:09:07 -07:00
mithereal
12fde1fdc6 add last_updated to status 2022-09-17 16:51:09 -07:00
mithereal
ad2da6cdc6 add status routes 2022-09-17 14:57:23 -07:00
mithereal
d5c3ec736c refactor 2022-09-17 14:13:53 -07:00
mithereal
84caea3af2 refactor 2022-09-17 14:10:07 -07:00
mithereal
03e46f81f8 add error handling 2022-09-17 03:59:48 -07:00
mithereal
0e17984d6f race condition i banish thee 2022-09-17 00:01:39 -07:00
mithereal
b5378f85c6 add moduledocs for tasks 2022-08-11 16:23:33 -07:00
mithereal
f39d6be013 fix init 2022-08-10 17:52:33 -07:00
Jason Clark
36d5b253a2
Merge branch 'main' into main 2022-08-09 14:08:52 -07:00
mithereal
666635f40f fix poll check 2022-08-02 10:40:13 -07:00
mithereal
2d5b31d61e remove check after update 2022-08-01 11:07:11 -07:00
mithereal
28e4545f65 refactor check for empty instances 2022-07-31 19:26:36 -07:00
mithereal
da4735fe2b add 1 min fallback poll to recheck servers w/o instances 2022-07-31 16:42:14 -07:00
mithereal
e2ca414f79 show fallback if there are no instances avail 2022-07-31 16:07:28 -07:00
mithereal
9b7c544466 add env var to control timeout 2022-07-31 15:15:50 -07:00
mithereal
4930ba353e fix init/update logic 2022-07-31 14:38:50 -07:00
alvv-z
431ea613d1
Fix spelling of quetre (#55) 2022-07-31 11:05:48 -06:00
mithereal
e9cca35a54 run as local service 2022-07-30 21:22:34 -07:00
mithereal
876bc2136b do not log in prod 2022-07-30 20:34:14 -07:00
mithereal
b73a8b4a4b update readme 2022-07-30 19:07:33 -07:00
mithereal
ca1e96470d config option update_file now contains updated json of working instances after sync 2022-07-30 18:57:00 -07:00
mithereal
a6e0c34abe refactor 2022-07-30 17:15:49 -07:00
mithereal
a76046a41b refactor 2022-07-30 16:25:49 -07:00
mithereal
7bd91cbcad fix reload 2022-07-29 22:56:17 -07:00
mithereal
a992934e11 fix test url issue 2022-07-29 21:55:54 -07:00
Jason Clark
75c36ae6af
Update lib/farside.ex
Co-authored-by: Ben Busby <contact@benbusby.com>
2022-07-29 21:12:50 -07:00
mithereal
c1ec9e9a6b refactor, remove unnecessary dependencies, speed up instance check query 2022-07-28 13:51:09 -07: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