Skip to content

Commit

Permalink
feat: respect profile
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Mory <[email protected]>
  • Loading branch information
morytyann committed Mar 1, 2025
1 parent da32b51 commit 049ab0c
Show file tree
Hide file tree
Showing 8 changed files with 414 additions and 428 deletions.
19 changes: 5 additions & 14 deletions luci-app-nikki/htdocs/luci-static/resources/tools/nikki.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,8 @@ return baseclass.extend({
},

api: async function (method, path, query, body) {
const profile = await this.profile();
const apiListen = profile['external-controller'];
const apiSecret = profile['secret'] ?? '';
if (!apiListen) {
return Promise.reject();
}
const apiListen = uci.get('nikki', 'mixin', 'api_listen');
const apiSecret = uci.get('nikki', 'mixin', 'api_secret') ?? '';
const apiPort = apiListen.substring(apiListen.lastIndexOf(':') + 1);
const url = `http://${window.location.hostname}:${apiPort}${path}`;
return request.request(url, {
Expand All @@ -116,14 +112,9 @@ return baseclass.extend({
},

openDashboard: async function () {
const profile = await this.profile();
const ui = profile['external-ui'];
const uiName = profile['external-ui-name'];
const apiListen = profile['external-controller'];
const apiSecret = encodeURIComponent(profile['secret'] ?? '');
if (!ui || !apiListen) {
return Promise.reject();
}
const uiName = uci.get('nikki', 'mixin', 'ui_name');
const apiListen = uci.get('nikki', 'mixin', 'api_listen');
const apiSecret = encodeURIComponent(uci.get('nikki', 'mixin', 'api_secret') ?? '');
const apiPort = apiListen.substring(apiListen.lastIndexOf(':') + 1);
const params = {
host: window.location.hostname,
Expand Down
38 changes: 14 additions & 24 deletions luci-app-nikki/htdocs/luci-static/resources/view/nikki/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ return view.extend({

s.tab('external_control', _('External Control Config'));

o = s.taboption('external_control', form.Value, 'ui_path', _('UI Path'));
o = s.taboption('external_control', form.Value, 'ui_path', '*' + ' ' + _('UI Path'));
o.rmempty = false;

o = s.taboption('external_control', form.Value, 'ui_name', _('UI Name'));
Expand All @@ -79,8 +79,9 @@ return view.extend({
o.value('https://github.com/MetaCubeX/Yacd-meta/archive/refs/heads/gh-pages.zip', 'YACD');
o.value('https://github.com/MetaCubeX/Razord-meta/archive/refs/heads/gh-pages.zip', 'Razord');

o = s.taboption('external_control', form.Value, 'api_port', _('API Port'));
o.datatype = 'port';
o = s.taboption('external_control', form.Value, 'api_listen', '*' + ' ' + _('API Listen'));
o.datatype = 'ipaddrport(1)';
o.rmempty = false;

o = s.taboption('external_control', form.Value, 'api_secret', _('API Secret'));
o.password = true;
Expand All @@ -106,11 +107,11 @@ return view.extend({
o = s.taboption('inbound', form.Value, 'mixed_port', _('Mixed Port'));
o.datatype = 'port';

o = s.taboption('inbound', form.Value, 'redir_port', _('Redirect Port'));
o = s.taboption('inbound', form.Value, 'redir_port', '*' + ' ' + _('Redirect Port'));
o.datatype = 'port';
o.rmempty = false;

o = s.taboption('inbound', form.Value, 'tproxy_port', _('TPROXY Port'));
o = s.taboption('inbound', form.Value, 'tproxy_port', '*' + ' ' + _('TPROXY Port'));
o.datatype = 'port';
o.rmempty = false;

Expand All @@ -137,10 +138,11 @@ return view.extend({

s.tab('tun', _('TUN Config'));

o = s.taboption('tun', form.Value, 'tun_device', _('Device'));
o = s.taboption('tun', form.Value, 'tun_device', '*' + ' ' + _('Device Name'));
o.rmempty = false;

o = s.taboption('tun', form.ListValue, 'tun_stack', _('Stack'));
o.optional = true;
o.value('system', 'System');
o.value('gvisor', 'gVisor');
o.value('mixed', 'Mixed');
Expand All @@ -155,8 +157,6 @@ return view.extend({

o = s.taboption('tun', form.Value, 'tun_gso_max_size', _('GSO Max Size'));
o.datatype = 'uinteger';
o.retain = true;
o.depends('tun_gso', '1');

o = s.taboption('tun', form.ListValue, 'tun_endpoint_independent_nat', _('Endpoint Independent NAT'));
o.optional = true;
Expand All @@ -168,54 +168,47 @@ return view.extend({

o = s.taboption('tun', form.DynamicList, 'tun_dns_hijacks', _('Edit DNS Hijacks'));
o.retain = true;
o.rmempty = false;
o.depends('tun_dns_hijack', '1');
o.value('tcp://any:53');
o.value('udp://any:53');

s.tab('dns', _('DNS Config'));

o = s.taboption('dns', form.Value, 'dns_port', _('DNS Port'));
o.datatype = 'port';
o = s.taboption('dns', form.Value, 'dns_listen', '*' + ' ' + _('DNS Listen'));
o.datatype = 'ipaddrport(1)';
o.rmempty = false;

o = s.taboption('dns', form.ListValue, 'dns_ipv6', _('IPv6'));
o.optional = true;
o.value('0', _('Disable'));
o.value('1', _('Enable'));

o = s.taboption('dns', form.ListValue, 'dns_mode', _('DNS Mode'));
o = s.taboption('dns', form.ListValue, 'dns_mode', '*' + ' ' + _('DNS Mode'));
o.value('redir-host', 'Redir-Host');
o.value('fake-ip', 'Fake-IP');

o = s.taboption('dns', form.Value, 'fake_ip_range', _('Fake-IP Range'));
o = s.taboption('dns', form.Value, 'fake_ip_range', '*' + ' ' + _('Fake-IP Range'));
o.datatype = 'cidr4';
o.retain = true;
o.rmempty = false;
o.depends('dns_mode', 'fake-ip');

o = s.taboption('dns', form.Flag, 'fake_ip_filter', _('Overwrite Fake-IP Filter'));
o.retain = true;
o.rmempty = false;
o.depends('dns_mode', 'fake-ip');

o = s.taboption('dns', form.DynamicList, 'fake_ip_filters', _('Edit Fake-IP Filters'));
o.retain = true;
o.depends({ 'dns_mode': 'fake-ip', 'fake_ip_filter': '1' });
o.depends('fake_ip_filter', '1');

o = s.taboption('dns', form.ListValue, 'fake_ip_filter_mode', _('Fake-IP Filter Mode'));
o.optional = true;
o.retain = true;
o.value('blacklist', _('Block Mode'));
o.value('whitelist', _('Allow Mode'));
o.depends('dns_mode', 'fake-ip');

o = s.taboption('dns', form.ListValue, 'fake_ip_cache', _('Fake-IP Cache'));
o.optional = true;
o.retain = true;
o.value('0', _('Disable'));
o.value('1', _('Enable'));
o.depends('dns_mode', 'fake-ip');

o = s.taboption('dns', form.ListValue, 'dns_respect_rules', _('Respect Rules'));
o.optional = true;
Expand Down Expand Up @@ -439,8 +432,7 @@ return view.extend({
so.rmempty = false;

so = o.subsection.option(form.Value, 'type', _('Type'));
so.optional = true;
so.rmempty = true;
so.rmempty = false;
so.value('RULE-SET', _('Rule Set'));
so.value('DOMAIN', _('Domain Name'));
so.value('DOMAIN-SUFFIX', _('Domain Name Suffix'));
Expand Down Expand Up @@ -495,8 +487,6 @@ return view.extend({

o = s.taboption('geox', form.Value, 'geox_update_interval', _('GeoX Update Interval'));
o.datatype = 'uinteger';
o.retain = true;
o.depends('geox_auto_update', '1');

s.tab('mixin_file_content', _('Mixin File Content'));

Expand Down
Loading

0 comments on commit 049ab0c

Please sign in to comment.