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