🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

@@ -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
});