2 Copyright
2010 Jo-Philipp Wich
<jow@openwrt.org
>
3 Licensed to the public under the Apache License
2.0.
9 local fs = require
"nixio.fs"
10 local has_ping6 = fs.access(
"/bin/ping6") or fs.access(
"/usr/bin/ping6")
11 local has_traceroute6 = fs.access(
"/usr/bin/traceroute6")
13 local dns_host = luci.config.diag and luci.config.diag.dns or
"dev.openwrt.org"
14 local ping_host = luci.config.diag and luci.config.diag.ping or
"dev.openwrt.org"
15 local route_host = luci.config.diag and luci.config.diag.route or
"dev.openwrt.org"
18 <script type=
"text/javascript" src=
"<%=resource%>/cbi.js"></script>
19 <script type=
"text/javascript">//<![CDATA[
20 var stxhr = new XHR();
22 function update_status(field, proto)
24 var tool = field.name;
25 var addr = field.value;
26 var protocol = proto ?
"6" :
"";
28 var legend = document.getElementById('diag-rc-legend');
29 var output = document.getElementById('diag-rc-output');
34 '
<img src=
"<%=resource%>/icons/loading.gif" alt=
"<%:Loading%>" style=
"vertical-align:middle" /> ' +
35 '<%:Waiting for command to complete...%
>'
38 legend.parentNode.style.display = 'block';
39 legend.style.display = 'inline';
41 stxhr.post('<%=url('admin/network')%
>/diag_' + tool + protocol + '/' + addr, { token: '<%=token%
>' },
46 legend.style.display = 'none';
47 output.innerHTML = String.format('
<pre>%h
</pre>', x.responseText);
51 legend.style.display = 'none';
52 output.innerHTML = '
<span class=
"error"><%:Bad address specified!%
></span>';
60 <form method=
"post" action=
"<%=url('admin/network/diagnostics')%>">
62 <h2 name=
"content"><%:Diagnostics%
></h2>
64 <div class=
"cbi-section">
65 <legend><%:Network Utilities%
></legend>
70 <input style=
"margin: 5px 0" type=
"text" value=
"<%=ping_host%>" name=
"ping" /><br />
71 <% if has_ping6 then %
>
72 <select name=
"ping_proto" style=
"width:auto">
73 <option value=
"" selected=
"selected"><%:IPv4%
></option>
74 <option value=
"6"><%:IPv6%
></option>
76 <input type=
"button" value=
"<%:Ping%>" class=
"cbi-button cbi-button-apply" onclick=
"update_status(this.form.ping, this.form.ping_proto.selectedIndex)" />
78 <input type=
"button" value=
"<%:Ping%>" class=
"cbi-button cbi-button-apply" onclick=
"update_status(this.form.ping)" />
83 <input style=
"margin: 5px 0" type=
"text" value=
"<%=route_host%>" name=
"traceroute" /><br />
84 <% if has_traceroute6 then %
>
85 <select name=
"traceroute_proto" style=
"width:auto">
86 <option value=
"" selected=
"selected"><%:IPv4%
></option>
87 <option value=
"6"><%:IPv6%
></option>
89 <input type=
"button" value=
"<%:Traceroute%>" class=
"cbi-button cbi-button-apply" onclick=
"update_status(this.form.traceroute, this.form.traceroute_proto.selectedIndex)" />
91 <input type=
"button" value=
"<%:Traceroute%>" class=
"cbi-button cbi-button-apply" onclick=
"update_status(this.form.traceroute)" />
93 <% if not has_traceroute6 then %
>
95 <p><%:Install iputils-traceroute6 for IPv6 traceroute%
></p>
100 <input style=
"margin: 5px 0" type=
"text" value=
"<%=dns_host%>" name=
"nslookup" /><br />
101 <input type=
"button" value=
"<%:Nslookup%>" class=
"cbi-button cbi-button-apply" onclick=
"update_status(this.form.nslookup)" />
108 <div class=
"cbi-section" style=
"display:none">
109 <strong id=
"diag-rc-legend"></strong>
110 <span id=
"diag-rc-output"></span>