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

Method handleDNSBL

lib/anubis.go:333–359  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, ip string, lg *slog.Logger)

Source from the content-addressed store, hash-verified

331}
332
333func (s *Server) handleDNSBL(w http.ResponseWriter, r *http.Request, ip string, lg *slog.Logger) bool {
334 db := &store.JSON[dnsbl.DroneBLResponse]{Underlying: s.store, Prefix: "dronebl:"}
335 if s.policy.DNSBL && ip != "" {
336 resp, err := db.Get(r.Context(), ip)
337 if err != nil {
338 lg.Debug("looking up ip in dnsbl")
339 resp, err := dnsbl.Lookup(ip)
340 if err != nil {
341 lg.Error("can't look up ip in dnsbl", "err", err)
342 }
343 db.Set(r.Context(), ip, resp, 24*time.Hour)
344 droneBLHits.WithLabelValues(resp.String()).Inc()
345 }
346
347 if resp != dnsbl.AllGood {
348 lg.Info("DNSBL hit", "status", resp.String())
349 localizer := localization.GetLocalizer(r)
350 s.respondWithStatus(w, r, fmt.Sprintf("%s: %s, %s https://dronebl.org/lookup?ip=%s",
351 localizer.T("dronebl_entry"),
352 resp.String(),
353 localizer.T("see_dronebl_lookup"),
354 ip), "", s.policy.StatusCodes.Deny)
355 return true
356 }
357 }
358 return false
359}
360
361func (s *Server) MakeChallenge(w http.ResponseWriter, r *http.Request) {
362 lg := internal.GetRequestLogger(s.logger, r)

Callers 1

maybeReverseProxyMethod · 0.95

Calls 8

respondWithStatusMethod · 0.95
LookupFunction · 0.92
GetLocalizerFunction · 0.92
ErrorMethod · 0.80
TMethod · 0.80
GetMethod · 0.65
SetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected