1
0

diagnostics.htm 3.8 KB

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