Show a dynamically updated list of NTS servers #1
|
@ -37,6 +37,3 @@ npm-debug.log
|
||||||
|
|
||||||
# Ignore IDE files.
|
# Ignore IDE files.
|
||||||
.elixir_ls/
|
.elixir_ls/
|
||||||
|
|
||||||
# Ignore server lists.
|
|
||||||
/priv/nts.txt
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ config :chronoscope, ChronoscopeWeb.Endpoint,
|
||||||
# In test we don't send emails.
|
# In test we don't send emails.
|
||||||
config :chronoscope, Chronoscope.Mailer, adapter: Swoosh.Adapters.Test
|
config :chronoscope, Chronoscope.Mailer, adapter: Swoosh.Adapters.Test
|
||||||
|
|
||||||
config :chronoscope, :nts_file, "test/priv/nts.txt"
|
config :chronoscope, :nts_file, "priv/nts-test.txt"
|
||||||
|
|
||||||
# Disable swoosh api client as it is only required for production adapters.
|
# Disable swoosh api client as it is only required for production adapters.
|
||||||
config :swoosh, :api_client, false
|
config :swoosh, :api_client, false
|
||||||
|
|
|
@ -23,8 +23,8 @@ defmodule Chronoscope.Application do
|
||||||
{Registry, [keys: :unique, name: Chronoscope.Gemini.Registry]},
|
{Registry, [keys: :unique, name: Chronoscope.Gemini.Registry]},
|
||||||
# Start to serve requests, typically the last entry
|
# Start to serve requests, typically the last entry
|
||||||
ChronoscopeWeb.Endpoint,
|
ChronoscopeWeb.Endpoint,
|
||||||
# Initialize clients for the main LiveView
|
# Initialize clients used in the main LiveView
|
||||||
Chronoscope.ViewActivator
|
ChronoscopeWeb.ClientActivator
|
||||||
]
|
]
|
||||||
|
|
||||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule Chronoscope.ViewActivator do
|
defmodule ChronoscopeWeb.ClientActivator do
|
||||||
use GenServer
|
use GenServer
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
@ -14,8 +14,7 @@ defmodule Chronoscope.ViewActivator do
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def init(_) do
|
def init(_) do
|
||||||
File.touch(@nts_file)
|
File.touch(Application.app_dir(:chronoscope, @nts_file))
|
||||||
activate_nts_clients()
|
|
||||||
{:ok, %{nts_servers: activate_nts_clients()}}
|
{:ok, %{nts_servers: activate_nts_clients()}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ defmodule Chronoscope.ViewActivator do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp activate_nts_clients() do
|
defp activate_nts_clients() do
|
||||||
@nts_file
|
Application.app_dir(:chronoscope, @nts_file)
|
||||||
|> File.stream!()
|
|> File.stream!()
|
||||||
|> Stream.map(&String.trim/1)
|
|> Stream.map(&String.trim/1)
|
||||||
|> Stream.filter(&(&1 != ""))
|
|> Stream.filter(&(&1 != ""))
|
|
@ -3,7 +3,7 @@ defmodule ChronoscopeWeb.IndexLive do
|
||||||
|
|
||||||
alias Chronoscope.NTS
|
alias Chronoscope.NTS
|
||||||
alias Chronoscope.NTS.KeyEstablishmentResponse
|
alias Chronoscope.NTS.KeyEstablishmentResponse
|
||||||
alias Chronoscope.ViewActivator
|
alias ChronoscopeWeb.ClientActivator
|
||||||
|
|
||||||
@topic Application.compile_env(:chronoscope, :nts_topic)
|
@topic Application.compile_env(:chronoscope, :nts_topic)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ defmodule ChronoscopeWeb.IndexLive do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp server_list() do
|
defp server_list() do
|
||||||
GenServer.call(ViewActivator, :get_nts_servers)
|
GenServer.call(ClientActivator, :get_nts_servers)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp client_list() do
|
defp client_list() do
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
time.cifelli.xyz
|
||||||
|
stratum1.time.cifelli.xyz
|
||||||
|
virginia.time.system76.com
|
||||||
|
paris.time.system76.com
|
||||||
|
oregon.time.system76.com
|
||||||
|
ohio.time.system76.com
|
||||||
|
brazil.time.system76.com
|
Loading…
Reference in New Issue