diagnostics.htm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <%#
  2. Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
  3. Licensed to the public under the Apache License 2.0.
  4. -%>
  5. <%+header%>
  6. <%
  7. local fs = require "nixio.fs"
  8. local has_ping6 = fs.access("/bin/ping6") or fs.access("/usr/bin/ping6")
  9. local has_traceroute6 = fs.access("/usr/bin/traceroute6")
  10. %>
  11. <script type="text/javascript">//<![CDATA[
  12. var stxhr = new XHR();
  13. function update_status(field, proto)
  14. {
  15. var tool = field.name;
  16. var addr = field.value;
  17. var protocol = proto ? "6" : "";
  18. var legend = document.getElementById('diag-rc-legend');
  19. var output = document.getElementById('diag-rc-output');
  20. if (legend && output)
  21. {
  22. output.innerHTML =
  23. '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
  24. '<%:Waiting for command to complete...%>'
  25. ;
  26. legend.parentNode.style.display = 'block';
  27. legend.style.display = 'inline';
  28. stxhr.get('<%=url('freifunk/status')%>/diag_' + tool + protocol + '/' + addr, null,
  29. function(x)
  30. {
  31. if (x.responseText)
  32. {
  33. legend.style.display = 'none';
  34. output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
  35. }
  36. else
  37. {
  38. legend.style.display = 'none';
  39. output.innerHTML = '<span class="error"><%:Bad address specified!%></span>';
  40. }
  41. }
  42. );
  43. }
  44. }
  45. //]]></script>
  46. <form method="post" action="<%=pcdata(FULL_REQUEST_URI)%>">
  47. <div class="cbi-map">
  48. <h2 name="content"><%:Diagnostics%></h2>
  49. <fieldset class="cbi-section">
  50. <legend><%:Network Utilities%></legend>
  51. <br />
  52. <div style="width:30%; float:left">
  53. <input style="margin: 5px 0" type="text" value="dev.openwrt.org" name="ping" /><br />
  54. <% if has_ping6 then %>
  55. <select name="ping_proto" style="width:auto">
  56. <option value="" selected="selected"><%:IPv4%></option>
  57. <option value="6"><%:IPv6%></option>
  58. </select>
  59. <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping, this.form.ping_proto.selectedIndex)" />
  60. <% else %>
  61. <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping)" />
  62. <% end %>
  63. </div>
  64. <div style="width:33%; float:left">
  65. <input style="margin: 5px 0" type="text" value="dev.openwrt.org" name="traceroute" /><br />
  66. <% if has_traceroute6 then %>
  67. <select name="traceroute_proto" style="width:auto">
  68. <option value="" selected="selected"><%:IPv4%></option>
  69. <option value="6"><%:IPv6%></option>
  70. </select>
  71. <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute, this.form.traceroute_proto.selectedIndex)" />
  72. <% else %>
  73. <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute)" />
  74. <% end %>
  75. <% if not has_traceroute6 then %>
  76. <p>&#160;</p>
  77. <p><%:Install iputils-traceroute6 for IPv6 traceroute%></p>
  78. <% end %>
  79. </div>
  80. <div style="width:33%; float:left;">
  81. <input style="margin: 5px 0" type="text" value="openwrt.org" name="nslookup" /><br />
  82. <input type="button" value="<%:Nslookup%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.nslookup)" />
  83. </div>
  84. <br style="clear:both" /><br />
  85. </fieldset>
  86. </div>
  87. <fieldset class="cbi-section" style="display:none">
  88. <legend id="diag-rc-legend"><%:Collecting data...%></legend>
  89. <span id="diag-rc-output"></span>
  90. </fieldset>
  91. </form>
  92. <%+footer%>