Skip to content

Commit a551aa5

Browse files
authored
fix: respect --disable-direct-connections on coder speedtest (#13377)
1 parent ec78f54 commit a551aa5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cli/speedtest.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func (r *RootCmd) speedtest() *serpent.Command {
3939
ctx, cancel := context.WithCancel(inv.Context())
4040
defer cancel()
4141

42+
if direct && r.disableDirect {
43+
return xerrors.Errorf("--direct (-d) is incompatible with --%s", varDisableDirect)
44+
}
45+
4246
_, workspaceAgent, err := getWorkspaceAndAgent(ctx, inv, client, false, inv.Args[0])
4347
if err != nil {
4448
return err
@@ -57,12 +61,13 @@ func (r *RootCmd) speedtest() *serpent.Command {
5761
logger = logger.Leveled(slog.LevelDebug)
5862
}
5963

60-
if r.disableDirect {
61-
_, _ = fmt.Fprintln(inv.Stderr, "Direct connections disabled.")
62-
}
6364
opts := &workspacesdk.DialAgentOptions{
6465
Logger: logger,
6566
}
67+
if r.disableDirect {
68+
_, _ = fmt.Fprintln(inv.Stderr, "Direct connections disabled.")
69+
opts.BlockEndpoints = true
70+
}
6671
if pcapFile != "" {
6772
s := capture.New()
6873
opts.CaptureHook = s.LogPacket

0 commit comments

Comments
 (0)