Files
librenms-librenms/app/Http/Controllers/Table/PortNacController.php
PipoCanaja fff8b8e832 Collect OUI Database and do OUI lookups (#12842)
* first draft

refresh time

refresh time

* return codes

style

style

* presentation

* Exception details

more

fix

fix

* add tooltips

fixes for dns display

* create WebUI config option

languages

* refresh data every 7 to 11 days, keep it 15 days max

* 'Ports' and 'Port' ARP table

* Stp page support

style

style

* fix dnsname column finding when vendor is added/removed

fix dnsname column finding when vendor is added/removed

* nac vendor column

nac

* filter fields to reduce size of AJAX reply

filter fields to reduce size of AJAX reply

* fix typo on dns column detection

* default enabled
2021-05-10 14:56:48 -05:00

94 lines
2.7 KiB
PHP

<?php
/**
* PortNacController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Table;
use App\Models\PortsNac;
use LibreNMS\Util\Rewrite;
use LibreNMS\Util\Url;
class PortNacController extends TableController
{
public function rules()
{
return [
'device_id' => 'required|int',
];
}
public function searchFields($request)
{
return ['username', 'ip_address', 'mac_address'];
}
protected function sortFields($request)
{
return [
'port_id',
'mac_address',
'mac_oui',
'ip_address',
'vlan',
'domain',
'host_mode',
'username',
'authz_by',
'timeout',
'time_elapsed',
'time_left',
'authc_status',
'authz_status',
'method',
];
}
/**
* Defines the base query for this resource
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
*/
public function baseQuery($request)
{
return PortsNac::select('port_id', 'mac_address', 'ip_address', 'vlan', 'domain', 'host_mode', 'username', 'authz_by', 'timeout', 'time_elapsed', 'time_left', 'authc_status', 'authz_status', 'method')
->where('device_id', $request->device_id)
->hasAccess($request->user())
->with('port');
}
/**
* @param PortsNac $nac
*/
public function formatItem($nac)
{
$item = $nac->toArray();
$item['port_id'] = Url::portLink($nac->port, $nac->port->getShortLabel());
$item['mac_oui'] = Rewrite::readableOUI($item['mac_address']);
$item['mac_address'] = Rewrite::readableMac($item['mac_address']);
$item['port'] = null; //free some unused data to be sent to the browser
return $item;
}
}