diff --git a/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/service.js b/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/service.js index e6a5300..111cb24 100644 --- a/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/service.js +++ b/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/service.js @@ -244,8 +244,18 @@ return view.extend({ ' ', _('Set AutoHostList mode') ]); + let erase_autohostlist = E('label', [ + E('input', { type: 'checkbox', id: 'cfg_erase_autohostlist' }), + ' ', _('Erase AutoHostList (ipset)') + ]); + + let enable_custom_d = E('label', [ + E('input', { type: 'checkbox', id: 'cfg_enable_custom_d' }), + ' ', _('Enable use custom.d scripts') + ]); + let strat_list = [ ]; - strat_list.push( E('option', { value: 'strat__skip__' }, [ '-' ] ) ); + strat_list.push( E('option', { value: 'strat__skip__' }, [ 'not change' ] ) ); for (let id = 0; id < this.nfqws_strat_list.length; id++) { let strat = '' + this.nfqws_strat_list[id]; strat_list.push( E('option', { value: 'strat_' + id }, [ strat ] ) ); @@ -276,10 +286,19 @@ return view.extend({ if (document.getElementById('cfg_autohostlist').checked) { opt_flags += '(set_mode_autohostlist)'; }; + if (document.getElementById('cfg_erase_autohostlist').checked) { + opt_flags += '(erase_autohostlist)'; + }; + if (document.getElementById('cfg_enable_custom_d').checked) { + opt_flags += '(enable_custom_d)'; + }; //console.log('RESET: opt_flags = ' + opt_flags); let sel_strat = document.getElementById('cfg_nfqws_strat'); let opt_strat = sel_strat.options[sel_strat.selectedIndex].text; //console.log('RESET: strat = ' + opt_strat); + if (opt_strat == 'not change') { + opt_strat = '-'; + } opt_flags += '(sync)'; let args = [ opt_flags, opt_strat ]; return this.serviceActionEx('reset', resetcfg_btn, args, true); @@ -293,6 +312,10 @@ return view.extend({ E('br'), E('br'), set_autohostlist, E('br'), E('br'), + erase_autohostlist, + E('br'), E('br'), + enable_custom_d, + E('br'), E('br'), nfqws_strat, E('br'), E('br') ]), diff --git a/zapret2/def-cfg.sh b/zapret2/def-cfg.sh index 0fb7c7a..643464e 100755 --- a/zapret2/def-cfg.sh +++ b/zapret2/def-cfg.sh @@ -181,5 +181,17 @@ function set_cfg_default_values commit $cfgname EOF fi + if echo "$opt_flags" | grep -q "(enable_custom_d)"; then + uci batch <<-EOF + set $cfgname.config.DISABLE_CUSTOM='0' + commit $cfgname + EOF + fi + if echo "$opt_flags" | grep -q "(disable_custom_d)"; then + uci batch <<-EOF + set $cfgname.config.DISABLE_CUSTOM='1' + commit $cfgname + EOF + fi return 0 } diff --git a/zapret2/restore-def-cfg.sh b/zapret2/restore-def-cfg.sh index 6c0545b..d406f38 100755 --- a/zapret2/restore-def-cfg.sh +++ b/zapret2/restore-def-cfg.sh @@ -13,6 +13,11 @@ opt_strat=$2 if echo "$opt_flags" | grep -q "(reset_ipset)"; then restore_all_ipset_cfg fi + +if echo "$opt_flags" | grep -q "(erase_autohostlist)"; then + : > $ZAPRET_BASE/ipset/zapret-hosts-auto.txt + : > $ZAPRET_BASE/ipset/zapret-hosts-auto-debug.log +fi create_default_cfg "$opt_flags" "$opt_strat"