You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
analytics/lib/plausible_web/plugs/firewall.ex

18 lines
348 B
Elixir

defmodule PlausibleWeb.Firewall do
import Plug.Conn
def init(opts) do
opts
end
def call(conn, _opts) do
blocklist = Keyword.fetch!(Application.get_env(:plausible, __MODULE__), :blocklist)
if PlausibleWeb.RemoteIp.get(conn) in blocklist do
send_resp(conn, 404, "Not found") |> halt
else
conn
end
end
end