Skip to content

Commit

Permalink
V1.11.0 (#296)
Browse files Browse the repository at this point in the history
* v1.11.0

1. add `interface` option in `access control` section
2. add `bypass_user` option in `bypass` section
3. add `bypass_group` option in `bypass` section
4. remove luci cache after luci app installed

* fix typo
  • Loading branch information
morytyann authored Nov 11, 2024
1 parent 99583b3 commit 5703949
Show file tree
Hide file tree
Showing 13 changed files with 480 additions and 328 deletions.
2 changes: 1 addition & 1 deletion luci-app-mihomo/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include $(TOPDIR)/rules.mk

PKG_VERSION:=1.10.0
PKG_VERSION:=1.11.0

LUCI_TITLE:=LuCI Support for mihomo
LUCI_DEPENDS:=+luci-base +mihomo
Expand Down
12 changes: 12 additions & 0 deletions luci-app-mihomo/htdocs/luci-static/resources/tools/mihomo.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,16 @@ return baseclass.extend({
alert(_('Service is not running.'));
}
},

getUsers: function () {
return fs.lines('/etc/passwd').then(function (lines) {
return lines.map(function (line) { return line.split(/:/)[0] }).filter(function (user) { return user !== 'root' && user !== 'mihomo' });
});
},

getGroups: function () {
return fs.lines('/etc/group').then(function (lines) {
return lines.map(function (line) { return line.split(/:/)[0] }).filter(function (group) { return group !== 'root' && group !== 'mihomo' });
});
},
})
44 changes: 36 additions & 8 deletions luci-app-mihomo/htdocs/luci-static/resources/view/mihomo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ return view.extend({
mihomo.appVersion(),
mihomo.coreVersion(),
mihomo.status(),
mihomo.getUsers(),
mihomo.getGroups(),
network.getHostHints(),
]);
},
Expand All @@ -38,7 +40,9 @@ return view.extend({
const appVersion = data[2];
const coreVersion = data[3];
const running = data[4];
const hosts = data[5].hosts;
const users = data[5];
const groups = data[6];
const hosts = data[7].hosts;

let m, s, o, so;

Expand Down Expand Up @@ -189,8 +193,8 @@ return view.extend({
for (const ip of host.ipaddrs) {
const hint = host.name || mac;
o.value(ip, hint ? '%s (%s)'.format(ip, hint) : ip);
}
}
};
};

o = s.taboption('access_control', form.DynamicList, 'acl_ip6', 'IP6');
o.datatype = 'ipmask6';
Expand All @@ -203,8 +207,8 @@ return view.extend({
for (const ip of host.ip6addrs) {
const hint = host.name || mac;
o.value(ip, hint ? '%s (%s)'.format(ip, hint) : ip);
}
}
};
};

o = s.taboption('access_control', form.DynamicList, 'acl_mac', 'MAC');
o.datatype = 'macaddr';
Expand All @@ -216,19 +220,40 @@ return view.extend({
const host = hosts[mac];
const hint = host.name || host.ipaddrs[0];
o.value(mac, hint ? '%s (%s)'.format(mac, hint) : mac);
}
};

o = s.taboption('access_control', widgets.NetworkSelect, 'acl_interface', _('Interface'));
o.multiple = true;
o.optional = true;
o.retain = true;
o.depends('access_control_mode', 'allow');
o.depends('access_control_mode', 'block');

s.tab('bypass', _('Bypass'));

o = s.taboption('bypass', form.MultiValue, 'bypass_user', _('Bypass User'));
o.create = true;

for (const user of users) {
o.value(user);
};

o = s.taboption('bypass', form.MultiValue, 'bypass_group', _('Bypass Group'));
o.create = true;

for (const group of groups) {
o.value(group);
};

o = s.taboption('bypass', form.Flag, 'bypass_china_mainland_ip', _('Bypass China Mainland IP'));
o.rmempty = false;

o = s.taboption('bypass', form.Value, 'acl_tcp_dport', _('Destination TCP Port to Proxy'));
o = s.taboption('bypass', form.Value, 'proxy_tcp_dport', _('Destination TCP Port to Proxy'));
o.rmempty = false;
o.value('0-65535', _('All Port'));
o.value('21 22 80 110 143 194 443 465 853 993 995 8080 8443', _('Commonly Used Port'));

o = s.taboption('bypass', form.Value, 'acl_udp_dport', _('Destination UDP Port to Proxy'));
o = s.taboption('bypass', form.Value, 'proxy_udp_dport', _('Destination UDP Port to Proxy'));
o.rmempty = false;
o.value('0-65535', _('All Port'));
o.value('123 443 8443', _('Commonly Used Port'));
Expand Down Expand Up @@ -316,6 +341,7 @@ return view.extend({
o.placeholder = '9090';

o = s.taboption('external_control', form.Value, 'api_secret', '*' + ' ' + _('API Secret'));
o.password = true;
o.rmempty = false;

o = s.taboption('external_control', form.Flag, 'selection_cache', _('Save Proxy Selection'));
Expand Down Expand Up @@ -364,6 +390,7 @@ return view.extend({
so.rmempty = false;

so = o.subsection.option(form.Value, 'password', _('Password'));
so.password = true;
so.rmempty = false;

s.tab('tun', _('TUN Config'));
Expand Down Expand Up @@ -536,6 +563,7 @@ return view.extend({
s.tab('mixin_file_content', _('Mixin File Content'));

o = s.taboption('mixin_file_content', form.Flag, 'mixin_file_content', '*' + ' ' + _('Enable'), _('Please go to the editor tab to edit the file for mixin'));
o.rmempty = false;

return m.render();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ return view.extend({

for (const profile of profiles) {
o.value(mihomo.profilesDir + '/' + profile.name, _('File:') + profile.name);
}
};

for (const subscription of subscriptions) {
o.value(mihomo.subscriptionsDir + '/' + subscription['.name'] + '.yaml', _('Subscription:') + subscription.name);
}
};

o.value(mihomo.mixinFilePath, _('File for Mixin'));
o.value(mihomo.runProfilePath, _('Profile for Startup'));
Expand Down
Loading

0 comments on commit 5703949

Please sign in to comment.