mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2026-01-02 06:38:53 +03:00
@@ -11,7 +11,7 @@ return view.extend({
|
||||
retrieveLog: async function() {
|
||||
return Promise.all([
|
||||
L.resolveDefault(fs.stat('/bin/cat'), null),
|
||||
fs.exec('/usr/bin/find', [ '/tmp', '-maxdepth', '1', '-type', 'f', '-name', 'zapret+*.log' ]),
|
||||
fs.exec('/usr/bin/find', [ '/tmp', '-maxdepth', '1', '-type', 'f', '-name', 'zapret2+*.log' ]),
|
||||
uci.load(tools.appName),
|
||||
]).then(function(status_array) {
|
||||
var filereader = status_array[0] ? status_array[0].path : null;
|
||||
@@ -130,7 +130,7 @@ return view.extend({
|
||||
return;
|
||||
}
|
||||
var h2 = E('div', {'class' : 'cbi-title-section'}, [
|
||||
E('h2', {'class': 'cbi-title-field'}, [ _('Zapret') + ' - ' + _('Log Viewer') ]),
|
||||
E('h2', {'class': 'cbi-title-field'}, [ _('Zapret2') + ' - ' + _('Log Viewer') ]),
|
||||
]);
|
||||
|
||||
var tabs = E('div', {}, E('div'));
|
||||
@@ -140,7 +140,7 @@ return view.extend({
|
||||
var logfn = logdata[log_num].filename;
|
||||
let filename = logfn.replace(/.*\//, '');
|
||||
let fname = filename.split('.')[0];
|
||||
fname = fname.replace(/^(zapret\+)/, '');
|
||||
fname = fname.replace(/^(zapret2\+)/, '');
|
||||
let fn = fname.split('+');
|
||||
|
||||
let tabNameText = fname.replace(/\+/g, ' ');
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
'require uci';
|
||||
'require ui';
|
||||
'require view';
|
||||
'require view.zapret.tools as tools';
|
||||
'require view.zapret.updater as updater';
|
||||
'require view.zapret2.tools as tools';
|
||||
'require view.zapret2.updater as updater';
|
||||
|
||||
const btn_style_neutral = 'btn';
|
||||
const btn_style_action = 'btn cbi-button-action';
|
||||
@@ -55,7 +55,7 @@ return view.extend({
|
||||
]).catch(e => {
|
||||
ui.addNotification(null, E('p', _('Unable to execute or read contents')
|
||||
+ ': %s [ %s | %s | %s ]'.format(
|
||||
e.message, tools.execPath, 'tools.getInitState', 'uci.zapret'
|
||||
e.message, tools.execPath, 'tools.getInitState', 'uci.zapret2'
|
||||
)));
|
||||
});
|
||||
},
|
||||
@@ -249,8 +249,8 @@ return view.extend({
|
||||
strat_list.push( E('option', { value: 'strat_' + id }, [ strat ] ) );
|
||||
}
|
||||
let nfqws_strat = E('label', [
|
||||
_('NFQWS_OPT strategy: '),
|
||||
E('select', { id: 'cfg_nfqws_strat' }, strat_list)
|
||||
_('NFQWS2_OPT strategy: '),
|
||||
E('select', { id: 'cfg_nfqws2_strat' }, strat_list)
|
||||
]);
|
||||
|
||||
let cancel_button = E('button', {
|
||||
@@ -274,7 +274,7 @@ return view.extend({
|
||||
opt_flags += '(set_mode_autohostlist)';
|
||||
};
|
||||
//console.log('RESET: opt_flags = ' + opt_flags);
|
||||
let sel_strat = document.getElementById('cfg_nfqws_strat');
|
||||
let sel_strat = document.getElementById('cfg_nfqws2_strat');
|
||||
let opt_strat = sel_strat.options[sel_strat.selectedIndex].text;
|
||||
//console.log('RESET: strat = ' + opt_strat);
|
||||
opt_flags += '(sync)';
|
||||
@@ -399,23 +399,23 @@ return view.extend({
|
||||
|
||||
poll.add(L.bind(this.statusPoll, this));
|
||||
|
||||
let page_title = _('Zapret');
|
||||
let page_title = _('Zapret2');
|
||||
let pkgdict = tools.decode_pkg_list(pkg_list.stdout, false);
|
||||
page_title += '   ';
|
||||
if (pkgdict['zapret'] === undefined || pkgdict['zapret'] == '') {
|
||||
if (pkgdict['zapret2'] === undefined || pkgdict['zapret2'] == '') {
|
||||
page_title += 'unknown version';
|
||||
} else {
|
||||
page_title += 'v' + pkgdict['zapret'];
|
||||
page_title += 'v' + pkgdict['zapret2'];
|
||||
}
|
||||
let aux1 = E('em');
|
||||
let aux2 = E('em');
|
||||
if (pkgdict['zapret'] != pkgdict['luci-app-zapret']) {
|
||||
let errtxt = 'LuCI APP v' + pkgdict['luci-app-zapret'] + ' [ incorrect version! ]';
|
||||
if (pkgdict['zapret2'] != pkgdict['luci-app-zapret2']) {
|
||||
let errtxt = 'LuCI APP v' + pkgdict['luci-app-zapret2'] + ' [ incorrect version! ]';
|
||||
aux1 = E('div', { 'class': 'label-status error' }, errtxt);
|
||||
aux2 = E('div', { }, ' ');
|
||||
}
|
||||
|
||||
let url1 = 'https://github.com/bol-van/zapret';
|
||||
let url1 = 'https://github.com/bol-van/zapret2';
|
||||
let url2 = 'https://github.com/remittor/zapret-openwrt';
|
||||
|
||||
return E([
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'require uci';
|
||||
'require ui';
|
||||
'require view';
|
||||
'require view.zapret.tools as tools';
|
||||
'require view.zapret2.tools as tools';
|
||||
|
||||
return view.extend({
|
||||
parsers: { },
|
||||
@@ -48,7 +48,7 @@ return view.extend({
|
||||
|
||||
let m, s, o, tabname;
|
||||
|
||||
m = new form.Map(tools.appName, _('Zapret') + ' - ' + _('Settings'));
|
||||
m = new form.Map(tools.appName, _('Zapret2') + ' - ' + _('Settings'));
|
||||
|
||||
s = m.section(form.NamedSection, 'config');
|
||||
s.anonymous = true;
|
||||
@@ -106,8 +106,8 @@ return view.extend({
|
||||
|
||||
/* NFQWS_OPT_DESYNC tab */
|
||||
|
||||
tabname = 'nfqws_params';
|
||||
s.tab(tabname, _('NFQWS options'));
|
||||
tabname = 'nfqws2_params';
|
||||
s.tab(tabname, _('NFQWS2 options'));
|
||||
|
||||
let add_delim = function(sec, url = null) {
|
||||
let o = sec.taboption(tabname, form.DummyValue, '_hr');
|
||||
@@ -154,7 +154,7 @@ return view.extend({
|
||||
btn.onclick = () => new tools.longstrEditDialog('config', param, param, desc, rows, multiline).show();
|
||||
};
|
||||
|
||||
o = s.taboption(tabname, form.Flag, 'NFQWS_ENABLE', _('NFQWS_ENABLE'));
|
||||
o = s.taboption(tabname, form.Flag, 'NFQWS2_ENABLE', _('NFQWS2_ENABLE'));
|
||||
o.rmempty = false;
|
||||
o.default = 1;
|
||||
|
||||
@@ -173,31 +173,31 @@ return view.extend({
|
||||
o.validate = function(section_id, value) { return true; };
|
||||
o.write = function(section_id, value) { return form.Value.prototype.write.call(this, section_id, (value == null || value.trim() == '') ? "\t" : value.trim()); };
|
||||
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS_PORTS_TCP', _('NFQWS_PORTS_TCP'));
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS2_PORTS_TCP', _('NFQWS2_PORTS_TCP'));
|
||||
o.rmempty = false;
|
||||
o.datatype = 'string';
|
||||
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS_PORTS_UDP', _('NFQWS_PORTS_UDP'));
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS2_PORTS_UDP', _('NFQWS2_PORTS_UDP'));
|
||||
o.rmempty = false;
|
||||
o.datatype = 'string';
|
||||
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS_TCP_PKT_OUT', _('NFQWS_TCP_PKT_OUT'));
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS2_TCP_PKT_OUT', _('NFQWS2_TCP_PKT_OUT'));
|
||||
o.rmempty = false;
|
||||
o.datatype = 'string';
|
||||
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS_TCP_PKT_IN', _('NFQWS_TCP_PKT_IN'));
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS2_TCP_PKT_IN', _('NFQWS2_TCP_PKT_IN'));
|
||||
o.rmempty = false;
|
||||
o.datatype = 'string';
|
||||
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS_UDP_PKT_OUT', _('NFQWS_UDP_PKT_OUT'));
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS2_UDP_PKT_OUT', _('NFQWS2_UDP_PKT_OUT'));
|
||||
o.rmempty = false;
|
||||
o.datatype = 'string';
|
||||
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS_UDP_PKT_IN', _('NFQWS_UDP_PKT_IN'));
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS2_UDP_PKT_IN', _('NFQWS2_UDP_PKT_IN'));
|
||||
o.rmempty = false;
|
||||
o.datatype = 'string';
|
||||
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS_PORTS_TCP_KEEPALIVE', _('NFQWS_PORTS_TCP_KEEPALIVE'));
|
||||
o = s.taboption(tabname, form.Value, 'NFQWS2_PORTS_TCP_KEEPALIVE', _('NFQWS2_PORTS_TCP_KEEPALIVE'));
|
||||
o.rmempty = false;
|
||||
o.datatype = 'uinteger';
|
||||
|
||||
@@ -206,7 +206,7 @@ return view.extend({
|
||||
o.datatype = 'uinteger';
|
||||
|
||||
add_delim(s, tools.nfqws_opt_url);
|
||||
add_param(s, 'NFQWS_OPT', null, 21, 2);
|
||||
add_param(s, 'NFQWS2_OPT', null, 21, 2);
|
||||
|
||||
/* AutoHostList settings */
|
||||
|
||||
|
||||
@@ -36,32 +36,31 @@ document.head.append(E('style', {'type': 'text/css'},
|
||||
|
||||
return baseclass.extend({
|
||||
packager : null,
|
||||
appName : 'zapret',
|
||||
execPath : '/etc/init.d/zapret',
|
||||
syncCfgPath : '/opt/zapret/sync_config.sh',
|
||||
defCfgPath : '/opt/zapret/def-cfg.sh',
|
||||
defaultCfgPath : '/opt/zapret/restore-def-cfg.sh',
|
||||
appName : 'zapret2',
|
||||
execPath : '/etc/init.d/zapret2',
|
||||
syncCfgPath : '/opt/zapret2/sync_config.sh',
|
||||
defCfgPath : '/opt/zapret2/def-cfg.sh',
|
||||
defaultCfgPath : '/opt/zapret2/restore-def-cfg.sh',
|
||||
|
||||
hostsGoogleFN : '/opt/zapret/ipset/zapret-hosts-google.txt',
|
||||
hostsUserFN : '/opt/zapret/ipset/zapret-hosts-user.txt',
|
||||
hostsUserExcludeFN: '/opt/zapret/ipset/zapret-hosts-user-exclude.txt',
|
||||
iplstExcludeFN : '/opt/zapret/ipset/zapret-ip-exclude.txt',
|
||||
iplstUserFN : '/opt/zapret/ipset/zapret-ip-user.txt',
|
||||
iplstUserExcludeFN: '/opt/zapret/ipset/zapret-ip-user-exclude.txt',
|
||||
hostsGoogleFN : '/opt/zapret2/ipset/zapret-hosts-google.txt',
|
||||
hostsUserFN : '/opt/zapret2/ipset/zapret-hosts-user.txt',
|
||||
hostsUserExcludeFN: '/opt/zapret2/ipset/zapret-hosts-user-exclude.txt',
|
||||
iplstExcludeFN : '/opt/zapret2/ipset/zapret-ip-exclude.txt',
|
||||
iplstUserFN : '/opt/zapret2/ipset/zapret-ip-user.txt',
|
||||
iplstUserExcludeFN: '/opt/zapret2/ipset/zapret-ip-user-exclude.txt',
|
||||
custFileMax : 4,
|
||||
custFileTemplate : '/opt/zapret/ipset/cust%s.txt',
|
||||
custFileTemplate : '/opt/zapret2/ipset/cust%s.txt',
|
||||
customdPrefixList : [ 10, 20, 50, 60, 90 ] ,
|
||||
customdFileFormat : '/opt/zapret/init.d/openwrt/custom.d/%s-script.sh',
|
||||
customdFileFormat : '/opt/zapret2/init.d/openwrt/custom.d/%s-script.sh',
|
||||
discord_num : 50,
|
||||
discord_url : [ 'https://github.com/bol-van/zapret/blob/4e8e3a9ed9dbeb1156db68dfaa7b353051c13797/init.d/custom.d.examples.linux/50-discord',
|
||||
'https://github.com/bol-van/zapret/blob/b251ea839cc8f04c45090314ef69fce69f2c00f2/init.d/custom.d.examples.linux/50-discord-media',
|
||||
'https://github.com/bol-van/zapret/blob/b251ea839cc8f04c45090314ef69fce69f2c00f2/init.d/custom.d.examples.linux/50-stun4all',
|
||||
'https://github.com/bol-van/zapret/tree/master/init.d/custom.d.examples.linux'
|
||||
discord_url : [ 'https://github.com/bol-van/zapret2/blob/master/init.d/custom.d.examples.linux/50-discord-media',
|
||||
'https://github.com/bol-van/zapret2/blob/master/init.d/custom.d.examples.linux/50-stun4all',
|
||||
'https://github.com/bol-van/zapret2/tree/master/init.d/custom.d.examples.linux'
|
||||
],
|
||||
nfqws_opt_url : 'https://github.com/remittor/zapret-openwrt/discussions/168',
|
||||
nfqws_opt_url : 'https://github.com/remittor/zapret-openwrt/discussions/',
|
||||
|
||||
autoHostListFN : '/opt/zapret/ipset/zapret-hosts-auto.txt',
|
||||
autoHostListDbgFN : '/opt/zapret/ipset/zapret-hosts-auto-debug.log',
|
||||
autoHostListFN : '/opt/zapret2/ipset/zapret-hosts-auto.txt',
|
||||
autoHostListDbgFN : '/opt/zapret2/ipset/zapret-hosts-auto-debug.log',
|
||||
|
||||
infoLabelRunning : '<span class="label-status running">' + _('Running') + '</span>',
|
||||
infoLabelStarting : '<span class="label-status starting">' + _('Starting') + '</span>',
|
||||
@@ -106,11 +105,11 @@ return baseclass.extend({
|
||||
if (L.hasSystemFeature('apk')) {
|
||||
this.packager.name = 'apk';
|
||||
this.packager.path = '/usr/bin/apk';
|
||||
this.packager.args = [ 'list', '-I', '*zapret*' ];
|
||||
this.packager.args = [ 'list', '-I', '*zapret2*' ];
|
||||
} else {
|
||||
this.packager.name = 'opkg';
|
||||
this.packager.path = '/bin/opkg';
|
||||
this.packager.args = [ 'list-installed', '*zapret*' ];
|
||||
this.packager.args = [ 'list-installed', '*zapret2*' ];
|
||||
}
|
||||
//console.log('PACKAGER: ' + this.packager.name);
|
||||
}
|
||||
@@ -271,9 +270,9 @@ return baseclass.extend({
|
||||
return -4;
|
||||
}
|
||||
let jdata = svc_info;
|
||||
if (typeof(jdata.zapret) == 'object') {
|
||||
if (typeof(jdata.zapret2) == 'object') {
|
||||
result.dmn.inited = true;
|
||||
let dmn_list = jdata.zapret.instances;
|
||||
let dmn_list = jdata.zapret2.instances;
|
||||
if (typeof(dmn_list) == 'object') {
|
||||
for (const [dmn_name, daemon] of Object.entries(dmn_list)) {
|
||||
result.dmn.total += 1;
|
||||
@@ -470,7 +469,7 @@ return baseclass.extend({
|
||||
},
|
||||
|
||||
load: function() {
|
||||
let value = uci.get('zapret', this.cfgsec, this.cfgparam);
|
||||
let value = uci.get('zapret2', this.cfgsec, this.cfgparam);
|
||||
if (typeof(value) === 'string') {
|
||||
value = value.trim();
|
||||
if (this.multiline == 2) {
|
||||
@@ -544,7 +543,7 @@ return baseclass.extend({
|
||||
}
|
||||
value = value.replace(/˂/g, '<');
|
||||
value = value.replace(/˃/g, '>');
|
||||
uci.set('zapret', this.cfgsec, this.cfgparam, value);
|
||||
uci.set('zapret2', this.cfgsec, this.cfgparam, value);
|
||||
uci.save();
|
||||
let elem = document.getElementById("cbi-zapret-" + this.cfgsec + "-_" + this.cfgparam);
|
||||
if (elem) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'require uci';
|
||||
'require ui';
|
||||
'require view';
|
||||
'require view.zapret.tools as tools';
|
||||
'require view.zapret2.tools as tools';
|
||||
|
||||
const btn_style_neutral = 'btn';
|
||||
const btn_style_action = 'btn cbi-button-action';
|
||||
@@ -14,7 +14,7 @@ const btn_style_negative = 'btn cbi-button-reset important';
|
||||
const btn_style_warning = 'btn cbi-button-negative';
|
||||
const btn_style_success = 'btn cbi-button-success important';
|
||||
|
||||
const fn_update_pkg_sh = '/opt/zapret/update-pkg.sh';
|
||||
const fn_update_pkg_sh = '/opt/zapret2/update-pkg.sh';
|
||||
|
||||
return baseclass.extend({
|
||||
releasesUrlPrefix : 'https://raw.githubusercontent.com/remittor/zapret-openwrt/gh-pages/releases/',
|
||||
@@ -104,7 +104,7 @@ return baseclass.extend({
|
||||
}
|
||||
let rpc_opt = { timeout: 5*1000 }
|
||||
//rpc_opt.uid = 0; // run under root
|
||||
const logFile = '/tmp/zapret_pkg_install.log';
|
||||
const logFile = '/tmp/zapret2_pkg_install.log';
|
||||
const rcFile = logFile + '.rc';
|
||||
try {
|
||||
await fs.exec('/bin/busybox', [ 'rm', '-f', logFile + '*' ], null, rpc_opt);
|
||||
@@ -118,7 +118,7 @@ return baseclass.extend({
|
||||
let opt = [ logFile, fn_update_pkg_sh ];
|
||||
//opt.push('-t'); opt.push('0'); // only for testing
|
||||
opt.push(...opt_list);
|
||||
let res = await fs.exec('/opt/zapret/script-exec.sh', opt, null, rpc_opt);
|
||||
let res = await fs.exec('/opt/zapret2/script-exec.sh', opt, null, rpc_opt);
|
||||
if (res.code == 0) {
|
||||
this.appendLog('Process started...');
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user