MCPcopy Create free account
hub / github.com/Hidden-Node/GooseRelayVPN-AndroidClient / writeDiagnosticsZip

Function writeDiagnosticsZip

cmd/client/diagnostics.go:18–72  ·  view source on GitHub ↗
(outPath, configPath, version string)

Source from the content-addressed store, hash-verified

16)
17
18func writeDiagnosticsZip(outPath, configPath, version string) (string, error) {
19 if strings.TrimSpace(outPath) == "" {
20 outPath = fmt.Sprintf("goose-diagnostics-%s.zip", time.Now().Format("20060102-150405"))
21 }
22 outPath = filepath.Clean(outPath)
23
24 f, err := os.Create(outPath)
25 if err != nil {
26 return "", err
27 }
28 zw := zip.NewWriter(f)
29 cleanup := true
30 defer func() {
31 if cleanup {
32 _ = zw.Close()
33 _ = f.Close()
34 }
35 }()
36
37 addText := func(name, body string) error {
38 w, err := zw.Create(name)
39 if err != nil {
40 return err
41 }
42 _, err = io.WriteString(w, body)
43 return err
44 }
45
46 if err := addText("README.txt", diagnosticsReadme(configPath)); err != nil {
47 return "", err
48 }
49 if err := addText("runtime.txt", diagnosticsRuntime(configPath, version)); err != nil {
50 return "", err
51 }
52 if err := addDiagnosticsSummary(zw, configPath, version); err != nil {
53 return "", err
54 }
55 if err := addProfile(zw, "goroutine.txt", "goroutine", 2); err != nil {
56 return "", err
57 }
58 if err := addProfile(zw, "heap.txt", "heap", 1); err != nil {
59 return "", err
60 }
61 if err := addRedactedConfig(zw, configPath); err != nil {
62 return "", err
63 }
64 if err := zw.Close(); err != nil {
65 return "", err
66 }
67 if err := f.Close(); err != nil {
68 return "", err
69 }
70 cleanup = false
71 return outPath, nil
72}
73
74func diagnosticsReadme(configPath string) string {
75 return fmt.Sprintf(`GooseRelayVPN diagnostics bundle

Callers 2

mainFunction · 0.85

Calls 6

diagnosticsReadmeFunction · 0.85
diagnosticsRuntimeFunction · 0.85
addDiagnosticsSummaryFunction · 0.85
addProfileFunction · 0.85
addRedactedConfigFunction · 0.85
CloseMethod · 0.80

Tested by 1