Skip to content

Commit

Permalink
Merge branch 'development-v6' into tweak/domain_array
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Oct 14, 2023
2 parents d516aec + 6c3d45c commit 4020177
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
**In raising this issue, I confirm the following:** `{please fill the checkboxes, e.g: [X]}`

- [] I have read and understood the [contributors guide](https://github.com/pi-hole/AdminLTE/blob/master/CONTRIBUTING.md).
- [] I have read and understood the [contributors guide](https://github.com/pi-hole/web/blob/master/CONTRIBUTING.md).
- [] The issue I am reporting can be _replicated_.
- [] The issue I am reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/AdminLTE/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/AdminLTE/issues)).
- [] The issue I am reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/web/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/web/issues)).

**How familiar are you with the the source code relevant to this issue?:**

Expand Down
17 changes: 4 additions & 13 deletions login.lp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@
--]]

mg.include('scripts/pi-hole/lua/header.lp','r')

-- Build HTTPS upgrade link if HTTP is used
https_link = ""
if not is_secure then
https_link = "https://pi.hole" .. mg.request_info.request_uri
if mg.request_info.query_string then
https_link = https_link .. "?" .. mg.request_info.query_string
end
end
?>
<body class="hold-transition layout-boxed login-page">
<div class="box login-box" id="login-box">
Expand All @@ -35,13 +26,13 @@ end
<div class="text-center form-group has-error" id="dns-failure-label" style="display: none;">
<label>DNS Server failure detected, log in to see Pi-hole diagnosis messages</label>
</div>
<div class="text-center form-group has-error" id="dns-failure-label" style="display: <? if is_secure then ?>none<? else ?>block<? end ?>;">
<div class="box box-danger" id="insecure-box">
<div class="text-center form-group has-error" id="insecure-box" style="display: none;">
<div class="box box-danger">
<div class="box-header with-border pointer no-user-select">
<h3 class="box-title has-error control-label"><i class="fa fa-fw fa-triangle-exclamation"></i>&nbsp;&nbsp;Insecure network connection&nbsp;&nbsp;<i class="fa fa-fw fa-triangle-exclamation"></i></h3>
</div>
<div class="box-body">
<p>Consider upgrading to <a href="<?=https_link?>">HTTPS</a> (end-to-end encryption)</p>
<p>Consider upgrading to <a href="#" id="https-link">HTTPS</a> (end-to-end encryption)</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -89,7 +80,7 @@ end
a new password (or explicitly disable the password by setting an empty password)
using the command
</p>
<pre>sudo pihole -a -p</pre>
<pre>sudo pihole setpassword</pre>
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"description": "",
"repository": {
"type": "git",
"url": "git+https://github.com/pi-hole/AdminLTE.git"
"url": "git+https://github.com/pi-hole/web.git"
},
"keywords": [],
"author": "",
"license": "EUPL-1.2",
"bugs": {
"url": "https://github.com/pi-hole/AdminLTE/issues"
"url": "https://github.com/pi-hole/web/issues"
},
"homepage": "https://github.com/pi-hole/AdminLTE#readme",
"homepage": "https://github.com/pi-hole/web#readme",
"scripts": {
"prefix": "postcss \"style/*.css\" \"style/themes/*.css\" --use autoprefixer --no-map --replace",
"prettier:check": "prettier -l \"style/*.css\" \"style/themes/*.css\" \"scripts/pi-hole/**/*.js\"",
Expand Down
29 changes: 24 additions & 5 deletions scripts/pi-hole/js/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ function piholeChange(action, duration) {
$.ajax({
url: "/api/dns/blocking",
method: "POST",
dataType: "json",
processData: false,
data: JSON.stringify({
blocking: action === "enable",
timer: parseInt(duration, 10) > 0 ? parseInt(duration, 10) : null,
Expand Down Expand Up @@ -474,6 +476,7 @@ function updateVersionInfo() {
remote: version.core.remote.version,
branch: version.core.local.branch,
hash: version.core.local.hash,
hash_remote: version.core.remote.hash,
url: "https://github.com/pi-hole/pi-hole/releases",
},
{
Expand All @@ -482,6 +485,7 @@ function updateVersionInfo() {
remote: version.ftl.remote.version,
branch: version.ftl.local.branch,
hash: version.ftl.local.hash,
hash_remote: version.ftl.remote.hash,
url: "https://github.com/pi-hole/FTL/releases",
},
{
Expand All @@ -490,7 +494,8 @@ function updateVersionInfo() {
remote: version.web.remote.version,
branch: version.web.local.branch,
hash: version.web.local.hash,
url: "https://github.com/pi-hole/AdminLTE/releases",
hash_remote: version.web.remote.hash,
url: "https://github.com/pi-hole/web/releases",
},
];

Expand All @@ -508,11 +513,25 @@ function updateVersionInfo() {
'" rel="noopener" target="_blank">' +
localVersion +
"</a>";
} else localVersion = "vDev (" + v.branch + ", " + v.hash + ")";
if (versionCompare(v.local, v.remote) === -1) {
// Update available
updateAvailable = true;
}
} else {
// non-master branch
localVersion = "vDev (" + v.branch + ", " + v.hash + ")";
if (v.hash !== v.hash_remote) {
// hash differ > Update available
updateAvailable = true;
}
}

if (v.name === "Docker Tag" && versionCompare(v.local, v.remote) === -1) {
updateAvailable = true;
dockerUpdate = true;
}

if (versionCompare(v.local, v.remote) === -1) {
if (v.name === "Docker Tag") dockerUpdate = true;
else updateAvailable = true;
if (updateAvailable) {
$("#versions").append(
"<li><strong>" +
v.name +
Expand Down
27 changes: 24 additions & 3 deletions scripts/pi-hole/js/gravity.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function eventsource() {
return reader.read().then(({ done, value }) => {
// When no more data needs to be consumed, close the stream
if (done) {
ta.append("Done.");
controller.close();
alInfo.hide();
$("#gravityBtn").prop("disabled", false);
Expand All @@ -47,9 +48,8 @@ function eventsource() {
// Enqueue the next data chunk into our target stream
controller.enqueue(value);
var string = new TextDecoder().decode(value);
// Remove ${OVER} from the string
string = string.replaceAll("\r", "\n");
ta.append(string);
parseLines(ta, string);

if (string.indexOf("Pi-hole blocking is") !== -1) {
alSuccess.show();
}
Expand Down Expand Up @@ -84,3 +84,24 @@ $(function () {
eventsource();
}
});

function parseLines(ta, str) {
// str can contain multiple lines.
// We want to split the text before an "OVER" escape sequence to allow overwriting previous line when needed

// Splitting the text on "\r"
var lines = str.split(/(?=\r)/g);

for (let i = 0; i < lines.length; i++) {
if (lines[i][0] === "\r") {
// This line starts with the "OVER" sequence. Replace them with "\n" before print
lines[i] = lines[i].replaceAll("\r", "\n").replaceAll("\r", "\n");

// Last line from the textarea will be overwritten, so we remove it
ta.text(ta.text().substring(0, ta.text().lastIndexOf("\n")));
}

// Append the new text to the end of the output
ta.append(lines[i]);
}
}
2 changes: 2 additions & 0 deletions scripts/pi-hole/js/groups-adlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ function addAdlist(event) {
url: "/api/lists",
method: "post",
dataType: "json",
processData: false,
data: JSON.stringify({ address: addresses, comment: comment, type: type }),
success: function (data) {
utils.enableAll();
Expand Down Expand Up @@ -590,6 +591,7 @@ function editAdlist() {
url: "/api/lists/" + encodeURIComponent(addressDecoded),
method: "put",
dataType: "json",
processData: false,
data: JSON.stringify({
groups: groups,
comment: comment,
Expand Down
2 changes: 2 additions & 0 deletions scripts/pi-hole/js/groups-clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ function addClient() {
url: "/api/clients",
method: "post",
dataType: "json",
processData: false,
data: JSON.stringify({ client: ips, comment: comment }),
success: function (data) {
utils.enableAll();
Expand Down Expand Up @@ -508,6 +509,7 @@ function editClient() {
url: "/api/clients/" + encodeURIComponent(clientDecoded),
method: "put",
dataType: "json",
processData: false,
data: JSON.stringify({
client: client,
groups: groups,
Expand Down
2 changes: 2 additions & 0 deletions scripts/pi-hole/js/groups-domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ function addDomain() {
url: "/api/domains/" + type + "/" + kind,
method: "post",
dataType: "json",
processData: false,
data: JSON.stringify({
domain: domains,
comment: comment,
Expand Down Expand Up @@ -617,6 +618,7 @@ function editDomain() {
url: "/api/domains/" + newTypestr + "/" + encodeURIComponent(domainDecoded),
method: "put",
dataType: "json",
processData: false,
data: JSON.stringify({
groups: groups,
comment: comment,
Expand Down
2 changes: 2 additions & 0 deletions scripts/pi-hole/js/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ function addGroup() {
url: "/api/groups",
method: "post",
dataType: "json",
processData: false,
data: JSON.stringify({
name: names,
comment: comment,
Expand Down Expand Up @@ -371,6 +372,7 @@ function editGroup() {
url: "/api/groups/" + oldName,
method: "put",
dataType: "json",
processData: false,
data: JSON.stringify({
name: name,
comment: comment,
Expand Down
18 changes: 18 additions & 0 deletions scripts/pi-hole/js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function doLogin(password) {
$.ajax({
url: "/api/auth",
method: "POST",
dataType: "json",
processData: false,
data: JSON.stringify({ password: password, totp: parseInt($("#totp").val(), 10) }),
})
.done(function () {
Expand Down Expand Up @@ -112,7 +114,23 @@ $(function () {
}).done(function (data) {
if (data.session.valid === true) redirect();
if (data.session.totp === true) $("#totp_input").removeClass("hidden");
});

// Get information about HTTPS port and DNS status
$.ajax({
url: "/api/info/login",
}).done(function (data) {
if (data.dns === false) showDNSfailure();

// Generate HTTPS redirection link (only used if not already HTTPS)
if (location.protocol !== "https:" && data.https_port !== 0) {
let url = "https://" + location.hostname;
if (data.https_port !== 443) url += ":" + data.https_port;
url += location.pathname + location.search + location.hash;

$("#https-link").attr("href", url);
$("#insecure-box").show();
}
});

// Clear TOTP field
Expand Down
2 changes: 2 additions & 0 deletions scripts/pi-hole/js/settings-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ function setTOTPSecret(secret) {
$.ajax({
url: "/api/config",
type: "PATCH",
dataType: "json",
processData: false,
data: JSON.stringify({ config: { webserver: { api: { totp_secret: secret } } } }),
contentType: "application/json",
})
Expand Down
2 changes: 2 additions & 0 deletions scripts/pi-hole/js/settings-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ $("#loggingButton").confirm({
$.ajax({
url: "/api/config/dns/queryLogging",
type: "PATCH",
dataType: "json",
processData: false,
data: JSON.stringify(data),
})
.done(function (data) {
Expand Down
2 changes: 2 additions & 0 deletions scripts/pi-hole/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ function saveSettings() {
$.ajax({
url: "/api/config",
method: "PATCH",
dataType: "json",
processData: false,
data: JSON.stringify({ config: settings }),
contentType: "application/json; charset=utf-8",
})
Expand Down
1 change: 1 addition & 0 deletions scripts/pi-hole/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ function addFromQueryLog(domain, list) {
url: "/api/domains/" + list + "/exact",
method: "post",
dataType: "json",
processData: false,
data: JSON.stringify({
domain: domain,
comment: "Added from Query Log",
Expand Down
4 changes: 2 additions & 2 deletions settings-api.lp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PageTitle = "Web Interface - API Settings"
mg.include('scripts/pi-hole/lua/settings_header.lp','r')
?>
<div class="row">
<div class="col-md-6 settings-level-1">
<div class="col-md-6 settings-level-0">
<div class="row">
<div class="col-md-12 settings-level-1">
<div class="box box-warning">
Expand Down Expand Up @@ -143,7 +143,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-12 settings-level-2">
<div class="box box-warning">
<div class="box-header with-border">
<h3 class="box-title">Currently active sessions</h3>
Expand Down

0 comments on commit 4020177

Please sign in to comment.