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

Commit6117f46

Browse files
chore: include if direct connection is over private network in ping diagnostics (#15313)
Whilst the `networking-troubleshooting` docs page already mentions thata direct connection can be established over a private network, even ifthere are no STUN servers, it's worth this is the case at the end of theping output.This also removes a print statement that was dirtying up the diagnosticoutput, and corrects the name of the `--disable-direct-connections`flag.
1 parentc519a12 commit6117f46

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

‎cli/cliui/agent.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ func (d ConnDiags) splitDiagnostics() (general, client, agent []string) {
411411
}
412412

413413
ifd.DisableDirect {
414-
general=append(general,"❗ Direct connections are disabled locally, by `--disable-direct` or `CODER_DISABLE_DIRECT`")
414+
general=append(general,"❗ Direct connections are disabled locally, by `--disable-direct-connections` or `CODER_DISABLE_DIRECT_CONNECTIONS`.\n"+
415+
" They may still be established over a private network.")
415416
if!d.Verbose {
416417
returngeneral,client,agent
417418
}

‎cli/ping.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func (r *RootCmd) ping() *serpent.Command {
118118
workspaceName,
119119
)
120120
iferr!=nil {
121+
spin.Stop()
121122
returnerr
122123
}
123124

@@ -128,7 +129,6 @@ func (r *RootCmd) ping() *serpent.Command {
128129
}
129130

130131
ifr.disableDirect {
131-
_,_=fmt.Fprintln(inv.Stderr,"Direct connections disabled.")
132132
opts.BlockEndpoints=true
133133
}
134134
if!r.disableNetworkTelemetry {
@@ -137,6 +137,7 @@ func (r *RootCmd) ping() *serpent.Command {
137137
wsClient:=workspacesdk.New(client)
138138
conn,err:=wsClient.DialAgent(ctx,workspaceAgent.ID,opts)
139139
iferr!=nil {
140+
spin.Stop()
140141
returnerr
141142
}
142143
deferconn.Close()
@@ -168,6 +169,7 @@ func (r *RootCmd) ping() *serpent.Command {
168169

169170
connInfo,err:=wsClient.AgentConnectionInfoGeneric(diagCtx)
170171
iferr!=nil||connInfo.DERPMap==nil {
172+
spin.Stop()
171173
returnxerrors.Errorf("Failed to retrieve connection info from server: %w\n",err)
172174
}
173175
connDiags.ConnInfo=connInfo
@@ -197,6 +199,11 @@ func (r *RootCmd) ping() *serpent.Command {
197199
results:=&pingSummary{
198200
Workspace:workspaceName,
199201
}
202+
var (
203+
pong*ipnstate.PingResult
204+
dur time.Duration
205+
p2pbool
206+
)
200207
n:=0
201208
start:=time.Now()
202209
pingLoop:
@@ -207,7 +214,7 @@ func (r *RootCmd) ping() *serpent.Command {
207214
n++
208215

209216
ctx,cancel:=context.WithTimeout(ctx,pingTimeout)
210-
dur,p2p,pong,err:=conn.Ping(ctx)
217+
dur,p2p,pong,err=conn.Ping(ctx)
211218
cancel()
212219
results.addResult(pong)
213220
iferr!=nil {
@@ -275,10 +282,15 @@ func (r *RootCmd) ping() *serpent.Command {
275282
}
276283
}
277284

278-
ifdidP2p {
279-
_,_=fmt.Fprintf(inv.Stderr,"✔ You are connected directly (p2p)\n")
285+
ifp2p {
286+
msg:="✔ You are connected directly (p2p)"
287+
ifpong!=nil&&isPrivateEndpoint(pong.Endpoint) {
288+
msg+=", over a private network"
289+
}
290+
_,_=fmt.Fprintln(inv.Stderr,msg)
280291
}else {
281-
_,_=fmt.Fprintf(inv.Stderr,"❗ You are connected via a DERP relay, not directly (p2p)\n%s#common-problems-with-direct-connections\n",connDiags.TroubleshootingURL)
292+
_,_=fmt.Fprintf(inv.Stderr,"❗ You are connected via a DERP relay, not directly (p2p)\n"+
293+
" %s#common-problems-with-direct-connections\n",connDiags.TroubleshootingURL)
282294
}
283295

284296
results.Write(inv.Stdout)
@@ -329,3 +341,11 @@ func isAWSIP(awsRanges *cliutil.AWSIPRanges, ni *tailcfg.NetInfo) bool {
329341
}
330342
returnfalse
331343
}
344+
345+
funcisPrivateEndpoint(endpointstring)bool {
346+
ip,err:=netip.ParseAddrPort(endpoint)
347+
iferr!=nil {
348+
returnfalse
349+
}
350+
returnip.Addr().IsPrivate()
351+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp