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

View File

@ -10,7 +10,7 @@ defmodule ChronoscopeWeb.IndexLive do
{:ok, assign(socket, %{servers: NTS.list()})}
end
def handle_info(%{topic: @topic, payload: servers}, socket) do
{:noreply, assign(socket, %{servers: servers})}
def handle_info(%{topic: @topic}, socket) do
{:noreply, assign(socket, %{servers: NTS.list()})}
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">
<thead>
<tr>
<th scope="col" class="py-3 px-6">
<th scope="col" class="py-3 px-6 whitespace-nowrap">
Host
</th>
<th scope="col" class="py-3 px-6">
<th scope="col" class="py-3 px-6 whitespace-nowrap">
Status
</th>
<th scope="col" class="py-3 px-6">
<th scope="col" class="py-3 px-6 whitespace-nowrap">
Algorithm
</th>
<th scope="col" class="py-3 px-6">
<th scope="col" class="py-3 px-6 whitespace-nowrap">
Cookies
</th>
<th scope="col" class="py-3 px-6">
<th scope="col" class="py-3 px-6 whitespace-nowrap">
Cookie Length
</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>
</thead>
<tbody>
@ -38,6 +44,12 @@
<td class="py-4 px-6 whitespace-nowrap">
<%= response.cookie_length %>
</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 %>
<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">
<%= server.last_key_establishment %>
</td>
<% end %>
</tr>
</tbody>

View File

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

View File

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