Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb07b33e

Browse files
authored
feat: add agentapi endpoint to report connections for audit (#16507)
This change adds a new `ReportConnection` endpoint to the `agentapi`.The protocol version was bumped previously, so it has been omitted here.This allows the agent to report connection events, for example when theuser connects to the workspace via SSH or VS Code.Updates#15139
1 parentdedc32f commitb07b33e

File tree

16 files changed

+1484
-705
lines changed

16 files changed

+1484
-705
lines changed

‎agent/agent.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ func (a *agent) collectMetadata(ctx context.Context, md codersdk.WorkspaceAgentM
372372
// Important: if the command times out, we may see a misleading error like
373373
// "exit status 1", so it's important to include the context error.
374374
err=errors.Join(err,ctx.Err())
375-
376375
iferr!=nil {
377376
result.Error=fmt.Sprintf("run cmd: %+v",err)
378377
}

‎agent/agenttest/client.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"golang.org/x/exp/slices"
1616
"golang.org/x/xerrors"
1717
"google.golang.org/protobuf/types/known/durationpb"
18+
"google.golang.org/protobuf/types/known/emptypb"
1819
"storj.io/drpc/drpcmux"
1920
"storj.io/drpc/drpcserver"
2021
"tailscale.com/tailcfg"
@@ -170,6 +171,7 @@ type FakeAgentAPI struct {
170171
lifecycleStates []codersdk.WorkspaceAgentLifecycle
171172
metadatamap[string]agentsdk.Metadata
172173
timings []*agentproto.Timing
174+
connections []*agentproto.Connection
173175

174176
getAnnouncementBannersFuncfunc() ([]codersdk.BannerConfig,error)
175177
getResourcesMonitoringConfigurationFuncfunc() (*agentproto.GetResourcesMonitoringConfigurationResponse,error)
@@ -338,12 +340,20 @@ func (f *FakeAgentAPI) BatchCreateLogs(ctx context.Context, req *agentproto.Batc
338340

339341
func (f*FakeAgentAPI)ScriptCompleted(_ context.Context,req*agentproto.WorkspaceAgentScriptCompletedRequest) (*agentproto.WorkspaceAgentScriptCompletedResponse,error) {
340342
f.Lock()
341-
f.timings=append(f.timings,req.Timing)
343+
f.timings=append(f.timings,req.GetTiming())
342344
f.Unlock()
343345

344346
return&agentproto.WorkspaceAgentScriptCompletedResponse{},nil
345347
}
346348

349+
func (f*FakeAgentAPI)ReportConnection(_ context.Context,req*agentproto.ReportConnectionRequest) (*emptypb.Empty,error) {
350+
f.Lock()
351+
f.connections=append(f.connections,req.GetConnection())
352+
f.Unlock()
353+
354+
return&emptypb.Empty{},nil
355+
}
356+
347357
funcNewFakeAgentAPI(t testing.TB,logger slog.Logger,manifest*agentproto.Manifest,statsChchan*agentproto.Stats)*FakeAgentAPI {
348358
return&FakeAgentAPI{
349359
t:t,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp