luci-base.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. --- a/package/feeds/luci/luci-base/root/usr/share/rpcd/ucode/luci
  2. +++ b/package/feeds/luci/luci-base/root/usr/share/rpcd/ucode/luci
  3. @@ -192,6 +192,7 @@ const methods = {
  4. getFeatures: {
  5. call: function() {
  6. + let kernel_version = popen('echo -n `uname -r`').read('all');
  7. let result = {
  8. firewall: access('/sbin/fw3') == true,
  9. firewall4: access('/sbin/fw4') == true,
  10. @@ -199,6 +200,7 @@ const methods = {
  11. bonding: access('/sys/module/bonding'),
  12. mii_tool: access('/usr/sbin/mii-tool'),
  13. offloading: access('/sys/module/xt_FLOWOFFLOAD/refcnt') == true || access('/sys/module/nft_flow_offload/refcnt') == true,
  14. + fullcone: access(`/lib/modules/${kernel_version}/xt_FULLCONENAT.ko`) == true || access(`/lib/modules/${kernel_version}/nft_fullcone.ko`) == true,
  15. br2684ctl: access('/usr/sbin/br2684ctl') == true,
  16. swconfig: access('/sbin/swconfig') == true,
  17. odhcpd: access('/usr/sbin/odhcpd') == true,
  18. @@ -538,6 +540,99 @@ const methods = {
  19. call: function() {
  20. return { result: process_list() };
  21. }
  22. + },
  23. +
  24. + getCPUBench: {
  25. + call: function() {
  26. + return { cpubench: readfile('/etc/bench.log') || '' };
  27. + }
  28. + },
  29. +
  30. + getCPUInfo: {
  31. + call: function() {
  32. + if (!access('/sbin/cpuinfo'))
  33. + return {};
  34. +
  35. + const fd = popen('/sbin/cpuinfo');
  36. + if (fd) {
  37. + let cpuinfo = fd.read('all');
  38. + fd.close();
  39. +
  40. + return { cpuinfo: cpuinfo };
  41. + } else {
  42. + return { cpuinfo: error() };
  43. + }
  44. + }
  45. + },
  46. +
  47. + getCPUUsage: {
  48. + call: function() {
  49. + const fd = popen('top -n1 | awk \'/^CPU/ {printf("%d%", 100 - $8)}\'');
  50. + if (fd) {
  51. + let cpuusage = fd.read('all');
  52. + fd.close();
  53. +
  54. + return { cpuusage: cpuusage };
  55. + } else {
  56. + return { cpuusage: error() };
  57. + }
  58. + }
  59. + },
  60. +
  61. + getETHInfo: {
  62. + call: function() {
  63. + if (!access('/sbin/ethinfo'))
  64. + return {};
  65. +
  66. + const fd = popen('/sbin/ethinfo');
  67. + if (fd) {
  68. + let ethinfo = fd.read('all');
  69. + if (!ethinfo)
  70. + ethinfo = '{}';
  71. + ethinfo = json(ethinfo);
  72. + fd.close();
  73. +
  74. + return { ethinfo: ethinfo };
  75. + } else {
  76. + return { ethinfo: error() };
  77. + }
  78. + }
  79. + },
  80. +
  81. + getTempInfo: {
  82. + call: function() {
  83. + if (!access('/sbin/tempinfo'))
  84. + return {};
  85. +
  86. + const fd = popen('/sbin/tempinfo');
  87. + if (fd) {
  88. + let tempinfo = fd.read('all');
  89. + fd.close();
  90. +
  91. + return { tempinfo: tempinfo };
  92. + } else {
  93. + return { tempinfo: error() };
  94. + }
  95. + }
  96. + },
  97. +
  98. + getOnlineUsers: {
  99. + call: function() {
  100. + const fd = open('/proc/net/arp', 'r');
  101. + if (fd) {
  102. + let onlineusers = 0;
  103. +
  104. + for (let line = fd.read('line'); length(line); line = fd.read('line'))
  105. + if (match(trim(line), /^.*(0x2).*(br-lan)$/))
  106. + onlineusers++;
  107. +
  108. + fd.close();
  109. +
  110. + return { onlineusers: onlineusers };
  111. + } else {
  112. + return { onlineusers: error() };
  113. + }
  114. + }
  115. }
  116. };
  117. --- a/package/feeds/luci/luci-base/htdocs/luci-static/resources/network.js
  118. +++ b/package/feeds/luci/luci-base/htdocs/luci-static/resources/network.js
  119. @@ -4376,4 +4376,10 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
  120. }
  121. });
  122. +setTimeout(function(){
  123. +try{
  124. + document.getElementsByClassName('cbi-button-apply')[0].children[3].children[0].value='1'
  125. +}catch(err) {
  126. +}},1000)
  127. +
  128. return Network;
  129. --- a/package/feeds/luci/luci-base/ucode/dispatcher.uc
  130. +++ b/package/feeds/luci/luci-base/ucode/dispatcher.uc
  131. @@ -939,7 +939,12 @@ dispatch = function(_http, path) {
  132. let cookie_name = (http.getenv('HTTPS') == 'on') ? 'sysauth_https' : 'sysauth_http',
  133. cookie_secure = (http.getenv('HTTPS') == 'on') ? '; secure' : '';
  134. - http.header('Set-Cookie', `${cookie_name}=${session.sid}; path=${build_url()}; SameSite=strict; HttpOnly${cookie_secure}`);
  135. + let cookie_p = uci.get('wizard', 'default', 'cookie_p');
  136. + if (cookie_p == '0') {
  137. + http.header('Set-Cookie', `${cookie_name}=${session.sid}; path=${build_url()}; SameSite=strict; HttpOnly${cookie_secure}`);
  138. + } else {
  139. + http.header('Set-Cookie', `${cookie_name}=${session.sid}; Max-Age=2147483647; path=${build_url()}; SameSite=strict; HttpOnly${cookie_secure}`);
  140. + }
  141. http.redirect(build_url(...resolved.ctx.request_path));
  142. return;
  143. --- a/package/feeds/luci/luci-base/root/www/index.html
  144. +++ b/package/feeds/luci/luci-base/root/www/index.html
  145. @@ -15,6 +15,5 @@
  146. </style>
  147. </head>
  148. <body>
  149. - <a href="cgi-bin/luci/">LuCI - Lua Configuration Interface</a>
  150. </body>
  151. </html>
  152. --- a/package/feeds/luci/luci-base/root/etc/init.d/ucitrack
  153. +++ b/package/feeds/luci/luci-base/root/etc/init.d/ucitrack
  154. @@ -8,7 +8,7 @@ register_init() {
  155. local init="$2"
  156. shift; shift
  157. - if [ -x "$init" ] && "$init" enabled && ! grep -sqE 'USE_PROCD=.' "$init"; then
  158. + if [ -x "$init" ] && ! grep -sqE 'USE_PROCD=.' "$init"; then
  159. logger -t "ucitrack" "Setting up /etc/config/$config reload trigger for non-procd $init"
  160. procd_add_config_trigger "config.change" "$config" "$init" "$@"
  161. fi