Skip to content

Commit 628cd91

Browse files
committed
Add env variable 'tmate_num_clients' to tell how many clients are connected
1 parent 5079fa0 commit 628cd91

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/tmate/session.ex

+6
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ defmodule Tmate.Session do
365365
daemon_set_env(state, "tmate_ssh_ro", ssh_cmd_ro)
366366
if !ssh_only, do: daemon_set_env(state, "tmate_web", web_url)
367367
daemon_set_env(state, "tmate_ssh", ssh_cmd)
368+
set_env_num_clients(state, 0)
368369

369370
daemon_set_env(state, "tmate_reconnection_data", pack_and_sign!(new_reconnection_data))
370371

@@ -610,9 +611,14 @@ defmodule Tmate.Session do
610611
num_clients = Kernel.map_size(state.clients)
611612
msg = "A mate has #{verb} (#{client.ip_address}) -- " <>
612613
"#{num_clients} client#{if num_clients > 1, do: 's'} currently connected"
614+
set_env_num_clients(state, num_clients)
613615
notify_daemon(state, msg)
614616
end
615617

618+
defp set_env_num_clients(state, num_clients) do
619+
daemon_set_env(state, "tmate_num_clients", "#{num_clients}")
620+
end
621+
616622
defp update_client_size(state, ref, size) do
617623
client = Map.fetch!(state.clients, ref)
618624
client = Map.merge(client, %{size: size})

0 commit comments

Comments
 (0)