mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2026-01-30 22:30:36 +03:00
luci: Splitting file tools.js into two parts (add file env.js)
This commit is contained in:
@@ -0,0 +1,51 @@
|
|||||||
|
'use strict';
|
||||||
|
'require baseclass';
|
||||||
|
|
||||||
|
return baseclass.extend({
|
||||||
|
packager : { },
|
||||||
|
appName : 'zapret2',
|
||||||
|
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/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/zapret2/ipset/cust%s.txt',
|
||||||
|
customdPrefixList : [ 10, 20, 50, 60, 90 ] ,
|
||||||
|
customdFileFormat : '/opt/zapret2/init.d/openwrt/custom.d/%s-script.sh',
|
||||||
|
discord_num : 50,
|
||||||
|
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/',
|
||||||
|
|
||||||
|
autoHostListFN : '/opt/zapret2/ipset/zapret-hosts-auto.txt',
|
||||||
|
autoHostListDbgFN : '/opt/zapret2/ipset/zapret-hosts-auto-debug.log',
|
||||||
|
|
||||||
|
load_env: function(dst_obj) {
|
||||||
|
let env_proto = Object.getPrototypeOf(this);
|
||||||
|
Object.getOwnPropertyNames(env_proto).forEach(function(key) {
|
||||||
|
if (key === 'constructor' || key === 'load_env' || key.startsWith('__'))
|
||||||
|
return;
|
||||||
|
dst_obj[key] = env_proto[key];
|
||||||
|
});
|
||||||
|
dst_obj.packager = { };
|
||||||
|
if (L.hasSystemFeature('apk')) {
|
||||||
|
dst_obj.packager.name = 'apk';
|
||||||
|
dst_obj.packager.path = '/usr/bin/apk';
|
||||||
|
dst_obj.packager.args = [ 'list', '-I', '*'+this.appName+'*' ];
|
||||||
|
} else {
|
||||||
|
dst_obj.packager.name = 'opkg';
|
||||||
|
dst_obj.packager.path = '/bin/opkg';
|
||||||
|
dst_obj.packager.args = [ 'list-installed', '*'+this.appName+'*' ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
'require rpc';
|
'require rpc';
|
||||||
'require ui';
|
'require ui';
|
||||||
'require uci';
|
'require uci';
|
||||||
|
'require view.zapret2.env as env_tools';
|
||||||
|
|
||||||
document.head.append(E('style', {'type': 'text/css'},
|
document.head.append(E('style', {'type': 'text/css'},
|
||||||
`
|
`
|
||||||
@@ -35,32 +36,11 @@ document.head.append(E('style', {'type': 'text/css'},
|
|||||||
`));
|
`));
|
||||||
|
|
||||||
return baseclass.extend({
|
return baseclass.extend({
|
||||||
packager : null,
|
__init__() {
|
||||||
appName : 'zapret2',
|
env_tools.load_env(this);
|
||||||
execPath : '/etc/init.d/zapret2',
|
//console.log('appName: ' + this.appName);
|
||||||
syncCfgPath : '/opt/zapret2/sync_config.sh',
|
//console.log('PACKAGER: ' + this.packager.name);
|
||||||
defCfgPath : '/opt/zapret2/def-cfg.sh',
|
},
|
||||||
defaultCfgPath : '/opt/zapret2/restore-def-cfg.sh',
|
|
||||||
|
|
||||||
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/zapret2/ipset/cust%s.txt',
|
|
||||||
customdPrefixList : [ 10, 20, 50, 60, 90 ] ,
|
|
||||||
customdFileFormat : '/opt/zapret2/init.d/openwrt/custom.d/%s-script.sh',
|
|
||||||
discord_num : 50,
|
|
||||||
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/',
|
|
||||||
|
|
||||||
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>',
|
infoLabelRunning : '<span class="label-status running">' + _('Running') + '</span>',
|
||||||
infoLabelStarting : '<span class="label-status starting">' + _('Starting') + '</span>',
|
infoLabelStarting : '<span class="label-status starting">' + _('Starting') + '</span>',
|
||||||
@@ -99,24 +79,7 @@ return baseclass.extend({
|
|||||||
expect: { result: false }
|
expect: { result: false }
|
||||||
}),
|
}),
|
||||||
|
|
||||||
init_consts: function() {
|
|
||||||
if (!this.packager) {
|
|
||||||
this.packager = { };
|
|
||||||
if (L.hasSystemFeature('apk')) {
|
|
||||||
this.packager.name = 'apk';
|
|
||||||
this.packager.path = '/usr/bin/apk';
|
|
||||||
this.packager.args = [ 'list', '-I', '*zapret2*' ];
|
|
||||||
} else {
|
|
||||||
this.packager.name = 'opkg';
|
|
||||||
this.packager.path = '/bin/opkg';
|
|
||||||
this.packager.args = [ 'list-installed', '*zapret2*' ];
|
|
||||||
}
|
|
||||||
//console.log('PACKAGER: ' + this.packager.name);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getSvcInfo: function(svc_name = null) {
|
getSvcInfo: function(svc_name = null) {
|
||||||
this.init_consts();
|
|
||||||
let name = (svc_name) ? svc_name : this.appName;
|
let name = (svc_name) ? svc_name : this.appName;
|
||||||
let verbose = 1;
|
let verbose = 1;
|
||||||
return this.callServiceList(name, verbose).then(res => {
|
return this.callServiceList(name, verbose).then(res => {
|
||||||
@@ -127,7 +90,6 @@ return baseclass.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getInitState: function(name) {
|
getInitState: function(name) {
|
||||||
this.init_consts();
|
|
||||||
return this.callInitState(name).then(res => {
|
return this.callInitState(name).then(res => {
|
||||||
if (res) {
|
if (res) {
|
||||||
return res[name].enabled ? true : false;
|
return res[name].enabled ? true : false;
|
||||||
@@ -140,7 +102,6 @@ return baseclass.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getStratList: function() {
|
getStratList: function() {
|
||||||
this.init_consts();
|
|
||||||
let exec_cmd = '/bin/busybox';
|
let exec_cmd = '/bin/busybox';
|
||||||
let exec_arg = [ 'awk', '-F', '"', '/if \\[ "\\$strat" = "/ {print $4}', this.defCfgPath ];
|
let exec_arg = [ 'awk', '-F', '"', '/if \\[ "\\$strat" = "/ {print $4}', this.defCfgPath ];
|
||||||
return fs.exec(exec_cmd, exec_arg).then(res => {
|
return fs.exec(exec_cmd, exec_arg).then(res => {
|
||||||
|
|||||||
Reference in New Issue
Block a user