mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 08:23:56 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,2 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,46 @@
|
||||
# Copyright 2023- Douglas Orend <doug.orend2@gmail.com>
|
||||
# This is free software, licensed under the Apache License, Version 2.0
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_NAME:=luci-app-nodogsplash
|
||||
PKG_VERSION:=2.0.1
|
||||
PKG_RELEASE:=1
|
||||
PKG_MAINTAINER:=Douglas Orend <doug.orend2@gmail.com>
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/luci-app-nodogsplash
|
||||
SECTION:=luci
|
||||
CATEGORY:=LuCI
|
||||
SUBMENU:=3. Applications
|
||||
TITLE:=LuCI support for NoDogSplash
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+nodogsplash +luci-base
|
||||
endef
|
||||
|
||||
define Package/luci-app-nodogsplash/description
|
||||
LuCI Support for NoDogSplash
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/luci-app-nodogsplash/install
|
||||
$(INSTALL_DIR) $(1)/www/luci-static/resources/view/nodogsplash/
|
||||
$(INSTALL_DATA) ./htdocs/luci-static/resources/view/nodogsplash/*.js $(1)/www/luci-static/resources/view/nodogsplash/
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/share/luci/menu.d/
|
||||
$(INSTALL_DATA) ./root/usr/share/luci/menu.d/luci-app-nodogsplash.json $(1)/usr/share/luci/menu.d/
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d
|
||||
$(INSTALL_DATA) ./root/usr/share/rpcd/acl.d/luci-app-nodogsplash.json $(1)/usr/share/rpcd/acl.d/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,luci-app-nodogsplash))
|
||||
@@ -0,0 +1,18 @@
|
||||
# luci-app-nodogsplash
|
||||
|
||||
Package for luci-app-nodogsplash for OpenWRT
|
||||
|
||||
### Status Tab
|
||||

|
||||
|
||||
### General Tab
|
||||

|
||||
|
||||
### MAC Filter Tab
|
||||

|
||||
|
||||
### Firewall Tab
|
||||

|
||||
|
||||
### Advanced Tab
|
||||

|
||||
@@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
'require form';
|
||||
'require ui';
|
||||
'require view';
|
||||
|
||||
// Project code format is tabs, not spaces
|
||||
return view.extend({
|
||||
render: function() {
|
||||
var m, s, o, i, t;
|
||||
m = new form.Map('nodogsplash', _("Advanced Settings"));
|
||||
|
||||
s = m.section(form.TypedSection, 'nodogsplash');
|
||||
s.anonymous = true;
|
||||
|
||||
o = s.option(form.Flag, 'fwhook_enabled', _("Restart nodogsplash when the firewall restarts."), _("Enabled by default"));
|
||||
o.rmempty = false;
|
||||
o.optional = false;
|
||||
|
||||
o = s.option(form.Value, 'gatewayport', _('Gateway Port Number'));
|
||||
o.default = "2050"
|
||||
o.rmempty = false;
|
||||
o.datatype = "integer"
|
||||
|
||||
o = s.option(form.Value, 'webroot', _('Web folder'))
|
||||
o.placeholder = "/etc/nodogsplash/htdocs"
|
||||
|
||||
o = s.option(form.Value, 'maxclients', _('Maximum number of users'))
|
||||
o.placeholder = "250"
|
||||
o.datatype = "integer"
|
||||
|
||||
o = s.option(form.Value, "preauth", _("Dynamic Web Page served by NDS"), _("The shell script will be invoked for authentication. <br/> Refer here for more information:") + " <a href=\"https://nodogsplash.readthedocs.io/en/latest/customize.html#the-splash-page\" target=\"blank\">NoDogSplash Wiki: The Splash Page</a>")
|
||||
o.placeholder = "/usr/lib/nodogsplash/login.sh"
|
||||
o.optional = true
|
||||
|
||||
o = s.option(form.Value, "binauth", _("Shell Script Path"), _("The shell script will be invoked for authentication. <br/> Refer here for more information:") + " <a href=\"https://nodogsplash.readthedocs.io/en/latest/binauth.html\" target=\"blank\">NoDogSplash Wiki: BinAuth Option</a>")
|
||||
o.placeholder = "/bin/myauth.sh"
|
||||
o.optional = true
|
||||
|
||||
o = s.option(form.ListValue, 'gatewayinterface', _('Debug Level'));
|
||||
o.value("0", _("Level 0: Silent"));
|
||||
o.value("1", _("Level 1: LOG_ERR, LOG_EMERG, LOG_WARNING and LOG_NOTICE"))
|
||||
o.value("2", _("Level 2: Level 1 + LOG_INFO"))
|
||||
o.value("3", _("Level 3: Level 2 + LOG_DEBUG"))
|
||||
o.rmempty = false;
|
||||
|
||||
s = m.section(form.TypedSection, 'nodogsplash', _("Forwarding Authentication Service") + " (FAS)");
|
||||
s.anonymous = true;
|
||||
|
||||
o = s.option(form.Value, "fasremoteip ", _("FAS Remote IP Address"))
|
||||
o.optional = true
|
||||
|
||||
o = s.option(form.Value, "fasport", _("FAS Port Number Used"), _("if FAS is running locally (ie fasremoteip is NOT set), port 80 cannot be used.<br/>Typical Remote Shared Hosting Example:80.Typical Locally Hosted example (ie fasremoteip not set):2080.<br/>if Enable username/emailaddress login.fasport must be set to the same value as gatewayport (default = 2050)"))
|
||||
o.optional = true
|
||||
o.datatype = "integer"
|
||||
|
||||
o = s.option(form.Value, "faspath", _("FAS Page Address"), _("The path of login page under Web root directory, ex: '/nodog/fas.php'<br/>If it is a user name login authentication method, ex: '/nodogsplash_preauth/'"))
|
||||
o.optional = true
|
||||
|
||||
o = s.option(form.Flag, "fas_secure_enabled", _("FAS Client token encryption"), _("If unchecked, the client token is sent to the FAS in clear text in the query string of the."))
|
||||
o.optional = true
|
||||
o.placeholder = "0"
|
||||
o.datatype="integer"
|
||||
|
||||
return m.render();
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
'require form';
|
||||
'require view';
|
||||
|
||||
// Project code format is tabs, not spaces
|
||||
return view.extend({
|
||||
render: function() {
|
||||
var m, s, o, i, t;
|
||||
m = new form.Map('nodogsplash', _("Firewall Settings"));
|
||||
|
||||
s = m.section(form.TypedSection, 'nodogsplash');
|
||||
s.anonymous = true;
|
||||
|
||||
o = s.option(form.DynamicList, "preauthenticated_users", _("Open Port Before Authentication"), _("<br/>allow:<br/>allow tcp port 80<br/>allow udp port 53"))
|
||||
o.optional = true
|
||||
|
||||
o = s.option(form.DynamicList, "users_to_router", _("LAN Open Port"), _("<br/>allow:<br/>allow tcp port 80<br/>allow udp port 53"))
|
||||
o.optional = true
|
||||
|
||||
o = s.option(form.DynamicList, "authenticated_users", _("Authenticated client isolation settings"), _("<br/>allow:<br/>allow tcp port 80<br/>allow udp port 53<br/>allow all<br/>block:<br/>block to 192.168.0.0/16<br/>192.168.X.1 80 Port Isolation Invalid."))
|
||||
o.optional = true
|
||||
|
||||
s = m.section(form.TypedSection, 'nodogsplash', _("Firewall Mask Settings"));
|
||||
s.anonymous = true;
|
||||
|
||||
o = s.option(form.Flag, "temp_mask", _("Use specific HEXADECIMAL values to mark packets used by iptables as a bitwise mask."),
|
||||
_("<br/> Modify the packet marker hexadecimal mask <br/> without modification if necessary. < br /> if you need visitor equipment to support adbyby, ssr.... See the default package tag. Modify iptables by yourself. <br/>"))
|
||||
|
||||
o = s.option(form.Value, "fw_mark_authenticated", "fw_mark_authenticated");
|
||||
o.placeholder = "30000"
|
||||
o.datatype="integer"
|
||||
o.depends({"temp_mask": "1"})
|
||||
|
||||
o = s.option(form.Value, "fw_mark_trusted", "fw_mark_trusted")
|
||||
o.placeholder = "20000"
|
||||
o.datatype="integer"
|
||||
o.depends({"temp_mask": "1"})
|
||||
|
||||
o = s.option(form.Value, "fw_mark_blocked", "fw_mark_blocked")
|
||||
o.placeholder = "10000"
|
||||
o.datatype="integer"
|
||||
o.depends({"temp_mask": "1"})
|
||||
|
||||
return m.render();
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
'require form';
|
||||
'require ui';
|
||||
'require view';
|
||||
'require network';
|
||||
|
||||
// Project code format is tabs, not spaces
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return Promise.all([
|
||||
network.getDevices(),
|
||||
]);
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
var netDevs = data[0];
|
||||
var m, s, o, i, t;
|
||||
m = new form.Map('nodogsplash', _("General Settings"));
|
||||
|
||||
s = m.section(form.TypedSection, 'nodogsplash');
|
||||
s.anonymous = true;
|
||||
|
||||
o = s.option(form.Flag, 'enabled', _('Enabled'));
|
||||
o.rmempty = false;
|
||||
o.optional = false;
|
||||
|
||||
o = s.option(form.ListValue, 'gatewayinterface', _('Interface Name'));
|
||||
o.default = netDevs[0].getName();
|
||||
for (var i = 0; i < netDevs.length; i++) {
|
||||
t = netDevs[i].getName();
|
||||
if (t != "lo" && t.substring(0,3) != "ifb" && t.substring(0,5) != "radio") {
|
||||
o.value(t);
|
||||
}
|
||||
if (t == "br-lan") {
|
||||
o.default = t;
|
||||
}
|
||||
}
|
||||
o.rmempty = false;
|
||||
o.optional = false;
|
||||
|
||||
o = s.option(form.Value, 'gatewayname', _('Authentication Page Name'), _("Name displayed on portal page."));
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'preauthidletimeout', _("Equipment Disconnection Retention Authentication (sub)"));
|
||||
o.placeholder = "30"
|
||||
o.rmempty = false;
|
||||
o.datatype = "integer"
|
||||
|
||||
o = s.option(form.Value, 'authidletimeout', _("Time of equipment re-certification (minutes)"))
|
||||
o.placeholder = "120"
|
||||
o.rmempty = false;
|
||||
o.datatype = "integer"
|
||||
|
||||
o = s.option(form.Value, 'sessiontimeout', _("Portal page timeout (seconds)"))
|
||||
o.placeholder = "1200"
|
||||
o.rmempty = false;
|
||||
o.datatype = "integer"
|
||||
|
||||
o = s.option(form.Value, 'checkinterval', _("Check the authentication status interval (seconds)"))
|
||||
o.placeholder = "600"
|
||||
o.rmempty = false;
|
||||
o.datatype = "integer"
|
||||
|
||||
return m.render();
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,187 @@
|
||||
'use strict';
|
||||
'require form';
|
||||
'require ui';
|
||||
'require view';
|
||||
'require uci';
|
||||
'require fs';
|
||||
|
||||
// Project code format is tabs, not spaces
|
||||
return view.extend({
|
||||
can_block: true,
|
||||
auth_list: [],
|
||||
allow_list: [],
|
||||
block_list: [],
|
||||
trust_list: [],
|
||||
allow_orig: [],
|
||||
block_orig: [],
|
||||
trust_orig: [],
|
||||
client_list: [],
|
||||
|
||||
load: function () {
|
||||
return Promise.all([
|
||||
uci.load('nodogsplash')
|
||||
]).then(function(stat) {
|
||||
return fs.exec_direct("/usr/bin/ndsctl", [ 'json' ]).catch(function(err) {
|
||||
ui.addNotification(null, E('p', {}, err.message ));
|
||||
return '';
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
ndsctl: function(group, div, cmd) {
|
||||
var mac = div.previousSibling.getElementsByClassName('mac')[0].innerHTML;
|
||||
var is_active = this.client_list[mac].state != null;
|
||||
var no_un = cmd.replace(/un|de/, "");
|
||||
|
||||
fs.exec('/usr/bin/ndsctl', [ cmd, mac ]).then(function(res) {
|
||||
ui.addNotification(null, E('p', [ res.stdout ]), res.code ? 'error' : 'success')
|
||||
}).catch(function(err) {
|
||||
ui.addNotification(null, E('p', [ err ]), 'error')
|
||||
});
|
||||
if (cmd != no_un)
|
||||
{
|
||||
group = group.filter( check => check != mac );
|
||||
div.getElementsByClassName('cbi-un' + no_un + '-button')[0].classList.add("hidden");
|
||||
div.getElementsByClassName('cbi-' + no_un + '-button')[0].classList.remove("hidden");
|
||||
} else {
|
||||
group = group.push(mac);
|
||||
div.getElementsByClassName('cbi-' + no_un + '-button')[0].classList.add("hidden");
|
||||
div.getElementsByClassName('cbi-un' + no_un + '-button')[0].classList.remove("hidden");
|
||||
}
|
||||
uci.set_first("nodogsplash", "nodogsplash", "trustedmac", group.length > 0 ? group : null);
|
||||
},
|
||||
|
||||
trust_mac: function(elem, cmd) {
|
||||
this.ndsctl(this.trust_orig, elem.currentTarget.parentNode, 'trust');
|
||||
},
|
||||
|
||||
untrust_mac: function(elem, cmd) {
|
||||
this.ndsctl(this.trust_orig, elem.currentTarget.parentNode, 'untrust');
|
||||
},
|
||||
|
||||
allow_mac: function(elem, cmd) {
|
||||
this.ndsctl(this.allow_orig, elem.currentTarget.parentNode, 'allow');
|
||||
},
|
||||
|
||||
unallow_mac: function(elem, cmd) {
|
||||
this.ndsctl(this.allow_orig, elem.currentTarget.parentNode, 'unallow');
|
||||
},
|
||||
|
||||
block_mac: function(elem, cmd) {
|
||||
this.ndsctl(this.allow_orig, elem.currentTarget.parentNode, 'block');
|
||||
},
|
||||
|
||||
unblock_mac: function(elem, cmd) {
|
||||
this.ndsctl(this.allow_orig, elem.currentTarget.parentNode, 'unblock');
|
||||
},
|
||||
|
||||
auth_mac: function(elem, cmd) {
|
||||
this.ndsctl(this.auth_orig, elem.currentTarget.parentNode, 'auth');
|
||||
},
|
||||
|
||||
unauth_mac: function(elem, cmd) {
|
||||
this.ndsctl(this.auth_orig, elem.currentTarget.parentNode, 'deauth');
|
||||
},
|
||||
|
||||
render_button: function(txt, is_hidden) {
|
||||
var cname = txt.toLowerCase();
|
||||
return E('button', {
|
||||
'class': 'cbi-button cbi-button-action cbi-' + cname + '-button cbi-' + cname.replace('un', '') + '-group' + (is_hidden ? ' hidden' : ''),
|
||||
'click': ui.createHandlerFn(this, cname + '_mac')
|
||||
}, _(txt + ' MAC'));
|
||||
},
|
||||
|
||||
render_client: function(client) {
|
||||
return E('tr', { 'class': 'tr mac-' + client.mac.replaceAll(":", "") }, [
|
||||
E('td', { 'class': 'td left', 'style': 'width: 50%;' }, [
|
||||
E('span', { style: 'font-size:medium;', class: 'mac' }, client.mac),
|
||||
E('span', {}, client.ip != null ? ' (' + client.ip + ')' : ''),
|
||||
E('ul', { style: "margin-left: 20px" }, [
|
||||
E('li', { style: "list-style-type: circle;" }, [
|
||||
E('span', { style: "font-weight:bold;" }, _("Client Status") + ": "),
|
||||
E('span', {}, client.state != null ? _(client.state) : _('Disconnected'))
|
||||
]),
|
||||
client.state != null ? E('li', { style: "list-style-type: circle;" }, [
|
||||
E('span', { style: "font-weight:bold;" }, _("Active Since") + ": "),
|
||||
E('span', {}, new Date(client.active * 1000)),
|
||||
]) : E('span', {})
|
||||
]),
|
||||
]),
|
||||
E('td', { 'class': 'diag-action', 'style': 'width: 50%; vertical-align: top;' }, [
|
||||
this.render_button('Trust', client.trusted),
|
||||
this.render_button('Untrust', !client.trusted),
|
||||
this.render_button('Allow', client.allowed || this.can_block),
|
||||
this.render_button('Unallow', !client.allowed || this.can_block),
|
||||
this.render_button('Block', client.blocked || !this.can_block),
|
||||
this.render_button('Unblock', !client.blocked || !this.can_block),
|
||||
])
|
||||
]);
|
||||
},
|
||||
|
||||
render_list: function(table, list) {
|
||||
for (let i in list) {
|
||||
// Render the client data:
|
||||
var client = list[i].mac == null ? { mac: list[i] } : list[i];
|
||||
var mac = client.mac = client.mac.toLowerCase();
|
||||
client.trusted = this.trust_list.includes(mac);
|
||||
client.allowed = this.allow_list.includes(mac);
|
||||
client.blocked = this.block_list.includes(mac);
|
||||
this.client_list[ mac ] = client;
|
||||
table.appendChild( this.render_client( client ) );
|
||||
|
||||
// Remove the client from each of the mac lists:
|
||||
this.trust_list = this.trust_list.filter( check => check != mac );
|
||||
this.allow_list = this.allow_list.filter( check => check != mac );
|
||||
this.block_list = this.block_list.filter( check => check != mac );
|
||||
}
|
||||
return table;
|
||||
},
|
||||
|
||||
lowercase_list: function(table) {
|
||||
for (let i in table)
|
||||
table[i] = table[i].toLowerCase();
|
||||
return table;
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
var m, s, o;
|
||||
var sections = uci.sections('nodogsplash');
|
||||
this.allow_orig = this.allow_list = this.lowercase_list( sections[0].allowedmac != null ? sections[0].allowedmac : [] );
|
||||
this.block_orig = this.block_list = this.lowercase_list( sections[0].blockedmac != null ? sections[0].blockedmac : [] );
|
||||
this.trust_orig = this.trust_list = this.lowercase_list( sections[0].trustedmac != null ? sections[0].trustedmac : [] );
|
||||
this.can_block = sections[0].macmechanism == 'block';
|
||||
|
||||
// Process the current clients first, creating table for use later:
|
||||
var table = E('table', { 'class': 'table mac-table' });
|
||||
data = JSON.parse( (data == '' || data == null) ? '{"clients": {}}' : data );
|
||||
this.render_list( table, data.clients );
|
||||
|
||||
// Process the trusted, allowed and blocked MAC address lists:
|
||||
this.render_list( table, this.trust_list );
|
||||
this.render_list( table, this.allow_list );
|
||||
this.render_list( table, this.block_list );
|
||||
|
||||
// Actually render the page:
|
||||
m = new form.Map('nodogsplash', _('MAC Mechanism'));
|
||||
s = m.section(form.TypedSection, 'nodogsplash');
|
||||
s.anonymous = true;
|
||||
|
||||
o = s.option(form.ListValue, 'macmechanism', _("MAC Access Mechanism"), _("MAC addresses that are / are not allowed to access the splash page"));
|
||||
o.value('block', _("Block MACs"));
|
||||
o.value('allow', _("Allow MACs"));
|
||||
o.default = 'block';
|
||||
o.rmempty = false;
|
||||
o.editable = false;
|
||||
|
||||
s = m.section(form.TypedSection, 'nodogsplash', _('Clients'));
|
||||
s.anonymous = true;
|
||||
var ClientTable = form.DummyValue.extend({
|
||||
renderWidget: function(section_id, option_index, cfgvalue) {
|
||||
return table;
|
||||
}
|
||||
});
|
||||
o = s.option(ClientTable);
|
||||
|
||||
return m.render();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,109 @@
|
||||
'use strict';
|
||||
'require fs';
|
||||
'require ui';
|
||||
'require view';
|
||||
|
||||
return view.extend({
|
||||
nds_sep: 0,
|
||||
nds_clients: 0,
|
||||
|
||||
load: function() {
|
||||
return Promise.all([
|
||||
L.resolveDefault(fs.stat('/usr/bin/ndsctl'), null),
|
||||
]).then(function(stat) {
|
||||
var logger = stat[0] ? stat[0].path : null;
|
||||
|
||||
return fs.exec_direct(logger, [ 'status' ]).catch(function(err) {
|
||||
ui.addNotification(null, E('p', {}, _( err.message )));
|
||||
return '';
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
render_table: function(lines, start) {
|
||||
var table, idx, data, client = false;
|
||||
var pattern = /^Client \d+/;
|
||||
|
||||
var table = E('table', { 'class': 'table', 'id': 'status' });
|
||||
if (lines.length == 1) {
|
||||
table.appendChild(E('tr', { 'class': 'tr' }, [
|
||||
E('td', { 'class': 'td left' }, _("ndsctl: nodogsplash probably not started (Error: Connection refused)"))
|
||||
]));
|
||||
} else {
|
||||
for (var i = start; i < lines.length; i++) {
|
||||
if (lines[i].substring(0,3) == "===") {
|
||||
this.nds_sep = i + 1
|
||||
break
|
||||
}
|
||||
if (pattern.test(lines[i + 1]) || lines[i] == '') {
|
||||
if (this.nds_clients < this.nds_sep) {
|
||||
client = true;
|
||||
this.nds_clients = i + 1;
|
||||
}
|
||||
}
|
||||
if (!client) {
|
||||
data = lines[i].split(":")
|
||||
idx = data[0];
|
||||
data.shift();
|
||||
data = data.join(":").trim();
|
||||
if (data.substring(0,7) == "http://" || data.substring(0,8) == "https://") {
|
||||
data = E('a', { 'href': data, 'target': '_blank' }, data);
|
||||
}
|
||||
table.appendChild(E('tr', { 'class': 'tr' }, [
|
||||
E('td', { 'class': 'td left', 'width': '33%' }, _(idx)),
|
||||
E('td', { 'class': 'td left' }, data)
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return table;
|
||||
},
|
||||
|
||||
render_status: function(lines) {
|
||||
return E('div', { 'class': 'left' }, [
|
||||
E('h2', _('NoDogSplash Status')), this.render_table(lines, 3)
|
||||
]);
|
||||
},
|
||||
|
||||
render_client_summary: function(lines) {
|
||||
return E('div', { 'class': 'left' }, [
|
||||
E('h3', _('Clients List')), this.render_table(lines, this.nds_sep)
|
||||
]);
|
||||
},
|
||||
|
||||
render_mac_summary: function(lines) {
|
||||
return E('div', { 'class': 'left' }, [
|
||||
E('h3', _('Type of Clients')), this.render_table(lines, this.nds_sep)
|
||||
]);
|
||||
},
|
||||
|
||||
render_client_list: function(lines) {
|
||||
var s;
|
||||
if (this.nds_clients == 0)
|
||||
return '';
|
||||
var clients = [];
|
||||
var count = 1;
|
||||
while (this.nds_clients + 1 < this.nds_sep) {
|
||||
lines[ this.nds_clients + 1 ] = lines[ this.nds_clients + 1 ].trim().replace("MAC", "/ MAC");
|
||||
s = _("Client") + " " + count + " (" + lines[ this.nds_clients + 1 ].split("/")[1].trim() + ")";
|
||||
lines[ this.nds_clients + 1 ] = lines[ this.nds_clients + 1 ].split("/")[0];
|
||||
clients.push( E('h3', s), this.render_table(lines, this.nds_clients + 1) );
|
||||
count++;
|
||||
}
|
||||
return E('div', { 'class': 'left' }, clients);
|
||||
},
|
||||
|
||||
render: function(output) {
|
||||
var lines = output.trim().split(/\n/);
|
||||
return E('div', { 'class': 'cbi-map', 'id': 'map' }, [
|
||||
this.render_status(lines),
|
||||
this.render_client_summary(lines),
|
||||
this.render_client_list(lines),
|
||||
this.render_mac_summary(lines)
|
||||
]);
|
||||
},
|
||||
|
||||
handleSave: null,
|
||||
handleSaveApply: null,
|
||||
handleReset: null
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"admin/services/nodogsplash": {
|
||||
"title": "NoDogSplash",
|
||||
"action": {
|
||||
"type": "firstchild"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [
|
||||
"luci-app-nodogsplash"
|
||||
],
|
||||
"uci": {
|
||||
"nodogsplash": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"admin/services/nodogsplash/status": {
|
||||
"title": "Status",
|
||||
"order": 1,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "nodogsplash/status"
|
||||
}
|
||||
},
|
||||
"admin/services/nodogsplash/general": {
|
||||
"title": "General",
|
||||
"order": 11,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "nodogsplash/general"
|
||||
}
|
||||
},
|
||||
"admin/services/nodogsplash/mac": {
|
||||
"title": "MAC Filter",
|
||||
"order": 21,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "nodogsplash/mac"
|
||||
}
|
||||
},
|
||||
"admin/services/nodogsplash/firewall": {
|
||||
"title": "Firewall",
|
||||
"order": 31,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "nodogsplash/firewall"
|
||||
}
|
||||
},
|
||||
"admin/services/nodogsplash/advanced": {
|
||||
"title": "Advanced",
|
||||
"order": 41,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "nodogsplash/advanced"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"luci-app-nodogsplash": {
|
||||
"description": "Grant permissions for the AdGuard Home LuCI app",
|
||||
"read": {
|
||||
"uci": [
|
||||
"nodogsplash"
|
||||
],
|
||||
"file": {
|
||||
"/usr/bin/ndsctl": [
|
||||
"stat",
|
||||
"exec"
|
||||
],
|
||||
"/usr/bin/ndsctl status": [
|
||||
"exec"
|
||||
],
|
||||
"/usr/bin/ndsctl auth *": [
|
||||
"exec"
|
||||
],
|
||||
"/usr/bin/ndsctl deauth *": [
|
||||
"exec"
|
||||
],
|
||||
"/usr/bin/ndsctl block *": [
|
||||
"exec"
|
||||
],
|
||||
"/usr/bin/ndsctl unblock *": [
|
||||
"exec"
|
||||
],
|
||||
"/usr/bin/ndsctl allow *": [
|
||||
"exec"
|
||||
],
|
||||
"/usr/bin/ndsctl unallow *": [
|
||||
"exec"
|
||||
],
|
||||
"/usr/bin/ndsctl trust *": [
|
||||
"exec"
|
||||
],
|
||||
"/usr/bin/ndsctl untrust *": [
|
||||
"exec"
|
||||
],
|
||||
"/usr/bin/ndsctl json": [
|
||||
"exec"
|
||||
]
|
||||
}
|
||||
},
|
||||
"write": {
|
||||
"uci": [
|
||||
"nodogsplash"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user