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

Function addDiagnosticsSummary

cmd/client/diagnostics.go:112–164  ·  view source on GitHub ↗
(zw *zip.Writer, configPath, version string)

Source from the content-addressed store, hash-verified

110}
111
112func addDiagnosticsSummary(zw *zip.Writer, configPath, version string) error {
113 w, err := zw.Create("diagnostics.json")
114 if err != nil {
115 return err
116 }
117 raw, err := os.ReadFile(configPath)
118 if err != nil {
119 summary := map[string]any{
120 "version": version,
121 "generated_at": time.Now().Format(time.RFC3339),
122 "config_error": err.Error(),
123 }
124 body, marshalErr := json.MarshalIndent(summary, "", " ")
125 if marshalErr != nil {
126 return marshalErr
127 }
128 _, err = w.Write(append(body, '\n'))
129 return err
130 }
131 redacted, err := redactConfigJSON(raw)
132 if err != nil {
133 summary := map[string]any{
134 "version": version,
135 "generated_at": time.Now().Format(time.RFC3339),
136 "config_error": err.Error(),
137 }
138 body, marshalErr := json.MarshalIndent(summary, "", " ")
139 if marshalErr != nil {
140 return marshalErr
141 }
142 _, err = w.Write(append(body, '\n'))
143 return err
144 }
145
146 var cfg map[string]any
147 if err := json.Unmarshal(redacted, &cfg); err != nil {
148 return err
149 }
150 summary := map[string]any{
151 "version": version,
152 "generated_at": time.Now().Format(time.RFC3339),
153 "go_version": runtime.Version(),
154 "goos": runtime.GOOS,
155 "goarch": runtime.GOARCH,
156 "config": diagnosticsConfigSummary(cfg),
157 }
158 body, err := json.MarshalIndent(summary, "", " ")
159 if err != nil {
160 return err
161 }
162 _, err = w.Write(append(body, '\n'))
163 return err
164}
165
166func diagnosticsConfigSummary(cfg map[string]any) map[string]any {
167 out := make(map[string]any)

Callers 1

writeDiagnosticsZipFunction · 0.85

Calls 4

redactConfigJSONFunction · 0.85
diagnosticsConfigSummaryFunction · 0.85
ErrorMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected