mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
@@ -1,4 +1,5 @@
|
||||
[
|
||||
plugins: [Phoenix.LiveView.HTMLFormatter],
|
||||
subdirectories: ["apps/*"],
|
||||
inputs: [
|
||||
"*.{ex,exs}",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule FzHttp.Repo.Migrations.FixSitesNullableFields do
|
||||
use Ecto.Migration
|
||||
|
||||
require Logger
|
||||
|
||||
def change do
|
||||
dns = System.get_env("WIREGUARD_DNS", "1.1.1.1,1.0.0.1")
|
||||
mtu = System.get_env("WIREGUARD_MTU", "1280")
|
||||
@@ -10,7 +12,7 @@ defmodule FzHttp.Repo.Migrations.FixSitesNullableFields do
|
||||
endpoint =
|
||||
System.get_env(
|
||||
"WIREGUARD_ENDPOINT",
|
||||
URI.parse(System.get_env("EXTERNAL_URL", "https://localhost/")).host
|
||||
host()
|
||||
) <> ":" <> System.get_env("WIREGUARD_PORT", "51820")
|
||||
|
||||
execute("""
|
||||
@@ -43,4 +45,29 @@ defmodule FzHttp.Repo.Migrations.FixSitesNullableFields do
|
||||
WHERE endpoint IS NULL
|
||||
""")
|
||||
end
|
||||
|
||||
defp host do
|
||||
external_url_var = System.get_env("EXTERNAL_URL")
|
||||
substitute = "https://localhost/"
|
||||
|
||||
external_url =
|
||||
if is_nil(external_url_var) || String.length(external_url_var) == 0 do
|
||||
Logger.warn("EXTERNAL_URL is empty! Using #{substitute} as basis for WireGuard endpoint.")
|
||||
substitute
|
||||
else
|
||||
external_url_var
|
||||
end
|
||||
|
||||
parsed_host = URI.parse(external_url).host
|
||||
|
||||
if is_nil(parsed_host) do
|
||||
Logger.warn(
|
||||
"EXTERNAL_URL doesn't seem to contain a valid URL. Assuming https://#{external_url}."
|
||||
)
|
||||
|
||||
external_url
|
||||
else
|
||||
parsed_host
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user