summaryrefslogtreecommitdiffstats
path: root/usr/local/www/diag_ping.php
diff options
context:
space:
mode:
authorSeth Mos <seth.mos@dds.nl>2010-10-23 12:19:11 +0200
committerSeth Mos <seth.mos@dds.nl>2010-10-23 12:19:11 +0200
commit86551a0623d80616bc7c6cc3a5ca6e122274b8c6 (patch)
tree4c21d04eed73847c3ec6dc9e266a6dc547f8913e /usr/local/www/diag_ping.php
parent5a5413bb5227e084703515007cc28fd746183c9b (diff)
downloadpfsense-86551a0623d80616bc7c6cc3a5ca6e122274b8c6.zip
pfsense-86551a0623d80616bc7c6cc3a5ca6e122274b8c6.tar.gz
Do a gethostbyname() on the host address to get a IP address, then perform ping or ping6 for correct type.
Diffstat (limited to 'usr/local/www/diag_ping.php')
-rwxr-xr-xusr/local/www/diag_ping.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/usr/local/www/diag_ping.php b/usr/local/www/diag_ping.php
index 0bbc7d5..3715cf8 100755
--- a/usr/local/www/diag_ping.php
+++ b/usr/local/www/diag_ping.php
@@ -61,7 +61,7 @@ if ($_POST || $_REQUEST['host']) {
if (!$input_errors) {
$do_ping = true;
- $host = $_REQUEST['host'];
+ $host = gethostbyname($_REQUEST['host']);
$interface = $_REQUEST['interface'];
$count = $_POST['count'];
if (preg_match('/[^0-9]/', $count) )
@@ -125,11 +125,21 @@ include("head.inc"); ?>
echo "<font face='terminal' size='2'>";
echo "<strong>" . gettext("Ping output") . ":</strong><br>";
echo('<pre>');
- $ifaddr = get_interface_ip($interface);
- if ($ifaddr)
- system("/sbin/ping -S$ifaddr -c$count " . escapeshellarg($host));
- else
- system("/sbin/ping -c$count " . escapeshellarg($host));
+ if(is_ipaddrv4($host)) {
+ $ifaddr = get_interface_ip($interface);
+ if ($ifaddr)
+ system("/sbin/ping -S$ifaddr -c$count " . escapeshellarg($host));
+ else
+ system("/sbin/ping -c$count " . escapeshellarg($host));
+ }
+ if(is_ipaddrv6($host)) {
+ $ifaddr = get_interface_ipv6($interface);
+ if ($ifaddr)
+ system("/sbin/ping6 -S$ifaddr -c$count " . escapeshellarg($host));
+ else
+ system("/sbin/ping6 -c$count " . escapeshellarg($host));
+ }
+
echo('</pre>');
}
?>
OpenPOWER on IntegriCloud