(w http.ResponseWriter, r *http.Request, ip string, lg *slog.Logger)
| 331 | } |
| 332 | |
| 333 | func (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 | |
| 361 | func (s *Server) MakeChallenge(w http.ResponseWriter, r *http.Request) { |
| 362 | lg := internal.GetRequestLogger(s.logger, r) |
no test coverage detected