MCPcopy
hub / github.com/tailscale/tailscale / printNetCheckReport

Function printNetCheckReport

cmd/tailscale/cli/netcheck.go:157–247  ·  view source on GitHub ↗
(dm *tailcfg.DERPMap, report *netcheck.Report)

Source from the content-addressed store, hash-verified

155}
156
157func printNetCheckReport(dm *tailcfg.DERPMap, report *netcheck.Report) error {
158 var j []byte
159 var err error
160 switch netcheckArgs.format {
161 case "":
162 case "json":
163 j, err = json.MarshalIndent(report, "", "\t")
164 case "json-line":
165 j, err = json.Marshal(report)
166 default:
167 return fmt.Errorf("unknown output format %q", netcheckArgs.format)
168 }
169 if err != nil {
170 return err
171 }
172 if j != nil {
173 j = append(j, '\n')
174 Stdout.Write(j)
175 return nil
176 }
177
178 printf("\nReport:\n")
179 printf("\t* Time: %v\n", report.Now.Local().Format(tstime.DateSpTimeNanoZ))
180 printf("\t* UDP: %v\n", report.UDP)
181 if report.GlobalV4.IsValid() {
182 printf("\t* IPv4: yes, %s\n", report.GlobalV4)
183 } else {
184 printf("\t* IPv4: (no addr found)\n")
185 }
186 if report.GlobalV6.IsValid() {
187 printf("\t* IPv6: yes, %s\n", report.GlobalV6)
188 } else if report.IPv6 {
189 printf("\t* IPv6: (no addr found)\n")
190 } else if report.OSHasIPv6 {
191 printf("\t* IPv6: no, but OS has support\n")
192 } else {
193 printf("\t* IPv6: no, unavailable in OS\n")
194 }
195 printf("\t* MappingVariesByDestIP: %v\n", report.MappingVariesByDestIP)
196 printf("\t* PortMapping: %v\n", portMapping(report))
197 if report.CaptivePortal != "" {
198 printf("\t* CaptivePortal: %v\n", report.CaptivePortal)
199 }
200
201 // When DERP latency checking failed,
202 // magicsock will try to pick the DERP server that
203 // most of your other nodes are also using
204 if len(report.RegionLatency) == 0 {
205 printf("\t* Nearest DERP: unknown (no response to latency probes)\n")
206 } else {
207 if report.PreferredDERP != 0 {
208 if region, ok := dm.Regions[report.PreferredDERP]; ok {
209 printf("\t* Nearest DERP: %v\n", region.RegionName)
210 } else {
211 printf("\t* Nearest DERP: %v (region not found in map)\n", report.PreferredDERP)
212 }
213 } else {
214 printf("\t* Nearest DERP: [none]\n")

Callers 1

runNetcheckFunction · 0.85

Calls 9

printfFunction · 0.70
portMappingFunction · 0.70
MarshalMethod · 0.65
ErrorfMethod · 0.65
WriteMethod · 0.65
StringMethod · 0.65
FormatMethod · 0.45
IsValidMethod · 0.45
SliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…