Show a dynamically updated list of NTS servers #1

Merged
mike merged 21 commits from liveview into main 2024-07-26 09:35:19 -04:00
5 changed files with 36 additions and 9 deletions
Showing only changes of commit 86d3808e54 - Show all commits

View File

@ -12,6 +12,7 @@ defmodule Chronoscope.NTS do
@registry Application.compile_env(:chronoscope, :registry, Registry) @registry Application.compile_env(:chronoscope, :registry, Registry)
@genserver Application.compile_env(:chronoscope, :gen_server, GenServer) @genserver Application.compile_env(:chronoscope, :gen_server, GenServer)
@dynamic_supervisor Application.compile_env(:chronoscope, :dynamic_supervisor, DynamicSupervisor) @dynamic_supervisor Application.compile_env(:chronoscope, :dynamic_supervisor, DynamicSupervisor)
@topic "nts-servers"
def healthy?() do def healthy?() do
true true
@ -37,6 +38,7 @@ defmodule Chronoscope.NTS do
%{host: host, port: port} %{host: host, port: port}
|> client_pid() |> client_pid()
|> @genserver.call(:key_establishment) |> @genserver.call(:key_establishment)
|> tap(fn _ -> ChronoscopeWeb.Endpoint.broadcast(@topic, "", "") end)
end end
defp client_pid(server) do defp client_pid(server) do

View File

@ -10,7 +10,7 @@ defmodule ChronoscopeWeb.IndexLive do
{:ok, assign(socket, %{servers: NTS.list()})} {:ok, assign(socket, %{servers: NTS.list()})}
end end
def handle_info(%{topic: @topic, payload: servers}, socket) do def handle_info(%{topic: @topic}, socket) do
{:noreply, assign(socket, %{servers: servers})} {:noreply, assign(socket, %{servers: NTS.list()})}
end end
end end

View File

@ -1,21 +1,27 @@
<table class="mx-auto border-collapse table-auto min-w-full divide-y divide-zinc-200 dark:divide-zinc-700 text-left"> <table class="mx-auto border-collapse table-auto min-w-full divide-y divide-zinc-200 dark:divide-zinc-700 text-left">
<thead> <thead>
<tr> <tr>
<th scope="col" class="py-3 px-6"> <th scope="col" class="py-3 px-6 whitespace-nowrap">
Host Host
</th> </th>
<th scope="col" class="py-3 px-6"> <th scope="col" class="py-3 px-6 whitespace-nowrap">
Status Status
</th> </th>
<th scope="col" class="py-3 px-6"> <th scope="col" class="py-3 px-6 whitespace-nowrap">
Algorithm Algorithm
</th> </th>
<th scope="col" class="py-3 px-6"> <th scope="col" class="py-3 px-6 whitespace-nowrap">
Cookies Cookies
</th> </th>
<th scope="col" class="py-3 px-6"> <th scope="col" class="py-3 px-6 whitespace-nowrap">
Cookie Length Cookie Length
</th> </th>
<th scope="col" class="py-3 px-6 whitespace-nowrap">
Certificate Expiration
</th>
<th scope="col" class="py-3 px-6 whitespace-nowrap">
Last Check
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -38,6 +44,12 @@
<td class="py-4 px-6 whitespace-nowrap"> <td class="py-4 px-6 whitespace-nowrap">
<%= response.cookie_length %> <%= response.cookie_length %>
</td> </td>
<td class="py-4 px-6 whitespace-nowrap">
<%= response.cert_expiration %>
</td>
<td class="py-4 px-6 whitespace-nowrap">
<%= server.last_key_establishment %>
</td>
<% else %> <% else %>
<td class="py-4 px-6 whitespace-nowrap"> <td class="py-4 px-6 whitespace-nowrap">
@ -54,6 +66,11 @@
<td class="py-4 px-6 whitespace-nowrap"> - </td> <td class="py-4 px-6 whitespace-nowrap"> - </td>
<td class="py-4 px-6 whitespace-nowrap"> - </td> <td class="py-4 px-6 whitespace-nowrap"> - </td>
<td class="py-4 px-6 whitespace-nowrap"> - </td> <td class="py-4 px-6 whitespace-nowrap"> - </td>
<td class="py-4 px-6 whitespace-nowrap"> - </td>
<td class="py-4 px-6 whitespace-nowrap">
<%= server.last_key_establishment %>
</td>
<% end %> <% end %>
</tr> </tr>
</tbody> </tbody>

View File

@ -8,7 +8,6 @@ defmodule Chronoscope.GeminiTest do
import Mox import Mox
setup :verify_on_exit!
describe "Chronoscope.Gemini.healthy?()" do describe "Chronoscope.Gemini.healthy?()" do
test "is healthy" do test "is healthy" do

View File

@ -1,8 +1,17 @@
defmodule ChronoscopeWeb.PageControllerTest do defmodule ChronoscopeWeb.PageControllerTest do
use ChronoscopeWeb.ConnCase, async: true use ChronoscopeWeb.ConnCase, async: true
alias Chronoscope.DynamicSupervisorMock
import Mox
setup :verify_on_exit!
test "GET /", %{conn: conn} do test "GET /", %{conn: conn} do
DynamicSupervisorMock
|> expect(:which_children, fn _ -> [] end)
conn = get(conn, ~p"/") conn = get(conn, ~p"/")
assert html_response(conn, 200) =~ "Peace of mind from prototype to production" assert html_response(conn, 200) =~ "Chronoscope"
end end
end end