Commit 597b68c9 authored by Dominik Hebeler's avatar Dominik Hebeler

added logging to browserverification

parent 41fd2162
......@@ -61,7 +61,9 @@ class BrowserVerification
$request->request->add(["headerPrinted" => false, "jskey" => $mgv]);
return $next($request);
} else {
return redirect("/");
# We are serving that request but log it for fail2ban
self::logBrowserverification($request);
return $next($request);
}
}
......@@ -86,4 +88,27 @@ class BrowserVerification
->with('url', $url)
->render());
}
public static logBrowserverification() {
$fail2banEnabled = config("metager.metager.fail2ban_enabled");
if(empty($fail2banEnabled) || !$fail2banEnabled || !env("fail2banurl", false) || !env("fail2banuser") || !env("fail2banpassword")){
return;
}
// Submit fetch job to worker
$mission = [
"resulthash" => "captcha",
"url" => env("fail2banurl") . "/browserverification/",
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => env("fail2banuser"),
"password" => env("fail2banpassword"),
"headers" => [
"ip" => $request->ip()
],
"cacheDuration" => 0,
"name" => "Captcha",
];
$mission = json_encode($mission);
Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment