1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add labels for shadowsocks and allow multiples rules in interface

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-06-26 14:58:04 +02:00
parent 5de56cb576
commit 75f2277fbd
3 changed files with 111 additions and 77 deletions

View file

@ -138,6 +138,8 @@ return L.Class.extend({
};
}
o = optfunc(form.Value, 'label', _('Label'));
o = optfunc(form.Value, 'server', _('Server'));
o.datatype = 'host';
o.size = 16;

View file

@ -74,6 +74,7 @@ return L.view.extend({
]).then(L.bind(function(res) {
s.tab('general', _('General Settings'));
s.tab('advanced', _('Advanced Settings'));
s.taboption('general', form.Value, 'label', _('Label'));
s.taboption('general', form.Flag, 'disabled', _('Disable'));
if (!res[0]) {
ss.option_install_package(s, 'general');

View file

@ -6,6 +6,7 @@
'require shadowsocks-libev as ss';
var conf = 'shadowsocks-libev';
var cfgtypes = ['ss_rules'];
function src_dst_option(s /*, ... */) {
var o = s.taboption.apply(s, L.varargs(arguments, 1));
@ -37,87 +38,117 @@ return L.view.extend({
If the prior check results in action <em>checkdst</em>, packets will continue \
to have their dst addresses checked.'));
s = m.section(form.NamedSection, 'ss_rules', 'ss_rules');
s.tab('general', _('General Settings'));
s.tab('src', _('Source Settings'));
s.tab('dst', _('Destination Settings'));
s = m.section(form.GridSection);
s.addremove = true;
s.cfgsections = function() {
return this.map.data.sections(this.map.config)
.filter(function(s) { return cfgtypes.indexOf(s['.type']) !== -1; })
.map(function(s) { return s['.name']; });
};
s.taboption('general', form.Flag, 'disabled', _('Disable'));
if (!stats[1]) {
ss.option_install_package(s, 'general');
}
s.addModalOptions = function(s, section_id, ev) {
s.sectiontype = 'ss_rules';
s.tab('general', _('General Settings'));
s.tab('src', _('Source Settings'));
s.tab('dst', _('Destination Settings'));
o = s.taboption('general', form.ListValue, 'redir_tcp',
_('ss-redir for TCP'));
ss.values_redir(o, 'tcp');
o = s.taboption('general', form.ListValue, 'redir_udp',
_('ss-redir for UDP'));
ss.values_redir(o, 'udp');
o = s.taboption('general', form.ListValue, 'local_default',
_('Local-out default'),
_('Default action for locally generated TCP packets'));
ss.values_actions(o);
o = s.taboption('general', widgets.DeviceSelect, 'ifnames',
_('Ingress interfaces'),
_('Only apply rules on packets from these network interfaces'));
o.multiple = true;
o.noaliases = true;
o.noinactive = true;
s.taboption('general', form.Value, 'ipt_args',
_('Extra arguments'),
_('Passes additional arguments to iptables. Use with care!'));
src_dst_option(s, 'src', form.DynamicList, 'src_ips_bypass',
_('Src ip/net bypass'),
_('Bypass ss-redir for packets with src address in this list'));
src_dst_option(s, 'src', form.DynamicList, 'src_ips_forward',
_('Src ip/net forward'),
_('Forward through ss-redir for packets with src address in this list'));
src_dst_option(s, 'src', form.DynamicList, 'src_ips_checkdst',
_('Src ip/net checkdst'),
_('Continue to have dst address checked for packets with src address in this list'));
o = s.taboption('src', form.ListValue, 'src_default',
_('Src default'),
_('Default action for packets whose src address do not match any of the src ip/net list'));
ss.values_actions(o);
src_dst_option(s, 'dst', form.DynamicList, 'dst_ips_bypass',
_('Dst ip/net bypass'),
_('Bypass ss-redir for packets with dst address in this list'));
src_dst_option(s, 'dst', form.DynamicList, 'dst_ips_forward',
_('Dst ip/net forward'),
_('Forward through ss-redir for packets with dst address in this list'));
var dir = '/etc/shadowsocks-libev';
o = s.taboption('dst', form.FileUpload, 'dst_ips_bypass_file',
_('Dst ip/net bypass file'),
_('File containing ip/net for the purposes as with <em>Dst ip/net bypass</em>'));
o.root_directory = dir;
o = s.taboption('dst', form.FileUpload, 'dst_ips_forward_file',
_('Dst ip/net forward file'),
_('File containing ip/net for the purposes as with <em>Dst ip/net forward</em>'));
o.root_directory = dir;
o = s.taboption('dst', form.ListValue, 'dst_default',
_('Dst default'),
_('Default action for packets whose dst address do not match any of the dst ip list'));
ss.values_actions(o);
if (stats[0].type === 'file') {
o = s.taboption('dst', form.Flag, 'dst_forward_recentrst');
} else {
uci.set(conf, 'ss_rules', 'dst_forward_recentrst', '0');
o = s.taboption('dst', form.Button, '_install');
o.inputtitle = _('Install package iptables-mod-conntrack-extra');
o.inputstyle = 'apply';
o.onclick = function() {
window.open(L.url('admin/system/opkg') +
'?query=iptables-mod-conntrack-extra', '_blank', 'noopener');
s.taboption('general', form.Flag, 'disabled', _('Disable'));
if (!stats[1]) {
ss.option_install_package(s, 'general');
}
}
o.title = _('Forward recentrst');
o.description = _('Forward those packets whose dst have recently sent to us multiple tcp-rst');
o = s.taboption('general', form.Value, 'label', _('Label'));
//o = s.taboption('general', form.ListValue, 'server', _('server'));
//ss.values_serverlist(o, '');
o = s.taboption('general', form.ListValue, 'redir_tcp',
_('ss-redir for TCP'));
ss.values_redir(o, 'tcp');
o = s.taboption('general', form.ListValue, 'redir_udp',
_('ss-redir for UDP'));
ss.values_redir(o, 'udp');
o = s.taboption('general', form.ListValue, 'local_default',
_('Local-out default'),
_('Default action for locally generated TCP packets'));
ss.values_actions(o);
o = s.taboption('general', widgets.DeviceSelect, 'ifnames',
_('Ingress interfaces'),
_('Only apply rules on packets from these network interfaces'));
o.multiple = true;
o.noaliases = true;
o.noinactive = true;
s.taboption('general', form.Value, 'ipt_args',
_('Extra arguments'),
_('Passes additional arguments to iptables. Use with care!'));
src_dst_option(s, 'src', form.DynamicList, 'src_ips_bypass',
_('Src ip/net bypass'),
_('Bypass ss-redir for packets with src address in this list'));
src_dst_option(s, 'src', form.DynamicList, 'src_ips_forward',
_('Src ip/net forward'),
_('Forward through ss-redir for packets with src address in this list'));
src_dst_option(s, 'src', form.DynamicList, 'src_ips_checkdst',
_('Src ip/net checkdst'),
_('Continue to have dst address checked for packets with src address in this list'));
o = s.taboption('src', form.ListValue, 'src_default',
_('Src default'),
_('Default action for packets whose src address do not match any of the src ip/net list'));
ss.values_actions(o);
src_dst_option(s, 'dst', form.DynamicList, 'dst_ips_bypass',
_('Dst ip/net bypass'),
_('Bypass ss-redir for packets with dst address in this list'));
src_dst_option(s, 'dst', form.DynamicList, 'dst_ips_forward',
_('Dst ip/net forward'),
_('Forward through ss-redir for packets with dst address in this list'));
var dir = '/etc/shadowsocks-libev';
o = s.taboption('dst', form.FileUpload, 'dst_ips_bypass_file',
_('Dst ip/net bypass file'),
_('File containing ip/net for the purposes as with <em>Dst ip/net bypass</em>'));
o.root_directory = dir;
o = s.taboption('dst', form.FileUpload, 'dst_ips_forward_file',
_('Dst ip/net forward file'),
_('File containing ip/net for the purposes as with <em>Dst ip/net forward</em>'));
o.root_directory = dir;
o = s.taboption('dst', form.ListValue, 'dst_default',
_('Dst default'),
_('Default action for packets whose dst address do not match any of the dst ip list'));
ss.values_actions(o);
if (stats[0].type === 'file') {
o = s.taboption('dst', form.Flag, 'dst_forward_recentrst');
} else {
uci.set(conf, 'ss_rules', 'dst_forward_recentrst', '0');
o = s.taboption('dst', form.Button, '_install');
o.inputtitle = _('Install package iptables-mod-conntrack-extra');
o.inputstyle = 'apply';
o.onclick = function() {
window.open(L.url('admin/system/opkg') +
'?query=iptables-mod-conntrack-extra', '_blank', 'noopener');
}
}
o.title = _('Forward recentrst');
o.description = _('Forward those packets whose dst have recently sent to us multiple tcp-rst');
};
o = s.option(form.Button, 'disabled', _('Enable/Disable'));
o.modalonly = false;
o.editable = true;
o.inputtitle = function(section_id) {
var s = uci.get(conf, section_id);
if (ss.ucival_to_bool(s['disabled'])) {
this.inputstyle = 'reset';
return _('Disabled');
}
this.inputstyle = 'save';
return _('Enabled');
}
o.onclick = function(ev) {
var inputEl = ev.target.parentElement.nextElementSibling;
inputEl.value = ss.ucival_to_bool(inputEl.value) ? '0' : '1';
return this.map.save();
}
return m.render();
},
});