Skip to content

Commit 17103d0

Browse files
committed
feat(support): add agent magicsock HTML
1 parent ce878c7 commit 17103d0

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

cli/support.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ func writeBundle(src *support.Bundle, dest *zip.Writer) error {
175175
"network/tailnet_debug.html": src.Network.TailnetDebug,
176176
"workspace/build_logs.txt": humanizeBuildLogs(src.Workspace.BuildLogs),
177177
"agent/logs.txt": string(src.Agent.Logs),
178+
"agent/magicsock.html": string(src.Agent.MagicsockHTML),
178179
"agent/startup_logs.txt": humanizeAgentLogs(src.Agent.StartupLogs),
179180
"workspace/template_file.zip": string(templateVersionBytes),
180181
"logs.txt": strings.Join(src.Logs, "\n"),

cli/support_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ func assertBundleContents(t *testing.T, path string) {
166166
case "agent/logs.txt":
167167
bs := readBytesFromZip(t, f)
168168
require.NotEmpty(t, bs, "logs should not be empty")
169+
case "agent/magicsock.html":
170+
bs := readBytesFromZip(t, f)
171+
require.NotEmpty(t, bs, "agent magicsock should not be empty")
169172
case "agent/manifest.json":
170173
var v agentsdk.Manifest
171174
decodeJSONFromZip(t, f, &v)

support/support.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ type Agent struct {
6262
Agent codersdk.WorkspaceAgent `json:"agent"`
6363
ListeningPorts *codersdk.WorkspaceAgentListeningPortsResponse `json:"listening_ports"`
6464
Logs []byte `json:"logs"`
65+
MagicsockHTML []byte `json:"magicsock_html"`
6566
Manifest *agentsdk.Manifest `json:"manifest"`
6667
PeerDiagnostics *tailnet.PeerDiagnostics `json:"peer_diagnostics"`
6768
PingResult *ipnstate.PingResult `json:"ping_result"`
@@ -340,6 +341,15 @@ func AgentInfo(ctx context.Context, client *codersdk.Client, log slog.Logger, ag
340341
return nil
341342
})
342343

344+
eg.Go(func() error {
345+
msBytes, err := conn.DebugMagicsock(ctx)
346+
if err != nil {
347+
return xerrors.Errorf("get agent magicsock page: %w", err)
348+
}
349+
a.MagicsockHTML = msBytes
350+
return nil
351+
})
352+
343353
eg.Go(func() error {
344354
tokenBytes, err := runCmd(ctx, client, agentID, `echo $CODER_AGENT_TOKEN`)
345355
if err != nil {

support/support_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func TestRun(t *testing.T) {
7272
require.NotNil(t, bun.Agent.Agent)
7373
require.NotNil(t, bun.Agent.ListeningPorts)
7474
require.NotNil(t, bun.Agent.Logs)
75+
require.NotNil(t, bun.Agent.MagicsockHTML)
7576
require.NotNil(t, bun.Agent.Manifest)
7677
require.NotNil(t, bun.Agent.PeerDiagnostics)
7778
require.NotNil(t, bun.Agent.PingResult)

0 commit comments

Comments
 (0)