| 506 | } |
| 507 | |
| 508 | func (d ConnDiags) splitDiagnostics() (general, client, agent []string) { |
| 509 | if d.AgentNetcheck != nil { |
| 510 | for _, msg := range d.AgentNetcheck.Interfaces.Warnings { |
| 511 | agent = append(agent, msg.Message) |
| 512 | } |
| 513 | if len(d.AgentNetcheck.Interfaces.Warnings) > 0 { |
| 514 | agent[len(agent)-1] += fmt.Sprintf("\n%s#low-mtu", d.TroubleshootingURL) |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | if d.LocalInterfaces != nil { |
| 519 | for _, msg := range d.LocalInterfaces.Warnings { |
| 520 | client = append(client, msg.Message) |
| 521 | } |
| 522 | if len(d.LocalInterfaces.Warnings) > 0 { |
| 523 | client[len(client)-1] += fmt.Sprintf("\n%s#low-mtu", d.TroubleshootingURL) |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | if d.PingP2P && !d.Verbose { |
| 528 | return general, client, agent |
| 529 | } |
| 530 | |
| 531 | if d.DisableDirect { |
| 532 | general = append(general, "❗ Direct connections are disabled locally, by `--disable-direct-connections` or `CODER_DISABLE_DIRECT_CONNECTIONS`.\n"+ |
| 533 | " They may still be established over a private network.") |
| 534 | if !d.Verbose { |
| 535 | return general, client, agent |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | if d.ConnInfo.DisableDirectConnections { |
| 540 | general = append(general, |
| 541 | fmt.Sprintf("❗ Your Coder administrator has blocked direct connections\n %s#disabled-deployment-wide", d.TroubleshootingURL)) |
| 542 | if !d.Verbose { |
| 543 | return general, client, agent |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | if !d.ConnInfo.DERPMap.HasSTUN() { |
| 548 | general = append(general, |
| 549 | fmt.Sprintf("❗ The DERP map is not configured to use STUN\n %s#no-stun-servers", d.TroubleshootingURL)) |
| 550 | } else if d.LocalNetInfo != nil && !d.LocalNetInfo.UDP { |
| 551 | client = append(client, |
| 552 | fmt.Sprintf("Client could not connect to STUN over UDP\n %s#udp-blocked", d.TroubleshootingURL)) |
| 553 | } |
| 554 | |
| 555 | if d.LocalNetInfo != nil && d.LocalNetInfo.MappingVariesByDestIP.EqualBool(true) { |
| 556 | client = append(client, |
| 557 | fmt.Sprintf("Client is potentially behind a hard NAT, as multiple endpoints were retrieved from different STUN servers\n %s#endpoint-dependent-nat-hard-nat", d.TroubleshootingURL)) |
| 558 | } |
| 559 | |
| 560 | if d.AgentNetcheck != nil && d.AgentNetcheck.NetInfo != nil { |
| 561 | if d.AgentNetcheck.NetInfo.MappingVariesByDestIP.EqualBool(true) { |
| 562 | agent = append(agent, |
| 563 | fmt.Sprintf("Agent is potentially behind a hard NAT, as multiple endpoints were retrieved from different STUN servers\n %s#endpoint-dependent-nat-hard-nat", d.TroubleshootingURL)) |
| 564 | } |
| 565 | if !d.AgentNetcheck.NetInfo.UDP { |