1
|
<?php
|
2
|
/*
|
3
|
diag_traceroute.php
|
4
|
part of m0n0wall (http://m0n0.ch/wall)
|
5
|
|
6
|
Copyright (C) 2005 Paul Taylor (paultaylor@winndixie.com) and Manuel Kasper <mk@neon1.net>.
|
7
|
All rights reserved.
|
8
|
|
9
|
Redistribution and use in source and binary forms, with or without
|
10
|
modification, are permitted provided that the following conditions are met:
|
11
|
|
12
|
1. Redistributions of source code must retain the above copyright notice,
|
13
|
this list of conditions and the following disclaimer.
|
14
|
|
15
|
2. Redistributions in binary form must reproduce the above copyright
|
16
|
notice, this list of conditions and the following disclaimer in the
|
17
|
documentation and/or other materials provided with the distribution.
|
18
|
|
19
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
POSSIBILITY OF SUCH DAMAGE.
|
29
|
*/
|
30
|
|
31
|
/*
|
32
|
pfSense_BUILDER_BINARIES: /usr/sbin/traceroute
|
33
|
pfSense_MODULE: routing
|
34
|
*/
|
35
|
|
36
|
##|+PRIV
|
37
|
##|*IDENT=page-diagnostics-traceroute
|
38
|
##|*NAME=Diagnostics: Traceroute page
|
39
|
##|*DESCR=Allow access to the 'Diagnostics: Traceroute' page.
|
40
|
##|*MATCH=diag_traceroute.php*
|
41
|
##|-PRIV
|
42
|
|
43
|
require("guiconfig.inc");
|
44
|
|
45
|
$pgtitle = array(gettext("Diagnostics"),gettext("Traceroute"));
|
46
|
include("head.inc");
|
47
|
|
48
|
?>
|
49
|
<body link="#000000" vlink="#000000" alink="#000000">
|
50
|
<? include("fbegin.inc"); ?>
|
51
|
<?php
|
52
|
|
53
|
define('MAX_TTL', 64);
|
54
|
define('DEFAULT_TTL', 18);
|
55
|
|
56
|
if ($_POST || $_REQUEST['host']) {
|
57
|
unset($input_errors);
|
58
|
unset($do_traceroute);
|
59
|
|
60
|
/* input validation */
|
61
|
$reqdfields = explode(" ", "host ttl");
|
62
|
$reqdfieldsn = array(gettext("Host"),gettext("ttl"));
|
63
|
do_input_validation($_REQUEST, $reqdfields, $reqdfieldsn, &$input_errors);
|
64
|
|
65
|
if (($_REQUEST['ttl'] < 1) || ($_REQUEST['ttl'] > MAX_TTL)) {
|
66
|
$input_errors[] = sprintf(gettext("Maximum number of hops must be between 1 and %s"), MAX_TTL);
|
67
|
}
|
68
|
|
69
|
if (!$input_errors) {
|
70
|
$do_traceroute = true;
|
71
|
$host = $_REQUEST['host'];
|
72
|
$ttl = $_REQUEST['ttl'];
|
73
|
|
74
|
}
|
75
|
}
|
76
|
if (!isset($do_traceroute)) {
|
77
|
$do_traceroute = false;
|
78
|
$host = '';
|
79
|
$ttl = DEFAULT_TTL;
|
80
|
}
|
81
|
?>
|
82
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
83
|
<form action="diag_traceroute.php" method="post" name="iform" id="iform">
|
84
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
85
|
<tr>
|
86
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Traceroute");?></td>
|
87
|
</tr>
|
88
|
<tr>
|
89
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Host");?></td>
|
90
|
<td width="78%" class="vtable">
|
91
|
<?=$mandfldhtml;?><input name="host" type="text" class="formfld" id="host" size="20" value="<?=htmlspecialchars($host);?>"></td>
|
92
|
</tr>
|
93
|
<tr>
|
94
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Maximum number of hops");?></td>
|
95
|
<td width="78%" class="vtable">
|
96
|
<select name="ttl" class="formfld" id="ttl">
|
97
|
<?php for ($i = 1; $i <= MAX_TTL; $i++): ?>
|
98
|
<option value="<?=$i;?>" <?php if ($i == $ttl) echo "selected"; ?>><?=$i;?></option>
|
99
|
<?php endfor; ?>
|
100
|
</select></td>
|
101
|
</tr>
|
102
|
|
103
|
<tr>
|
104
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Use ICMP");?></td>
|
105
|
<td width="78%" class="vtable">
|
106
|
<input name="useicmp" type="checkbox"<?php if($_REQUEST['useicmp']) echo " CHECKED"; ?>>
|
107
|
</td>
|
108
|
</tr>
|
109
|
<tr>
|
110
|
<td width="22%" valign="top"> </td>
|
111
|
<td width="78%">
|
112
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Traceroute");?>">
|
113
|
</td>
|
114
|
</tr>
|
115
|
<tr>
|
116
|
<td valign="top" colspan="2">
|
117
|
<p><span class="vexpl"><span class="red"><b><?=gettext("Note:");?></b></span><?=gettext("Traceroute may take a while to complete. You may hit the Stop button on your browser at any time to see the progress of failed traceroutes.");?><p>
|
118
|
<? if ($do_traceroute) {
|
119
|
echo "<font face='terminal' size='2'>";
|
120
|
echo("<br><strong>" . gettext("Traceroute output:") . "</strong><br>");
|
121
|
echo('<pre>');
|
122
|
ob_end_flush();
|
123
|
if($_REQUEST['useicmp'])
|
124
|
$useicmp = "-I";
|
125
|
else
|
126
|
$useicmp = "";
|
127
|
system("/usr/sbin/traceroute $useicmp -w 2 -m " . escapeshellarg($ttl) . " " . escapeshellarg($host));
|
128
|
echo('</pre>');
|
129
|
}
|
130
|
?>
|
131
|
</td>
|
132
|
</tr>
|
133
|
<tr>
|
134
|
<td width="22%" valign="top"> </td>
|
135
|
<td width="78%">
|
136
|
<span class="vexpl"><b><?=gettext("Note:");?></b></span><?=gettext("Multi-wan is not supported from this utility currently.");?>
|
137
|
</td>
|
138
|
</tr>
|
139
|
</table>
|
140
|
</form>
|
141
|
<?php include("fend.inc"); ?>
|