From a1e98c66457af11cc752c40a1bda7e0569917911 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Sat, 13 Dec 2014 00:20:07 +0100 Subject: [PATCH] MT#10603 Print autprov config access/failure --- lib/NGCP/Panel/Controller/Device.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/NGCP/Panel/Controller/Device.pm b/lib/NGCP/Panel/Controller/Device.pm index 5f129179b6..548df2b513 100644 --- a/lib/NGCP/Panel/Controller/Device.pm +++ b/lib/NGCP/Panel/Controller/Device.pm @@ -1095,10 +1095,20 @@ sub dev_field_config :Chained('/') :PathPart('device/autoprov/config') :Args() { $yealink_key = $c->config->{autoprovisioning}->{yealink_key}; } + # print access details for external rate limiting (e.g. fail2ban) + my $ip; + if(defined $c->req->headers->header('X-Forwarded-For')) { + $ip = (split(/\s*,\s*/, $c->req->headers->header('X-Forwarded-For')))[0]; + } else { + $ip = $c->req->address; + } + $c->log->notice("Serving autoprov config for '$id' to '$ip'"); + my $dev = $c->model('DB')->resultset('autoprov_field_devices')->find({ identifier => $id }); unless($dev) { + $c->log->notice("Unknown autoprov config '$id' for '$ip'"); $c->response->content_type('text/plain'); if($c->config->{features}->{debug}) { $c->response->body("404 - device id '" . $id . "' not found");