diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 65726b0b..89b009ec 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -714,6 +714,7 @@ function addAdvancedInfo() { const advancedInfoTarget = $("#advanced-info"); const isTLS = advancedInfoSource.data("tls"); const clientIP = advancedInfoSource.data("client-ip"); + const XForwardedFor = atob(advancedInfoSource.data("xff")); const starttime = parseFloat(advancedInfoSource.data("starttime")); const endtime = parseFloat(advancedInfoSource.data("endtime")); const totaltime = 1e3 * (endtime - starttime); @@ -727,11 +728,18 @@ function addAdvancedInfo() { (isTLS ? "" : "-open") + '" title="Your connection is ' + (isTLS ? "" : "NOT ") + - 'end-to-end encrypted (TLS/SSL)"> ' + - clientIP + - "
" + 'end-to-end encrypted (TLS/SSL)"> 
' ); + // Add client IP info + $("#client-id").text(XForwardedFor ? XForwardedFor : clientIP); + if (XForwardedFor) { + // If X-Forwarded-For is set, show the X-Forwarded-For in italics and add + // the real client IP as tooltip + $("#client-id").css("font-style", "italic"); + $("#client-id").prop("title", "Original remote address: " + clientIP); + } + // Add render time info advancedInfoTarget.append( "Render time: " + (totaltime > 0.5 ? totaltime.toFixed(1) : totaltime.toFixed(3)) + " ms" diff --git a/scripts/pi-hole/lua/footer.lp b/scripts/pi-hole/lua/footer.lp index 3be0b1d9..e0b52ced 100644 --- a/scripts/pi-hole/lua/footer.lp +++ b/scripts/pi-hole/lua/footer.lp @@ -6,6 +6,16 @@ * This file is copyright under the latest version of the EUPL. * Please see LICENSE file for your rights under this license. * ]]-- + +-- Iterate over the array mg.request_info.http_headers and check if there is an 'X-Forwarded-For' header +x_forwarded_for = "" +local headers = mg.request_info.http_headers +for k,v in pairs(headers) do + if k:lower() == "x-forwarded-for" then + x_forwarded_for = v + break + end +end ?> @@ -59,6 +69,6 @@ - +