fix: respect --disable-direct-connections on coder speedtest (#13377)

This commit is contained in:
Spike Curtis
2024-05-29 08:07:48 +04:00
committed by GitHub
parent ec78f54941
commit a551aa51ab
+8 -3
View File
@@ -39,6 +39,10 @@ func (r *RootCmd) speedtest() *serpent.Command {
ctx, cancel := context.WithCancel(inv.Context())
defer cancel()
if direct && r.disableDirect {
return xerrors.Errorf("--direct (-d) is incompatible with --%s", varDisableDirect)
}
_, workspaceAgent, err := getWorkspaceAndAgent(ctx, inv, client, false, inv.Args[0])
if err != nil {
return err
@@ -57,12 +61,13 @@ func (r *RootCmd) speedtest() *serpent.Command {
logger = logger.Leveled(slog.LevelDebug)
}
if r.disableDirect {
_, _ = fmt.Fprintln(inv.Stderr, "Direct connections disabled.")
}
opts := &workspacesdk.DialAgentOptions{
Logger: logger,
}
if r.disableDirect {
_, _ = fmt.Fprintln(inv.Stderr, "Direct connections disabled.")
opts.BlockEndpoints = true
}
if pcapFile != "" {
s := capture.New()
opts.CaptureHook = s.LogPacket