parent
24d2f10e7a
commit
8761690691
@ -28,6 +28,7 @@ const callNikkiVersion = rpc.declare({
|
||||
const callNikkiProfile = rpc.declare({
|
||||
object: 'luci.nikki',
|
||||
method: 'profile',
|
||||
params: [ 'defaults' ],
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
@ -98,8 +99,8 @@ return baseclass.extend({
|
||||
return callNikkiVersion();
|
||||
},
|
||||
|
||||
profile: function () {
|
||||
return callNikkiProfile();
|
||||
profile: function (defaults) {
|
||||
return callNikkiProfile(defaults);
|
||||
},
|
||||
|
||||
updateSubscription: function (section_id) {
|
||||
@ -107,7 +108,7 @@ return baseclass.extend({
|
||||
},
|
||||
|
||||
api: async function (method, path, query, body) {
|
||||
const profile = await callNikkiProfile();
|
||||
const profile = await callNikkiProfile({ 'external-controller': null, 'secret': null });
|
||||
const apiListen = profile['external-controller'];
|
||||
const apiSecret = profile['secret'] ?? '';
|
||||
const apiPort = apiListen.substring(apiListen.lastIndexOf(':') + 1);
|
||||
@ -121,7 +122,7 @@ return baseclass.extend({
|
||||
},
|
||||
|
||||
openDashboard: async function () {
|
||||
const profile = await callNikkiProfile();
|
||||
const profile = await callNikkiProfile({ 'external-ui-name': null, 'external-controller': null, 'secret': null });
|
||||
const uiName = profile['external-ui-name'];
|
||||
const apiListen = profile['external-controller'];
|
||||
const apiSecret = profile['secret'] ?? '';
|
||||
|
@ -67,6 +67,8 @@ return view.extend({
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.taboption('router', form.SectionValue, '_router_access_control', form.TableSection, 'router_access_control', _('Access Control'));
|
||||
o.retain = true;
|
||||
o.depends('router_proxy', '1');
|
||||
|
||||
o.subsection.addremove = true;
|
||||
o.subsection.anonymous = true;
|
||||
@ -102,7 +104,9 @@ return view.extend({
|
||||
o = s.taboption('lan', form.Flag, 'lan_proxy', _('Enable'));
|
||||
|
||||
o = s.taboption('lan', form.DynamicList, 'lan_inbound_interface', _('Inbound Interface'));
|
||||
o.retain = true;
|
||||
o.rmempty = false;
|
||||
o.depends('lan_proxy', '1');
|
||||
|
||||
for (const network of networks) {
|
||||
if (network.getName() === 'loopback') {
|
||||
@ -112,6 +116,8 @@ return view.extend({
|
||||
}
|
||||
|
||||
o = s.taboption('lan', form.SectionValue, '_lan_access_control', form.TableSection, 'lan_access_control', _('Access Control'));
|
||||
o.retain = true;
|
||||
o.depends('lan_proxy', '1');
|
||||
|
||||
o.subsection.addremove = true;
|
||||
o.subsection.anonymous = true;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { access, popen } from 'fs';
|
||||
import { access, popen, writefile } from 'fs';
|
||||
import { get_users, get_groups, get_cgroups } from '/etc/nikki/ucode/include.uc';
|
||||
|
||||
const methods = {
|
||||
@ -33,13 +33,18 @@ const methods = {
|
||||
}
|
||||
},
|
||||
profile: {
|
||||
call: function() {
|
||||
args: { defaults: {} },
|
||||
call: function(req) {
|
||||
let profile = {};
|
||||
const defaults = req.args?.defaults ?? {};
|
||||
const filepath = '/etc/nikki/run/config.yaml';
|
||||
const tmpFilepath = '/var/run/nikki/profile.json';
|
||||
if (access(filepath, 'r')) {
|
||||
const process = popen(`yq -p yaml -o json < ${filepath}`);
|
||||
writefile(tmpFilepath, defaults);
|
||||
const command = `yq -p yaml -o json eval-all 'select(fi == 0) *? select(fi == 1)' ${tmpFilepath} ${filepath}`;
|
||||
const process = popen(command);
|
||||
if (process) {
|
||||
profile = json(trim(process.read('all')));
|
||||
profile = json(process);
|
||||
process.close();
|
||||
}
|
||||
}
|
||||
@ -67,7 +72,7 @@ const methods = {
|
||||
},
|
||||
debug: {
|
||||
call: function() {
|
||||
const success = system('/etc/nikki/scripts/debug.sh > /var/log/nikki/debug.log 2>&1') == 0;
|
||||
const success = system('/etc/nikki/scripts/debug.sh > /var/log/nikki/debug.log') == 0;
|
||||
return { success: success };
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user