luci-base.patch 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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
  162. --- a/package/feeds/luci/luci-base/htdocs/luci-static/resources/tools/widgets.js
  163. +++ b/package/feeds/luci/luci-base/htdocs/luci-static/resources/tools/widgets.js
  164. @@ -4,6 +4,7 @@
  165. 'require network';
  166. 'require firewall';
  167. 'require fs';
  168. +'require uci';
  169. function getUsers() {
  170. return fs.lines('/etc/passwd').then(function(lines) {
  171. @@ -645,6 +646,83 @@ var CBIGroupSelect = form.ListValue.extend({
  172. },
  173. });
  174. +// how to name a ListValue class which contain domain and mac group
  175. +
  176. +var CBIWifidogxGroupSelect = form.ListValue.extend({
  177. + __name__: 'CBI.WifidogxGroupSelect',
  178. +
  179. + // group_type: 1: Domain Group, 2: MAC Group
  180. + // add a new property to store the group type
  181. + group_type: '1',
  182. +
  183. + load: function(section_id) {
  184. + this.sappList = [];
  185. + var sections = uci.sections('wifidogx', 'group');
  186. +
  187. + for (var i = 0; i < sections.length; i++) {
  188. + if (sections[i]['g_type'] == this.group_type)
  189. + this.sappList.push(sections[i]['.name']);
  190. + }
  191. +
  192. + return this.super('load', section_id);
  193. + },
  194. +
  195. + setGroupType: function(group_type) {
  196. + if (group_type == 'mac') {
  197. + this.group_type = '2';
  198. + } else if (group_type == 'wildcard') {
  199. + this.group_type = '3';
  200. + }
  201. + },
  202. +
  203. + filter: function(section_id, value) {
  204. + return true;
  205. + },
  206. +
  207. + renderWidget: function(section_id, option_index, cfgvalue) {
  208. + var values = L.toArray((cfgvalue != null) ? cfgvalue : this.default),
  209. + choices = {},
  210. + checked = {};
  211. +
  212. + for (var i = 0; i < values.length; i++)
  213. + checked[values[i]] = true;
  214. +
  215. + values = [];
  216. +
  217. + if (!this.multiple && (this.rmempty || this.optional))
  218. + choices[''] = E('em', _('unspecified'));
  219. +
  220. + for (var i = 0; i < this.sappList.length; i++) {
  221. + var name = this.sappList[i];
  222. +
  223. + if (checked[name])
  224. + values.push(name);
  225. +
  226. + choices[name] = E('span', { 'class': 'ifacebadge' }, name);
  227. + }
  228. +
  229. + var widget = new ui.Dropdown(this.multiple ? values : values[0], choices, {
  230. + id: this.cbid(section_id),
  231. + sort: true,
  232. + multiple: this.multiple,
  233. + optional: this.optional || this.rmempty,
  234. + disabled: (this.readonly != null) ? this.readonly : this.map.readonly,
  235. + select_placeholder: E('em', _('unspecified')),
  236. + display_items: this.display_size || this.size || 3,
  237. + dropdown_items: this.dropdown_size || this.size || 5,
  238. + validate: L.bind(this.validate, this, section_id),
  239. + create: !this.nocreate,
  240. + create_markup: '' +
  241. + '<li data-value="{{value}}">' +
  242. + '<span class="ifacebadge" style="background:repeating-linear-gradient(45deg,rgba(204,204,204,0.5),rgba(204,204,204,0.5) 5px,rgba(255,255,255,0.5) 5px,rgba(255,255,255,0.5) 10px)">' +
  243. + '{{value}}: <em>('+_('create')+')</em>' +
  244. + '</span>' +
  245. + '</li>'
  246. + });
  247. +
  248. + return widget.render();
  249. + }
  250. +});
  251. return L.Class.extend({
  252. ZoneSelect: CBIZoneSelect,
  253. @@ -653,4 +731,5 @@ return L.Class.extend({
  254. DeviceSelect: CBIDeviceSelect,
  255. UserSelect: CBIUserSelect,
  256. GroupSelect: CBIGroupSelect,
  257. + WifidogxGroupSelect: CBIWifidogxGroupSelect,
  258. });
  259. --- a/package/feeds/luci/luci-base/htdocs/luci-static/resources/validation.js
  260. +++ b/package/feeds/luci/luci-base/htdocs/luci-static/resources/validation.js
  261. @@ -403,6 +403,14 @@ const ValidatorFactory = baseclass.extend({
  262. return this.assert(false, _('valid hostname'));
  263. },
  264. + wildcard() {
  265. + // must start with '.', then remove it and check if it's a valid hostname
  266. + if (this.value[0] != '.')
  267. + return this.assert(false, _('valid wildcard hostname'));
  268. + const hostname = this.value.substr(1);
  269. + return this.apply('hostname', hostname);
  270. + },
  271. +
  272. network() {
  273. return this.assert(this.apply('uciname') || this.apply('hostname') || this.apply('ip4addr') || this.apply('ip6addr'),
  274. _('valid UCI identifier, hostname or IP address range'));
  275. --- a/package/feeds/luci/luci-base/root/usr/share/luci/menu.d/luci-base.json
  276. +++ b/package/feeds/luci/luci-base/root/usr/share/luci/menu.d/luci-base.json
  277. @@ -50,6 +50,24 @@
  278. }
  279. },
  280. + "admin/nas": {
  281. + "title": "NAS",
  282. + "order": 60,
  283. + "action": {
  284. + "type": "firstchild",
  285. + "recurse": true
  286. + }
  287. + },
  288. +
  289. + "admin/control": {
  290. + "title": "Control",
  291. + "order": 61,
  292. + "action": {
  293. + "type": "firstchild",
  294. + "recurse": true
  295. + }
  296. + },
  297. +
  298. "admin/vpn": {
  299. "title": "VPN",
  300. "order": 70,