admin-full/diagnostics: Allow to use ping6 and traceroute6 when available, #487
authorManuel Munz <freifunk@somakoma.de>
Sun, 11 Nov 2012 12:20:56 +0000 (12:20 +0000)
committerManuel Munz <freifunk@somakoma.de>
Sun, 11 Nov 2012 12:20:56 +0000 (12:20 +0000)
modules/admin-full/luasrc/controller/admin/network.lua
modules/admin-full/luasrc/view/admin_network/diagnostics.htm

index 85dc68fff0128b5c16396a4da85c7569f106ced4..6f55ff77796162feadb125fc8ccd68a81947d219 100644 (file)
@@ -156,6 +156,12 @@ function index()
 
                page = entry({"admin", "network", "diag_traceroute"}, call("diag_traceroute"), nil)
                page.leaf = true
+
+               page = entry({"admin", "network", "diag_ping6"}, call("diag_ping6"), nil)
+               page.leaf = true
+
+               page = entry({"admin", "network", "diag_traceroute6"}, call("diag_traceroute6"), nil)
+               page.leaf = true
 --     end
 end
 
@@ -463,3 +469,11 @@ end
 function diag_nslookup()
        diag_command("nslookup %q 2>&1")
 end
+
+function diag_ping6()
+       diag_command("ping6 -c 5 %q 2>&1")
+end
+
+function diag_traceroute6()
+       diag_command("traceroute6 -q 1 -w 2 -n %q 2>&1")
+end
index a991f9a48fd14895d814758eb9af3eec007d08ba..abbc906234df0b44a24f04a31d6e4346219ec910 100644 (file)
@@ -14,18 +14,33 @@ $Id$
 
 <%+header%>
 
+<%
+local fs   = require "nixio.fs"
+local has_ping6 = fs.access("/bin/ping6") or fs.access("/usr/bin/ping6")
+local has_traceroute6 = fs.access("/usr/bin/traceroute6")
+%>
+
 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
 <script type="text/javascript">//<![CDATA[
        var stxhr = new XHR();
 
-       function update_status(field)
+       function update_status(field,proto)
        {
                var tool = field.name;
                var addr = field.value;
+               var protocol = ""
 
                var legend = document.getElementById('diag-rc-legend');
                var output = document.getElementById('diag-rc-output');
 
+               if (typeof proto != 'undefined') {
+                       for(var i = 0; i < proto.length; i++) {
+                               if(proto[i].checked) {
+                                       protocol = proto[i].value;
+                               }
+                       }
+               }
+
                if (legend && output)
                {
                        output.innerHTML =
@@ -36,7 +51,7 @@ $Id$
                        legend.parentNode.style.display = 'block';
                        legend.style.display = 'inline';
 
-                       stxhr.get('<%=luci.dispatcher.build_url("admin", "network")%>/diag_' + tool + '/' + addr, null,
+                       stxhr.get('<%=luci.dispatcher.build_url("admin", "network")%>/diag_' + tool + protocol + '/' + addr, null,
                                function(x)
                                {
                                        if (x.responseText)
@@ -64,17 +79,29 @@ $Id$
 
                        <br />
 
-                       <div style="width:30%; float:left; text-align:center">
+                       <div style="width:30%; float:left">
                                <input style="width: 50%" type="text" value="openwrt.org" name="ping" />
-                               <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping)" />
+                               <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping,this.form.proto)" />
+                               <% if has_ping6 then %>
+                               <div style="width:100%; margin-top: 10px;">
+                                       <input type="radio" name="proto" value="" checked> <%:IPv4%>
+                                       <input type="radio" name="proto" value="6"> <%:IPv6%>
+                               </div>
+                               <%end%>
                        </div>
 
-                       <div style="width:30%; float:left; text-align:center">
+                       <div style="width:33%; float:left">
                                <input style="width: 50%" type="text" value="openwrt.org" name="traceroute" />
-                               <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute)" />
+                               <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute,this.form.trproto)" />
+                               <% if has_traceroute6 then %>
+                               <div style="width:100%; margin-top: 10px;">
+                                       <input type="radio" name="trproto" value="" checked> <%:IPv4%>
+                                       <input type="radio" name="trproto" value="6"> <%:IPv6%>
+                               </div>
+                               <%end%>
                        </div>
 
-                       <div style="width:30%; float:left; text-align:center">
+                       <div style="width:33%; float:left;">
                                <input style="width: 50%" type="text" value="openwrt.org" name="nslookup" />
                                <input type="button" value="<%:Nslookup%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.nslookup)" />
                        </div>