mirror of
https://github.com/benbusby/farside.git
synced 2025-03-14 19:26:30 -04:00
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.
This commit is contained in:
parent
06bb8403dd
commit
8042dcad0c
15
README.md
15
README.md
@ -1,5 +1,16 @@
|
||||
# Privacy Revolver
|
||||
# Farside
|
||||
FOSS alternative redirecting service
|
||||
|
||||
[](https://github.com/benbusby/privacy-revolver/actions/workflows/elixir.yml)
|
||||
|
||||
A smart redirecting proxy for privacy-friendly frontends
|
||||
A tool for evenly distributing traffic across various open source alternative frontends
|
||||
|
||||
### Development
|
||||
|
||||
- Install [redis](https://redis.io)
|
||||
- Install [elixir](https://elixir-lang.org/install.html)
|
||||
- Start redis: `redis-server /usr/local/etc/redis.conf`
|
||||
- Install dependencies: `mix deps.get`
|
||||
- Initialize redis contents: `mix run update.exs`
|
||||
- Run Farside: `mix run --no-halt`
|
||||
- Uses localhost:4001
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Config
|
||||
|
||||
config :privacy_revolver,
|
||||
config :farside,
|
||||
redis_conn: "redis://localhost:6379",
|
||||
fallback_str: "-fallback",
|
||||
update_file: ".update-results",
|
||||
|
17
lib/farside/application.ex
Normal file
17
lib/farside/application.ex
Normal file
@ -0,0 +1,17 @@
|
||||
defmodule Farside.Application do
|
||||
@redis_conn Application.fetch_env!(:farside, :redis_conn)
|
||||
@moduledoc false
|
||||
|
||||
use Application
|
||||
|
||||
@impl true
|
||||
def start(_type, _args) do
|
||||
children = [
|
||||
Plug.Cowboy.child_spec(scheme: :http, plug: Farside.Router, options: [port: 4001]),
|
||||
{Redix, {@redis_conn, [name: :redix]}}
|
||||
]
|
||||
|
||||
opts = [strategy: :one_for_one, name: Farside.Supervisor]
|
||||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
defmodule PrivacyRevolver.Router do
|
||||
@fallback_str Application.fetch_env!(:privacy_revolver, :fallback_str)
|
||||
defmodule Farside.Router do
|
||||
@fallback_str Application.fetch_env!(:farside, :fallback_str)
|
||||
|
||||
use Plug.Router
|
||||
|
@ -1,17 +0,0 @@
|
||||
defmodule PrivacyRevolver.Application do
|
||||
@redis_conn Application.fetch_env!(:privacy_revolver, :redis_conn)
|
||||
@moduledoc false
|
||||
|
||||
use Application
|
||||
|
||||
@impl true
|
||||
def start(_type, _args) do
|
||||
children = [
|
||||
Plug.Cowboy.child_spec(scheme: :http, plug: PrivacyRevolver.Router, options: [port: 4001]),
|
||||
{Redix, {@redis_conn, [name: :redix]}}
|
||||
]
|
||||
|
||||
opts = [strategy: :one_for_one, name: PrivacyRevolver.Supervisor]
|
||||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
end
|
6
mix.exs
6
mix.exs
@ -1,9 +1,9 @@
|
||||
defmodule PrivacyRevolver.MixProject do
|
||||
defmodule Farside.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :privacy_revolver,
|
||||
app: :farside,
|
||||
version: "0.1.0",
|
||||
elixir: "~> 1.8",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
@ -15,7 +15,7 @@ defmodule PrivacyRevolver.MixProject do
|
||||
def application do
|
||||
[
|
||||
extra_applications: [:logger],
|
||||
mod: {PrivacyRevolver.Application, []}
|
||||
mod: {Farside.Application, []}
|
||||
]
|
||||
end
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
defmodule PrivacyRevolverTest do
|
||||
defmodule FarsideTest do
|
||||
use ExUnit.Case
|
||||
use Plug.Test
|
||||
|
||||
alias PrivacyRevolver.Router
|
||||
alias Farside.Router
|
||||
|
||||
@opts Router.init([])
|
||||
|
10
update.exs
10
update.exs
@ -8,9 +8,9 @@ defmodule Service do
|
||||
end
|
||||
|
||||
defmodule Instances do
|
||||
@fallback_str Application.fetch_env!(:privacy_revolver, :fallback_str)
|
||||
@update_file Application.fetch_env!(:privacy_revolver, :update_file)
|
||||
@services_json Application.fetch_env!(:privacy_revolver, :services_json)
|
||||
@fallback_str Application.fetch_env!(:farside, :fallback_str)
|
||||
@update_file Application.fetch_env!(:farside, :update_file)
|
||||
@services_json Application.fetch_env!(:farside, :services_json)
|
||||
|
||||
def init() do
|
||||
File.rename(@update_file, "#{@update_file}-prev")
|
||||
@ -33,7 +33,9 @@ defmodule Instances do
|
||||
|
||||
# Loop through all instances and check each for availability
|
||||
for service <- json do
|
||||
IO.puts "======== " <> service.type
|
||||
result = Enum.filter(service.instances, fn(instance_url) ->
|
||||
IO.puts " " <> instance_url
|
||||
request(instance_url <> service.test_url) == :good
|
||||
end)
|
||||
|
||||
@ -43,6 +45,8 @@ defmodule Instances do
|
||||
end
|
||||
|
||||
def add_to_redis(service, instances) do
|
||||
IO.puts " --------"
|
||||
IO.inspect "OK: " <> instances
|
||||
# Remove previous list of instances
|
||||
Redix.command(:redix, [
|
||||
"DEL",
|
||||
|
Loading…
x
Reference in New Issue
Block a user