Compare commits

...

18 Commits

Author SHA1 Message Date
remittor
030b243bd6 Bump version to v65-20241023 2024-10-23 14:01:34 +03:00
remittor
f72a82bfe7 config: luci: Add options for overriding ports 2024-10-23 14:01:09 +03:00
remittor
ed09612065 luci: Fix show actual service status 2024-10-23 13:26:28 +03:00
remittor
144b9369b9 github: Change extension for out zip-files 2024-10-20 16:14:22 +03:00
remittor
79af08d99e readme: Add link to download page 2024-10-19 19:18:13 +03:00
Oleg S.
8d915f3e1d Create README.md 2024-10-19 14:33:39 +03:00
remittor
241a733eec Bump version to v65-20241018 2024-10-18 10:14:11 +03:00
remittor
6cfcaf2a03 luci: Fix path to main zapret script 2024-10-18 10:11:30 +03:00
remittor
2e58533b4e [install] Add detect for installed original zapret 2024-10-18 08:07:46 +03:00
remittor
6999144837 [install] Fix syntax 2024-10-18 08:06:08 +03:00
remittor
a6b89f3c2f [install] Remove empty custom files from ipset 2024-10-18 07:54:38 +03:00
remittor
facc4ac2bd Bump version to v65-20241016 2024-10-16 21:45:20 +03:00
remittor
8940c4bfa7 Add support for custom txt-configs
Example: /opt/zapret/ipset/cust1.txt
2024-10-16 21:45:20 +03:00
remittor
256c357554 Add other configs from original ipset directory 2024-10-16 21:45:20 +03:00
remittor
6c0c3498bd Add params DESYNC_MARK and DESYNC_MARK_POSTNAT 2024-10-16 21:45:20 +03:00
remittor
b28c89e569 Reformat type of parameters 2024-10-16 21:45:13 +03:00
remittor
0f6e981616 [install] Fix upgrade and remove main package 2024-10-16 10:34:29 +03:00
remittor
86310e3cf9 [install] Disable copy directory "docs" 2024-10-15 22:03:14 +03:00
14 changed files with 492 additions and 253 deletions

View File

@@ -209,7 +209,7 @@ jobs:
run: |
mkdir -p public
find . -name "ipk-openwrt-$BRANCH-*.tar" -exec tar -xvf {} --wildcards '*.ipk' \;
find $BRANCH -mindepth 1 -type d -exec sh -c 'zip -0 ./public/zapret_${TAG}_$(basename {}).ipk.zip -j {} {}/*' \;
find $BRANCH -mindepth 1 -type d -exec sh -c 'zip -0 ./public/zapret_${TAG}_$(basename {}).zip -j {} {}/*' \;
ls -lh ./public/*.zip
- name: Upload assets

6
README.md Normal file
View File

@@ -0,0 +1,6 @@
[![build](https://github.com/remittor/zapret-openwrt/actions/workflows/build.yml/badge.svg)](https://github.com/remittor/zapret-openwrt/actions/workflows/build.yml)
# zapret-openwrt
[Instructions for installing](https://github.com/remittor/zapret-openwrt/wiki/Installing-zapretopenwrt-package)
[Download page](https://github.com/remittor/zapret-openwrt/releases)

View File

@@ -5,8 +5,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-zapret
PKG_RELEASE:=20241014
PKG_VERSION:=64-$(PKG_RELEASE)
PKG_RELEASE:=20241023
PKG_VERSION:=65-$(PKG_RELEASE)
PKG_LICENSE:=MIT
LUCI_TITLE:=LuCI support for zapret

View File

@@ -14,111 +14,92 @@ const btn_style_warning = 'btn cbi-button-negative';
const btn_style_success = 'btn cbi-button-success important';
return view.extend({
disableButtons: function(flag, btn, elems = [ ]) {
let btn_start = elems[1] || document.getElementById("btn_start");
//let btn_destroy = elems[4] || document.getElementById("btn_destroy");
let btn_enable = elems[2] || document.getElementById("btn_enable");
let btn_update = elems[3] || document.getElementById("btn_update");
disableButtons: function(flag, btn, elems = { }) {
let btn_enable = elems.btn_enable || document.getElementById('btn_enable');
let btn_disable = elems.btn_disable || document.getElementById('btn_disable');
let btn_start = elems.btn_start || document.getElementById('btn_start');
let btn_restart = elems.btn_restart || document.getElementById('btn_restart');
let btn_stop = elems.btn_stop || document.getElementById('btn_stop');
let btn_update = elems.btn_update || document.getElementById('btn_update');
btn_enable.disabled = flag;
btn_disable.disabled = flag;
btn_start.disabled = flag;
btn_restart.disabled = flag;
btn_stop.disabled = flag;
btn_update.disabled = true; // TODO
//btn_destroy.disabled = flag;
if (btn === btn_update) {
btn_enable.disabled = false;
} else {
btn_enable.disabled = flag;
}
},
getAppStatus: function() {
return Promise.all([
{ code: -1 }, //fs.exec(tools.execPath, [ 'raw-status' ]),
{ code: -1 }, //fs.exec(tools.execPath, [ 'vpn-route-status' ]),
tools.getInitStatus(tools.appName),
//L.resolveDefault(fs.read(tools.tokenFile), 0),
uci.load(tools.appName),
tools.getInitState(tools.appName), // svc_state
fs.exec(tools.execPath, [ 'info' ]), // svc_info
fs.exec('/bin/ps'), // process list
uci.load(tools.appName), // config
]).catch(e => {
ui.addNotification(null, E('p', _('Unable to execute or read contents')
+ ': %s [ %s | %s | %s ]'.format(
e.message, tools.execPath, 'tools.getInitStatus', 'uci.zapret'
e.message, tools.execPath, 'tools.getInitState', 'uci.zapret'
)));
});
},
setAppStatus: function(status_array, elems = [ ], force_app_code = 0) {
let section = uci.get(tools.appName, 'config');
if (!status_array || section == null || typeof(section) !== 'object') {
(elems[0] || document.getElementById("status")).innerHTML = tools.makeStatusString(1);
setAppStatus: function(status_array, elems = { }, force_app_status = 0) {
let cfg = uci.get(tools.appName, 'config');
if (!status_array || cfg == null || typeof(cfg) !== 'object') {
let elem_status = elems.status || document.getElementById("status");
elem_status.innerHTML = tools.makeStatusString(null);
ui.addNotification(null, E('p', _('Unable to read the contents') + ': setAppStatus()'));
this.disableButtons(true, null, elems);
return;
}
let app_status_code = (force_app_code) ? force_app_code : status_array[0].code;
let vpn_route_status_code = status_array[1].code;
let enabled_flag = status_array[2];
let z_fwtype = section.FWTYPE;
let z_mode = section.MODE;
let bllist_preset = 'user_only';
let btn_enable = elems[2] || document.getElementById('btn_enable');
/*
if (enabled_flag == true) {
btn_enable.onclick = ui.createHandlerFn(this, this.serviceAction, 'disable', 'btn_enable');
btn_enable.textContent = _('Enabled');
btn_enable.className = btn_style_positive;
} else {
btn_enable.onclick = ui.createHandlerFn(this, this.serviceAction, 'enable', 'btn_enable');
btn_enable.textContent = _('Disabled');
btn_enable.className = btn_style_negative;
}
*/
let btn_start = elems[1] || document.getElementById('btn_start');
let btn_update = elems[3] || document.getElementById('btn_update');
//let btn_destroy = elems[4] || document.getElementById('btn_destroy');
let btnStartStateOn = () => {
//btn_start.onclick = ui.createHandlerFn(this, this.appAction, 'stop', 'btn_start');
//btn_start.textContent = _('Enabled');
//btn_start.className = btn_style_positive;
};
let btnStartStateOff = () => {
//btn_start.onclick = ui.createHandlerFn(this, this.appAction, 'start', 'btn_start');
//btn_start.textContent = _('Disabled');
//btn_start.className = btn_style_negative;
};
if (app_status_code == -1) {
this.disableButtons(false, null, elems);
btnStartStateOn();
}
else if (app_status_code == 0) {
this.disableButtons(false, null, elems);
btnStartStateOn();
//btn_destroy.disabled = false;
btn_update.disabled = false;
}
else if (app_status_code == 2) {
this.disableButtons(false, null, elems);
btnStartStateOff();
btn_update.disabled = true;
}
else if (app_status_code == 3) {
btnStartStateOff();
this.disableButtons(true, btn_start, elems);
}
else if (app_status_code == 4) {
btnStartStateOn();
this.disableButtons(true, btn_update, elems);
}
else {
ui.addNotification(null, E('p', _('Error')
+ ' %s: return code = %s'.format(tools.execPath, app_status_code)));
let svc_autorun = status_array[0] ? true : false;
let svc_info = status_array[1]; // stdout: JSON as text
let proc_list = status_array[2]; // stdout: multiline text
if (svc_info.code != 0) {
ui.addNotification(null, E('p', _('Unable to read the service info') + ': setAppStatus()'));
this.disableButtons(true, null, elems);
return;
}
if (proc_list.code != 0) {
ui.addNotification(null, E('p', _('Unable to read process list') + ': setAppStatus()'));
this.disableButtons(true, null, elems);
return;
}
let svcinfo;
if (force_app_status) {
svcinfo = force_app_status;
} else {
svcinfo = tools.decode_svc_info(svc_autorun, svc_info, proc_list, cfg);
}
let btn_enable = elems.btn_enable || document.getElementById('btn_enable');
let btn_disable = elems.btn_disable || document.getElementById('btn_disable');
(elems[0] || document.getElementById("status")).innerHTML = tools.makeStatusString(app_status_code, z_fwtype, bllist_preset);
let btn_start = elems.btn_start || document.getElementById('btn_start');
let btn_restart = elems.btn_restart || document.getElementById('btn_restart');
let btn_stop = elems.btn_stop || document.getElementById('btn_stop');
let btn_update = elems.btn_update || document.getElementById('btn_update');
btn_update.disabled = true; // TODO
if (Number.isInteger(svcinfo)) {
ui.addNotification(null, E('p', _('Error')
+ ' %s: return code = %s'.format('decode_svc_info', svcinfo + ' ')));
this.disableButtons(true, null, elems);
} else {
btn_enable.disabled = (svc_autorun) ? true : false;
btn_disable.disabled = (svc_autorun) ? false : true;
if (svcinfo.dmn.total == 0) {
btn_start.disabled = false;
btn_restart.disabled = true;
btn_stop.disabled = true;
} else {
btn_start.disabled = true;
btn_restart.disabled = false;
btn_stop.disabled = false;
}
}
let elem_status = elems.status || document.getElementById("status");
elem_status.innerHTML = tools.makeStatusString(svcinfo, cfg.FWTYPE, 'user_only');
if (!poll.active()) {
poll.start();
@@ -130,12 +111,33 @@ return view.extend({
let elem = document.getElementById(button);
this.disableButtons(true, elem);
}
poll.stop();
let _this = this;
return fs.exec('/opt/zapret/sync_config.sh')
return tools.handleServiceAction(tools.appName, action)
.then(() => {
return _this.getAppStatus().then(
(status_array) => {
_this.setAppStatus(status_array);
}
);
})
.catch(e => {
ui.addNotification(null, E('p', _('Unable to run service action.') + ' Error: ' + e.message));
});
},
serviceActionEx: function(action, button) {
if (button) {
let elem = document.getElementById(button);
this.disableButtons(true, elem);
}
poll.stop();
let _this = this;
return fs.exec(tools.syncCfgPath)
.then(function(res) {
if (res.code != 0) {
ui.addNotification(null, E('p', _('Unable to run sync_config.sh script.') + ' res.code = ' + res.code));
@@ -145,13 +147,7 @@ return view.extend({
}
);
}
return tools.handleServiceAction(tools.appName, action).then(() => {
return _this.getAppStatus().then(
(status_array) => {
_this.setAppStatus(status_array);
}
);
});
return _this.serviceAction(action, null);
})
.catch(e => {
ui.addNotification(null, E('p', _('Unable to run sync_config.sh script.') + ' Error: ' + e.message));
@@ -225,8 +221,7 @@ return view.extend({
if (!status_array) {
return;
}
let section = uci.get(tools.appName, 'config');
let cfg = uci.get(tools.appName, 'config');
let status_string = E('div', {
'id' : 'status',
@@ -236,15 +231,15 @@ return view.extend({
let layout = E('div', { 'class': 'cbi-section-node' });
function layout_append(title, descr, elem) {
function layout_append(title, descr, elems) {
descr = (descr) ? E('div', { 'class': 'cbi-value-description' }, descr) : '';
let elist;
if (elem instanceof E) {
elist = [ elem ];
} else {
elist = elem;
let elist = elems;
let elem_list = [ ];
for (let i = 0; i < elist.length; i++) {
elem_list.push(elist[i]);
elem_list.push(' ');
}
let vlist = [ E('div', {}, elist ) ];
let vlist = [ E('div', {}, elem_list ) ];
for (let i = 0; i < elist.length; i++) {
let input = E('input', {
'id' : elist[i].id + '_hidden',
@@ -252,9 +247,10 @@ return view.extend({
});
vlist.push(input);
}
let elem_name = (elist.length == 1) ? elist[0].id + '_hidden' : null;
layout.append(
E('div', { 'class': 'cbi-value' }, [
E('label', { 'class': 'cbi-value-title', 'for': elem.id + '_hidden' || null }, title),
E('label', { 'class': 'cbi-value-title', 'for': elem_name }, title),
E('div', { 'class': 'cbi-value-field' }, vlist),
])
);
@@ -272,26 +268,32 @@ return view.extend({
btn_enable.onclick = ui.createHandlerFn(this, this.serviceAction, 'enable', 'btn_enable');
let btn_disable = create_btn('btn_disable', btn_style_warning, _('Disable'));
btn_disable.onclick = ui.createHandlerFn(this, this.serviceAction, 'disable', 'btn_disable');
layout_append(_('Service Status'), null, [ btn_enable, btn_disable ] );
layout_append(_('Service autorun control'), null, [ btn_enable, btn_disable ] );
let btn_start = create_btn('btn_start', btn_style_action, _('Start'));
btn_start.onclick = ui.createHandlerFn(this, this.serviceAction, 'start', 'btn_start');
btn_start.onclick = ui.createHandlerFn(this, this.serviceActionEx, 'start', 'btn_start');
let btn_restart = create_btn('btn_restart', btn_style_action, _('Restart'));
btn_restart.onclick = ui.createHandlerFn(this, this.serviceAction, 'restart', 'btn_restart');
btn_restart.onclick = ui.createHandlerFn(this, this.serviceActionEx, 'restart', 'btn_restart');
let btn_stop = create_btn('btn_stop', btn_style_warning, _('Stop'));
btn_stop.onclick = ui.createHandlerFn(this, this.serviceAction, 'stop', 'btn_stop');
layout_append(_('Service Control'), null, [ btn_start, btn_restart, btn_stop ] );
layout_append(_('Service daemons control'), null, [ btn_start, btn_restart, btn_stop ] );
let btn_update = create_btn('btn_update', btn_style_action, _('Update'));
btn_update.onclick = ui.createHandlerFn(this, () => { this.appAction('update', 'btn_update') });
layout_append(_('Update blacklist'), null, btn_update);
layout_append(_('Update blacklist'), null, [ btn_update ] );
let btn_destroy = create_btn('btn_destroy', btn_style_negative, _('Shutdown'));
btn_destroy.onclick = L.bind(this.dialogDestroy, this);
//layout_append(_('Shutdown'), _('Complete service shutdown'), btn_destroy);
//let elems = [ status_string, btn_start, btn_enable, btn_update, btn_destroy ];
let elems = [ status_string, btn_start, btn_enable, btn_update ];
let elems = {
"status": status_string,
"btn_enable": btn_enable,
"btn_disable": btn_disable,
"btn_start": btn_start,
"btn_restart": btn_restart,
"btn_stop": btn_stop,
"btn_update": btn_update,
};
this.setAppStatus(status_array, elems);
poll.add(L.bind(this.statusPoll, this));
@@ -309,7 +311,6 @@ return view.extend({
),
E('div', { 'class': 'cbi-section fade-in' }, [
status_string,
E('hr'),
]),
E('div', { 'class': 'cbi-section fade-in' },
layout

View File

@@ -60,8 +60,8 @@ return view.extend({
s.tab(tabname, _('Main settings'));
o = s.taboption(tabname, form.ListValue, 'FWTYPE', _('FWTYPE'));
o.value('nftables', 'NFTables');
//o.value('iptables', 'IPTables');
o.value('nftables', 'nftables');
//o.value('iptables', 'iptables');
//o.value('ipfw', 'ipfw');
o = s.taboption(tabname, form.ListValue, 'MODE', _('MODE'));
@@ -74,17 +74,17 @@ return view.extend({
o.value('software', 'software');
o.value('hardware', 'hardware');
o = s.taboption(tabname, form.ListValue, 'INIT_APPLY_FW', _('INIT_APPLY_FW'));
o.value('0', 'False');
o.value('1', 'True');
o = s.taboption(tabname, form.Flag, 'INIT_APPLY_FW', _('INIT_APPLY_FW'));
o.rmempty = false;
o.default = 0;
o = s.taboption(tabname, form.ListValue, 'DISABLE_IPV4', _('DISABLE_IPV4'));
o.value('0', 'False');
o.value('1', 'True');
o = s.taboption(tabname, form.Flag, 'DISABLE_IPV4', _('DISABLE_IPV4'));
o.rmempty = false;
o.default = 1;
o = s.taboption(tabname, form.ListValue, 'DISABLE_IPV6', _('DISABLE_IPV6'));
o.value('0', 'False');
o.value('1', 'True');
o = s.taboption(tabname, form.Flag, 'DISABLE_IPV6', _('DISABLE_IPV6'));
o.rmempty = false;
o.default = 0;
o = s.taboption(tabname, form.ListValue, 'MODE_FILTER', _('MODE_FILTER'));
//o.value('none', 'none');
@@ -92,21 +92,43 @@ return view.extend({
o.value('hostlist', 'hostlist');
o.value('autohostlist', 'autohostlist');
o = s.taboption(tabname, form.ListValue, 'MODE_HTTP', _('MODE_HTTP'));
o.value('0', 'False');
o.value('1', 'True');
o = s.taboption(tabname, form.Flag, 'MODE_HTTP', _('MODE_HTTP'));
o.rmempty = false;
o.default = 0;
o = s.taboption(tabname, form.ListValue, 'MODE_HTTP_KEEPALIVE', _('MODE_HTTP_KEEPALIVE'));
o.value('0', 'False');
o.value('1', 'True');
o = s.taboption(tabname, form.Flag, 'MODE_HTTP_KEEPALIVE', _('MODE_HTTP_KEEPALIVE'));
o.rmempty = false;
o.default = 0;
o = s.taboption(tabname, form.ListValue, 'MODE_HTTPS', _('MODE_HTTPS'));
o.value('0', 'False');
o.value('1', 'True');
o = s.taboption(tabname, form.Value, 'HTTP_PORTS', _('HTTP_PORTS'));
o.rmempty = false;
o.datatype = 'string';
o = s.taboption(tabname, form.ListValue, 'MODE_QUIC', _('MODE_QUIC'));
o.value('0', 'False');
o.value('1', 'True');
o = s.taboption(tabname, form.Flag, 'MODE_HTTPS', _('MODE_HTTPS'));
o.rmempty = false;
o.default = 0;
o = s.taboption(tabname, form.Value, 'HTTPS_PORTS', _('HTTPS_PORTS'));
o.rmempty = false;
o.datatype = 'string';
o = s.taboption(tabname, form.Flag, 'MODE_QUIC', _('MODE_QUIC'));
o.rmempty = false;
o.default = 0;
o = s.taboption(tabname, form.Value, 'QUIC_PORTS', _('QUIC_PORTS'));
o.rmempty = false;
o.datatype = 'string';
o = s.taboption(tabname, form.Value, 'DESYNC_MARK', _('DESYNC_MARK'));
//o.description = _("nfqws option for DPI desync attack");
o.rmempty = false;
o.datatype = 'string';
o = s.taboption(tabname, form.Value, 'DESYNC_MARK_POSTNAT', _('DESYNC_MARK_POSTNAT'));
//o.description = _("nfqws option for DPI desync attack");
o.rmempty = false;
o.datatype = 'string';
/* NFQWS_OPT_DESYNC tab */
@@ -178,25 +200,77 @@ return view.extend({
o = s.taboption(tabname, form.Button, '_user_entries_btn', _('User hostname entries'));
o.inputtitle = _('Edit');
o.inputstyle = 'edit btn';
o.description = tools.hostsUserFN;
o.onclick = () => new tools.fileEditDialog(
tools.userEntriesFile,
tools.hostsUserFN,
_('User entries'),
_('One hostname per line.<br />Examples:'),
'<code>domain.net<br />sub.domain.com<br />googlevideo.com</code>',
15
).show();
o = s.taboption(tabname, form.Button, '_ip_filter_btn', _('User IP entries'));
o = s.taboption(tabname, form.Button, '_user_excluded_entries_btn', _('User excluded hostname entries'));
o.inputtitle = _('Edit');
o.inputstyle = 'edit btn';
o.description = tools.hostsUserExcludeFN;
o.onclick = () => new tools.fileEditDialog(
tools.hostsUserExcludeFN,
_('User excluded entries'),
_('One hostname per line.<br />Examples:'),
'<code>domain.net<br />sub.domain.com<br />googlevideo.com</code>',
15
).show();
add_delim(s);
o = s.taboption(tabname, form.Button, '_ip_exclude_filter_btn', _('Excluded IP entries'));
o.inputtitle = _('Edit');
o.inputstyle = 'edit btn';
o.description = tools.iplstExcludeFN;
o.onclick = () => new tools.fileEditDialog(
tools.ipFilterFile,
_('IP filter'),
tools.iplstExcludeFN,
_('Excluded IP filter'),
_('Patterns can be strings or regular expressions. Each pattern in a separate line<br />Examples:'),
'<code>128.199.0.0/16<br />34.217.90.52<br />162.13.190.77</code>',
15
).show();
o = s.taboption(tabname, form.Button, '_user_ip_filter_btn', _('User IP entries'));
o.inputtitle = _('Edit');
o.inputstyle = 'edit btn';
o.description = tools.iplstUserFN;
o.onclick = () => new tools.fileEditDialog(
tools.iplstUserFN,
_('User IP filter'),
_('Patterns can be strings or regular expressions. Each pattern in a separate line<br />Examples:'),
'<code>128.199.0.0/16<br />34.217.90.52<br />162.13.190.77</code>',
15
).show();
o = s.taboption(tabname, form.Button, '_user_excluded_ip_filter_btn', _('User excluded IP entries'));
o.inputtitle = _('Edit');
o.inputstyle = 'edit btn';
o.description = tools.iplstUserExcludeFN;
o.onclick = () => new tools.fileEditDialog(
tools.iplstUserExcludeFN,
_('User excluded IP filter'),
_('Patterns can be strings or regular expressions. Each pattern in a separate line<br />Examples:'),
'<code>128.199.0.0/16<br />34.217.90.52<br />162.13.190.77</code>',
15
).show();
add_delim(s);
for (let num = 1; num <= tools.custFileMax; num++) {
let fn = tools.custFileTemplate.format(num.toString());
let name = _('Custom file #' + num);
o = s.taboption(tabname, form.Button, '_cust_file%d_btn'.format(num), name);
o.inputtitle = _('Edit');
o.inputstyle = 'edit btn';
o.description = fn;
o.onclick = () => new tools.fileEditDialog(fn, name, '', '', 15).show();
}
let map_promise = m.render();
map_promise.then(node => node.classList.add('fade-in'));
return map_promise;

View File

@@ -36,18 +36,34 @@ document.head.append(E('style', {'type': 'text/css'},
return baseclass.extend({
appName : 'zapret',
execPath : '/opt/zapret/init.d/openwrt/zapret',
parsersDir : '/usr/libexec/ruantiblock',
userEntriesFile : '/opt/zapret/ipset/zapret-hosts-user.txt',
ipFilterFile : '/opt/zapret/ipset/zapret-ip-user.txt',
execPath : '/etc/init.d/zapret',
syncCfgPath : '/opt/zapret/sync_config.sh',
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',
custFileMax : 4,
custFileTemplate : '/opt/zapret/ipset/cust%s.txt',
infoLabelRunning : '<span class="label-status running">' + _('Running') + '</span>',
infoLabelStarting : '<span class="label-status starting">' + _('Starting') + '</span>',
infoLabelRunning : '<span class="label-status running">' + _('Enabled') + '</span>',
infoLabelUpdating : '<span class="label-status updating">' + _('Updating') + '</span>',
infoLabelStopped : '<span class="label-status stopped">' + _('Disabled') + '</span>',
infoLabelError : '<span class="label-status error">' + _('Error') + '</span>',
infoLabelStopped : '<span class="label-status stopped">' + _('Stopped') + '</span>',
infoLabelDisabled : '<span class="label-status stopped">' + _('Disabled') + '</span>',
infoLabelError : '<span class="label-status error">' + _('Error') + '</span>',
callInitStatus: rpc.declare({
infoLabelUpdating : '<span class="label-status updating">' + _('Updating') + '</span>',
statusDict: {
error : { code: 0, name: _('Error') , label: this.infoLabelError },
disabled : { code: 1, name: _('Disabled') , label: this.infoLabelDisabled },
stopped : { code: 2, name: _('Stopped') , label: this.infoLabelStopped },
starting : { code: 3, name: _('Starting') , label: this.infoLabelStarting },
running : { code: 4, name: _('Running') , label: this.infoLabelRunning },
},
callInitState: rpc.declare({
object: 'luci',
method: 'getInitList',
params: [ 'name' ],
@@ -61,10 +77,10 @@ return baseclass.extend({
expect: { result: false }
}),
getInitStatus: function(name) {
return this.callInitStatus(name).then(res => {
getInitState: function(name) {
return this.callInitState(name).then(res => {
if (res) {
return res[name].enabled;
return res[name].enabled ? true : false;
} else {
throw _('Command failed');
}
@@ -88,72 +104,130 @@ return baseclass.extend({
return (v && typeof(v) === 'string') ? v.trim().replace(/\r?\n/g, '') : v;
},
makeStatusString: function(app_status_code, fwtype, bllist_preset) {
let app_status_label;
let spinning = '';
/*
switch(app_status_code) {
case 0:
app_status_label = this.infoLabelRunning;
break;
case 2:
app_status_label = this.infoLabelStopped;
break;
case 3:
app_status_label = this.infoLabelStarting;
spinning = ' spinning';
break;
case 4:
app_status_label = this.infoLabelUpdating;
spinning = ' spinning';
break;
default:
app_status_label = this.infoLabelError;
return `<table class="table">
<tr class="tr">
<td class="td left" style="min-width:33%%">
${_('Status')}:
</td>
<td class="td left">
${app_status_label}
</td>
</tr>
</table>`;
get_pid_list: function(proc_list) {
let plist = [ ];
let lines = proc_list.trim().split('\n');
for (let i = 0; i < lines.length; i++) {
let line = lines[i].trim();
if (line.length > 5) {
let word_list = line.split(/\s+/);
let pid = word_list[0];
let isnum = /^\d+$/.test(pid);
if (isnum) {
plist.push(parseInt(pid));
}
}
}
*/
return `<table class="table">
return plist;
},
decode_svc_info: function(svc_autorun, svc_info, proc_list, cfg) {
let result = {
"autorun": svc_autorun,
"dmn": {
total: 0,
running: 0,
working: 0,
},
"status": this.statusDict.error,
};
if (svc_info.code != 0) {
return -1;
}
if (proc_list.code != 0) {
return -2;
}
let plist = this.get_pid_list(proc_list.stdout);
let jdata = JSON.parse(svc_info.stdout);
if (typeof(jdata) !== 'object') {
return -3;
}
if (typeof(jdata.zapret) == 'object') {
let dmn_list = jdata.zapret.instances;
if (typeof(dmn_list) !== 'object') {
return -4;
}
for (const [dmn_name, daemon] of Object.entries(dmn_list)) {
result.dmn.total += 1;
if (daemon.running) {
result.dmn.running += 1;
}
if (daemon.pid !== undefined && daemon.pid != null) {
if (plist.includes(daemon.pid)) {
result.dmn.working += 1;
}
}
}
}
//console.log('SVC_DAEMONS: ' + result.dmn.working + ' / ' + result.dmn.total);
if (result.dmn.total == 0) {
result.status = (!svc_autorun) ? this.statusDict.disabled : this.statusDict.stopped;
} else {
result.status = (!result.dmn.working) ? this.statusDict.started : this.statusDict.running;
}
return result;
},
makeStatusString: function(svcinfo, fwtype, bllist_preset) {
let svc_autorun = _('Unknown');
let svc_daemons = _('Unknown');
if (typeof(svcinfo) == 'object') {
svc_autorun = (svcinfo.autorun) ? _('Enabled') : _('Disabled');
if (svcinfo.dmn.total == 0) {
svc_daemons = _('Stopped');
} else {
svc_daemons = (!svcinfo.dmn.working) ? _('Starting') : _('Running');
svc_daemons += ' [' + svcinfo.dmn.working + '/' + svcinfo.dmn.total + ']';
}
}
let update_mode = _('user entries only');
let td_name_width = 40;
let td_name_style = `style="width: ${td_name_width}%; min-width:${td_name_width}%; max-width:${td_name_width}%;"`;
let out = `
<table class="table">
<tr class="tr">
<td class="td left" style="min-width:33%%">
${_('Status')}:
<td class="td left" ${td_name_style}>
${_('Service autorun status')}:
</td>
<td class="td left%s">
%s %s
<td class="td left">
${svc_autorun}
</td>
</tr>
<tr class="tr">
<td class="td left">
<td class="td left" ${td_name_style}>
${_('Service daemons status')}:
</td>
<td class="td left %s">
${svc_daemons}
</td>
</tr>
<tr class="tr">
<td class="td left" ${td_name_style}>
${_('FW type')}:
</td>
<td class="td left">
%s
${fwtype}
</td>
</tr>
<tr class="tr">
<td class="td left">
<td class="td left" ${td_name_style}>
${_('Blacklist update mode')}:
</td>
<td class="td left">
%s
${update_mode}
</td>
</tr>
</table>
`.format(
spinning,
app_status_label,
'',
fwtype,
_('user entries only')
);
<tr class="tr">
<td class="td left" ${td_name_style}>
</td>
<td class="td left">
</td>
</tr>
</table>`;
return out;
},
fileEditDialog: baseclass.extend({

View File

@@ -8,6 +8,7 @@
"/opt/zapret/ipset/*": [ "read" ],
"/etc/crontabs/root": [ "read" ],
"/etc/init.d/zapret*": [ "exec" ],
"/bin/ps*": [ "exec" ],
"/opt/zapret/sync_config.sh*": [ "exec" ]
},
"uci": [ "zapret", "network" ],

View File

@@ -1,21 +1,26 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=zapret-ip2net
PKG_VERSION:=64
PKG_RELEASE:=20241014
PKG_VERSION:=65
PKG_RELEASE:=20241023
PKG_MAINTAINER:=bol-van
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=docs/LICENSE.txt
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/bol-van/zapret/archive/refs/tags/v$(PKG_VERSION).tar.gz?
PKG_HASH:=skip
PKG_SOURCE_URL:=https://github.com/bol-van/zapret.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=5cd5ab176ebe020f0af66829254dc29f275c1840
PKG_SOURCE_DATE:=2024-10-23
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
#PKG_SOURCE_URL:=https://github.com/bol-van/zapret/archive/refs/tags/v$(PKG_VERSION).tar.gz?
#PKG_HASH:=skip
include $(INCLUDE_DIR)/package.mk
TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
#TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
#TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
MAKE_PATH:=ip2net

View File

@@ -1,21 +1,26 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=zapret-mdig
PKG_VERSION:=64
PKG_RELEASE:=20241014
PKG_VERSION:=65
PKG_RELEASE:=20241023
PKG_MAINTAINER:=bol-van
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=docs/LICENSE.txt
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/bol-van/zapret/archive/refs/tags/v$(PKG_VERSION).tar.gz?
PKG_HASH:=skip
PKG_SOURCE_URL:=https://github.com/bol-van/zapret.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=5cd5ab176ebe020f0af66829254dc29f275c1840
PKG_SOURCE_DATE:=2024-10-23
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
#PKG_SOURCE_URL:=https://github.com/bol-van/zapret/archive/refs/tags/v$(PKG_VERSION).tar.gz?
#PKG_HASH:=skip
include $(INCLUDE_DIR)/package.mk
TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
#TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
#TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
MAKE_PATH:=mdig

View File

@@ -1,21 +1,26 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=zapret-tpws
PKG_VERSION:=64
PKG_RELEASE:=20241014
PKG_VERSION:=65
PKG_RELEASE:=20241023
PKG_MAINTAINER:=bol-van
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=docs/LICENSE.txt
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/bol-van/zapret/archive/refs/tags/v$(PKG_VERSION).tar.gz?
PKG_HASH:=skip
PKG_SOURCE_URL:=https://github.com/bol-van/zapret.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=5cd5ab176ebe020f0af66829254dc29f275c1840
PKG_SOURCE_DATE:=2024-10-23
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
#PKG_SOURCE_URL:=https://github.com/bol-van/zapret/archive/refs/tags/v$(PKG_VERSION).tar.gz?
#PKG_HASH:=skip
include $(INCLUDE_DIR)/package.mk
TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
#TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
#TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
MAKE_PATH:=tpws

View File

@@ -5,21 +5,26 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=zapret
PKG_VERSION:=64
PKG_RELEASE:=20241014
PKG_VERSION:=65
PKG_RELEASE:=20241023
PKG_MAINTAINER:=bol-van
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=docs/LICENSE.txt
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/bol-van/zapret/archive/refs/tags/v$(PKG_VERSION).tar.gz?
PKG_HASH:=skip
PKG_SOURCE_URL:=https://github.com/bol-van/zapret.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=5cd5ab176ebe020f0af66829254dc29f275c1840
PKG_SOURCE_DATE:=2024-10-23
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
#PKG_SOURCE_URL:=https://github.com/bol-van/zapret/archive/refs/tags/v$(PKG_VERSION).tar.gz?
#PKG_HASH:=skip
include $(INCLUDE_DIR)/package.mk
TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
#TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
#TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
MAKE_PATH:=nfq
@@ -40,31 +45,26 @@ define Build/Prepare
rm -f $(PKG_BUILD_DIR)/$(MAKE_PATH)/nfqws
endef
define Package/$(PKG_NAME)/conffiles
/etc/config/zapret
/opt/zapret/config
/opt/zapret/ipset/zapret-hosts-user.txt
/opt/zapret/ipset/zapret-hosts-user-exclude.txt
/opt/zapret/ipset/zapret-hosts-user-ipban.txt
/opt/zapret/ipset/zapret-ip-user.txt
/opt/zapret/ipset/zapret-ip-user-exclude.txt
/opt/zapret/ipset/zapret-ip-user-ipban.txt
endef
#define Build/Configure
#endef
#define Build/Compile
#endef
define Package/$(PKG_NAME)/conffiles
/etc/config/zapret
/opt/zapret/config
/opt/zapret/ipset/
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/opt/zapret
$(INSTALL_DIR) $(1)/opt/zapret/$(MAKE_PATH)
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/nfqws $(1)/opt/zapret/$(MAKE_PATH)/
$(INSTALL_DIR) $(1)/opt/zapret/common
$(CP) $(PKG_BUILD_DIR)/common/* $(1)/opt/zapret/common/
$(INSTALL_DIR) $(1)/opt/zapret/docs
$(CP) $(PKG_BUILD_DIR)/docs/* $(1)/opt/zapret/docs/
#$(INSTALL_DIR) $(1)/opt/zapret/docs
#$(CP) $(PKG_BUILD_DIR)/docs/* $(1)/opt/zapret/docs/
$(INSTALL_DIR) $(1)/opt/zapret/files
$(CP) $(PKG_BUILD_DIR)/files/* $(1)/opt/zapret/files/
$(INSTALL_DIR) $(1)/opt/zapret/ipset
@@ -93,14 +93,58 @@ define Package/$(PKG_NAME)/install
$(INSTALL_BIN) ./sync_config.sh $(1)/opt/zapret/sync_config.sh
endef
define Package/$(PKG_NAME)/preinst
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
if [ -f "/etc/init.d/zapret" ]; then
SCRIPT=$$( readlink /etc/init.d/zapret )
if [ -n "$${SCRIPT}" ]; then
echo "Please uninstall original zapret utility!"
exit 44
fi
fi
if [ "$${PKG_UPGRADE}" = "1" ]; then
# stop service if PKG_UPGRADE
[ -x "/etc/init.d/zapret" ] && /etc/init.d/zapret stop >/dev/null 2>&1
fi
fi
exit 0
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
NEWCFGNAME=zapret-opkg
NEWCFGFILE=/etc/config/$${NEWCFGNAME}
if [ -f "$${NEWCFGFILE}" ]; then
uci -m -f /etc/config/zapret import "$${NEWCFGNAME}"
uci commit "$${NEWCFGNAME}"
uci -m -f "$${NEWCFGFILE}" import zapret
uci commit zapret
rm -f "$${NEWCFGFILE}"
echo "File /etc/config/zapret merged from IPK"
fi
NEWCONFIG=/opt/zapret/config-opkg
if [ -f "$${NEWCONFIG}" ]; then
# backup current main config
mv -f /opt/zapret/config /opt/zapret/config.backup
# renew main config
mv -f "$${NEWCONFIG}" /opt/zapret/config
echo "File /opt/zapret/config replaced from IPK"
fi
# synchnonize main config
/opt/zapret/sync_config.sh
# enable main service
/etc/init.d/zapret enable
# stop all
/etc/init.d/zapret stop_fw
/etc/init.d/zapret stop_daemons
ps w | grep '/opt/zapret/nfq/nfqws' | grep -v grep | awk '{print $$1}' | xargs -r kill -9
# start main service
/etc/init.d/zapret start
# restart firewall
[ -x /sbin/fw4 ] && fw4 -q restart || fw3 -q restart
fi
exit 0
@@ -109,17 +153,19 @@ endef
define Package/$(PKG_NAME)/prerm
#!/bin/sh
# check if we are on real system
if [ -n "$${IPKG_INSTROOT}" ]; then
if [ -z "$${IPKG_INSTROOT}" ]; then
EXEDIR=/opt/zapret
ZAPRET_BASE=/opt/zapret
ZAPRET_CONFIG=/opt/zapret/config
OPENWRT_FW_INCLUDE=/etc/firewall.zapret
. "$ZAPRET_CONFIG"
. "$ZAPRET_BASE/common/base.sh"
. "$ZAPRET_BASE/common/fwtype.sh"
. "$ZAPRET_BASE/common/installer.sh"
. "$${ZAPRET_CONFIG}"
. "$${ZAPRET_BASE}/common/base.sh"
. "$${ZAPRET_BASE}/common/fwtype.sh"
. "$${ZAPRET_BASE}/common/nft.sh"
. "$${ZAPRET_BASE}/common/installer.sh"
/etc/init.d/zapret disable
/etc/init.d/zapret stop
ps w | grep '/opt/zapret/nfq/nfqws' | grep -v grep | awk '{print $$1}' | xargs -r kill -9
remove_openwrt_firewall
nft_del_table
restart_openwrt_firewall
@@ -127,4 +173,16 @@ fi
exit 0
endef
define Package/$(PKG_NAME)/postrm
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
[ -f "/etc/config/zapret-opkg" ] && rm -f "/etc/config/zapret-opkg"
[ -f "/opt/zapret/config" ] && cp -f /opt/zapret/config "/opt/zapret/config.backup2"
#rm -rf /opt/zapret
#echo "Directory /opt/zapret removed!"
fi
exit 0
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@@ -42,9 +42,9 @@ GZIP_LISTS=0
#LISTS_RELOAD="pfctl -f /etc/pf.conf"
# override ports
#HTTP_PORTS=80-81,85
#HTTPS_PORTS=443,500-501
#QUIC_PORTS=443,444
HTTP_PORTS=80
HTTPS_PORTS=443
QUIC_PORTS=443
# CHOOSE OPERATION MODE
# MODE : nfqws,tpws,tpws-socks,filter,custom

View File

@@ -46,20 +46,25 @@ sync_param INIT_APPLY_FW
sync_param DISABLE_IPV4
sync_param DISABLE_IPV6
sync_param MODE_FILTER
sync_param DESYNC_MARK
sync_param DESYNC_MARK_POSTNAT
sync_param NFQWS_OPT_DESYNC str
sync_param NFQWS_OPT_DESYNC_SUFFIX str
sync_param MODE_HTTP
sync_param MODE_HTTP_KEEPALIVE
sync_param HTTP_PORTS
sync_param NFQWS_OPT_DESYNC_HTTP str
sync_param NFQWS_OPT_DESYNC_HTTP_SUFFIX str
sync_param NFQWS_OPT_DESYNC_HTTP6 str
sync_param NFQWS_OPT_DESYNC_HTTP6_SUFFIX str
sync_param MODE_HTTPS
sync_param HTTPS_PORTS
sync_param NFQWS_OPT_DESYNC_HTTPS str
sync_param NFQWS_OPT_DESYNC_HTTPS_SUFFIX str
sync_param NFQWS_OPT_DESYNC_HTTPS6 str
sync_param NFQWS_OPT_DESYNC_HTTPS6_SUFFIX str
sync_param MODE_QUIC
sync_param QUIC_PORTS
sync_param NFQWS_OPT_DESYNC_QUIC str
sync_param NFQWS_OPT_DESYNC_QUIC_SUFFIX str
sync_param NFQWS_OPT_DESYNC_QUIC6 str

View File

@@ -7,20 +7,25 @@ config main 'config'
option DISABLE_IPV4 '0'
option DISABLE_IPV6 '1'
option MODE_FILTER 'hostlist'
option DESYNC_MARK '0x40000000'
option DESYNC_MARK_POSTNAT '0x20000000'
option NFQWS_OPT_DESYNC '--dpi-desync=fake,split2 --dpi-desync-ttl=7 --dpi-desync-ttl6=0 --dpi-desync-repeats=20 --dpi-desync-fooling=md5sig,badseq --dpi-desync-fake-tls=/opt/zapret/files/fake/tls_clienthello_www_google_com.bin'
option NFQWS_OPT_DESYNC_SUFFIX ''
option MODE_HTTP '1'
option MODE_HTTP_KEEPALIVE '0'
option HTTP_PORTS '80'
option NFQWS_OPT_DESYNC_HTTP ''
option NFQWS_OPT_DESYNC_HTTP_SUFFIX ''
option NFQWS_OPT_DESYNC_HTTP6 ''
option NFQWS_OPT_DESYNC_HTTP6_SUFFIX ''
option MODE_HTTPS '1'
option HTTPS_PORTS '443'
option NFQWS_OPT_DESYNC_HTTPS ''
option NFQWS_OPT_DESYNC_HTTPS_SUFFIX ''
option NFQWS_OPT_DESYNC_HTTPS6 ''
option NFQWS_OPT_DESYNC_HTTPS6_SUFFIX ''
option MODE_QUIC '1'
option QUIC_PORTS '443'
option NFQWS_OPT_DESYNC_QUIC '--dpi-desync=fake,split2 --dpi-desync-repeats=15 --dpi-desync-fake-quic=/opt/zapret/files/fake/quic_initial_www_google_com.bin --new --dpi-desync=fake --dpi-desync-repeats=15'
option NFQWS_OPT_DESYNC_QUIC_SUFFIX ''
option NFQWS_OPT_DESYNC_QUIC6 ''