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

Commit8772013

Browse files
committed
chore: include if direction is over private network in ping diagnostics
1 parentb1298a3 commit8772013

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

‎cli/cliui/agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ 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`")
415415
if!d.Verbose {
416416
returngeneral,client,agent
417417
}

‎cli/ping.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ func (r *RootCmd) ping() *serpent.Command {
128128
}
129129

130130
ifr.disableDirect {
131-
_,_=fmt.Fprintln(inv.Stderr,"Direct connections disabled.")
132131
opts.BlockEndpoints=true
133132
}
134133
if!r.disableNetworkTelemetry {
@@ -197,6 +196,7 @@ func (r *RootCmd) ping() *serpent.Command {
197196
results:=&pingSummary{
198197
Workspace:workspaceName,
199198
}
199+
varoverPrivateNetworkbool
200200
n:=0
201201
start:=time.Now()
202202
pingLoop:
@@ -240,6 +240,7 @@ func (r *RootCmd) ping() *serpent.Command {
240240
_,_=fmt.Fprintln(inv.Stdout,"p2p connection established in",
241241
pretty.Sprint(cliui.DefaultStyles.DateTimeStamp,time.Since(start).Round(time.Millisecond).String()),
242242
)
243+
overPrivateNetwork=isPrivateEndpoint(pong.Endpoint)
243244
}
244245
didP2p=true
245246

@@ -276,7 +277,11 @@ func (r *RootCmd) ping() *serpent.Command {
276277
}
277278

278279
ifdidP2p {
279-
_,_=fmt.Fprintf(inv.Stderr,"✔ You are connected directly (p2p)\n")
280+
msg:="✔ You are connected directly (p2p)"
281+
ifoverPrivateNetwork {
282+
msg+=", over a private network"
283+
}
284+
_,_=fmt.Fprintln(inv.Stderr,msg)
280285
}else {
281286
_,_=fmt.Fprintf(inv.Stderr,"❗ You are connected via a DERP relay, not directly (p2p)\n%s#common-problems-with-direct-connections\n",connDiags.TroubleshootingURL)
282287
}
@@ -329,3 +334,11 @@ func isAWSIP(awsRanges *cliutil.AWSIPRanges, ni *tailcfg.NetInfo) bool {
329334
}
330335
returnfalse
331336
}
337+
338+
funcisPrivateEndpoint(endpointstring)bool {
339+
ip,err:=netip.ParseAddrPort(endpoint)
340+
iferr!=nil {
341+
returnfalse
342+
}
343+
returnip.Addr().IsPrivate()
344+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp