MCPcopy
hub / github.com/TecharoHQ/anubis / makeCode

Function makeCode

lib/http.go:171–193  ·  view source on GitHub ↗
(err error)

Source from the content-addressed store, hash-verified

169}
170
171func makeCode(err error) string {
172 var buf bytes.Buffer
173 gzw := gzip.NewWriter(&buf)
174 errStr := fmt.Sprintf("internal error: %v", err)
175
176 fmt.Fprintln(gzw, rot13(errStr))
177 if err := gzw.Close(); err != nil {
178 panic("can't write to gzip in ram buffer")
179 }
180 const width = 16
181
182 enc := base64.StdEncoding.EncodeToString(buf.Bytes())
183 var builder strings.Builder
184 for i := 0; i < len(enc); i += width {
185 end := i + width
186 if end > len(enc) {
187 end = len(enc)
188 }
189 builder.WriteString(enc[i:end])
190 builder.WriteByte('\n')
191 }
192 return builder.String()
193}
194
195func (s *Server) RenderIndex(w http.ResponseWriter, r *http.Request, cr policy.CheckResult, rule *policy.Bot, returnHTTPStatusOnly bool) {
196 localizer := localization.GetLocalizer(r)

Callers 5

RenderIndexMethod · 0.85
ServeHTTPNextMethod · 0.85
maybeReverseProxyMethod · 0.85
checkRulesMethod · 0.85
PassChallengeMethod · 0.85

Calls 3

rot13Function · 0.85
CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected