Skip to content

Commit

Permalink
Fix IPv6 in service check host (librenms#13939)
Browse files Browse the repository at this point in the history
* Add hostName cleaning to Clean

* Apply RFC 5952 formatting to Clean::hostName output

* Use more liberal cleaning for hostnames

* Remove unwanted whitespace

* Apply Clean::hostName() to all relevant fields

* Fix docstring

* Use IP::isValid inline

* Update Clean.php

* Update services.inc.php

Co-authored-by: Tony Murray <[email protected]>
  • Loading branch information
steffann and murrant authored Apr 22, 2022
1 parent 4aaf6f2 commit d4479e1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions includes/services.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use LibreNMS\Config;
use LibreNMS\RRD\RrdDefinition;
use LibreNMS\Util\Clean;
use LibreNMS\Util\IP;

function get_service_status($device = null)
{
Expand Down Expand Up @@ -122,9 +123,9 @@ function poll_service($service)
$update = [];
$old_status = $service['service_status'];
$service['service_type'] = Clean::fileName($service['service_type']);
$service['service_ip'] = Clean::fileName($service['service_ip']);
$service['hostname'] = Clean::fileName($service['hostname']);
$service['overwrite_ip'] = Clean::fileName($service['overwrite_ip']);
$service['service_ip'] = IP::isValid($service['service_ip']) ? $service['service_ip'] : Clean::fileName($service['service_ip']);
$service['hostname'] = IP::isValid($service['hostname']) ? $service['hostname'] : Clean::fileName($service['hostname']);
$service['overwrite_ip'] = IP::isValid($service['overwrite_ip']) ? $service['overwrite_ip'] : Clean::fileName($service['overwrite_ip']);
$check_cmd = '';

// if we have a script for this check, use it.
Expand Down

0 comments on commit d4479e1

Please sign in to comment.