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("/bin/traceroute6") or 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">//<![CDATA[
19 var stxhr = new XHR();
21 function update_status(field, proto)
23 var tool = field.name;
24 var addr = field.value;
25 var protocol = proto ? "6" : "";
27 var legend = document.getElementById('diag-rc-legend');
28 var output = document.getElementById('diag-rc-output');
33 '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
34 '<%:Waiting for command to complete...%>'
37 legend.parentNode.style.display = 'block';
38 legend.style.display = 'inline';
40 stxhr.post('<%=url('admin/network')%>/diag_' + tool + protocol + '/' + addr, { token: '<%=token%>' },
45 legend.style.display = 'none';
46 output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
50 legend.style.display = 'none';
51 output.innerHTML = '<span class="error"><%:Bad address specified!%></span>';
59 <form method="post" action="<%=url('admin/network/diagnostics')%>">
61 <h2 name="content"><%:Diagnostics%></h2>
63 <div class="cbi-section">
64 <legend><%:Network Utilities%></legend>
69 <input style="margin: 5px 0" type="text" value="<%=ping_host%>" name="ping" /><br />
70 <% 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>
77 <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping, this.form.ping_proto.selectedIndex)" />
79 <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping)" />
84 <input style="margin: 5px 0" type="text" value="<%=route_host%>" name="traceroute" /><br />
85 <% if has_traceroute6 then %>
87 <select name="traceroute_proto" style="width:auto">
88 <option value="" selected="selected"><%:IPv4%></option>
89 <option value="6"><%:IPv6%></option>
92 <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute, this.form.traceroute_proto.selectedIndex)" />
94 <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute)" />
96 <% if not has_traceroute6 then %>
98 <p><%:Install iputils-traceroute6 for IPv6 traceroute%></p>
102 <div class="td left">
103 <input style="margin: 5px 0" type="text" value="<%=dns_host%>" name="nslookup" /><br />
104 <input type="button" value="<%:Nslookup%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.nslookup)" />
111 <div class="cbi-section" style="display:none">
112 <strong id="diag-rc-legend"></strong>
113 <span id="diag-rc-output"></span>