External IP Lookup Disable Feature implemented with environment variable: DISABLE_EXTERNAL_IP_LOOKUP

This commit is contained in:
2026-01-14 19:13:46 +01:00
parent 5d52fbcba9
commit e997059e2a
4 changed files with 35 additions and 3 deletions

View File

@@ -1118,9 +1118,14 @@ func shouldAlertForCountry(country string, alertCountries []string) bool {
// IndexHandler serves the HTML page
func IndexHandler(c *gin.Context) {
// Check if external IP lookup is disabled via environment variable
// Default is enabled (false means enabled, true means disabled)
disableExternalIP := os.Getenv("DISABLE_EXTERNAL_IP_LOOKUP") == "true" || os.Getenv("DISABLE_EXTERNAL_IP_LOOKUP") == "1"
c.HTML(http.StatusOK, "index.html", gin.H{
"timestamp": time.Now().Format(time.RFC1123),
"version": time.Now().Unix(),
"timestamp": time.Now().Format(time.RFC1123),
"version": time.Now().Unix(),
"disableExternalIP": disableExternalIP,
})
}

View File

@@ -3,7 +3,10 @@
window.addEventListener('DOMContentLoaded', function() {
showLoading(true);
displayExternalIP();
// Only display external IP if the element exists (not disabled via template variable)
if (document.getElementById('external-ip')) {
displayExternalIP();
}
// Initialize header components (clock and status indicator)
if (typeof initHeader === 'function') {

View File

@@ -116,10 +116,12 @@
</div>
<div class="flex flex-col sm:flex-row sm:items-center gap-3">
<div id="serverSelectorContainer" class="min-w-[220px]"></div>
{{if not .disableExternalIP}}
<div class="text-sm text-gray-500 sm:ml-2">
<span data-i18n="dashboard.external_ip">Your ext. IP:</span>
<span id="external-ip" class="font-medium text-blue-600 hover:underline cursor-pointer">Loading…</span>
</div>
{{end}}
<div class="flex flex-col sm:flex-row gap-3">
<button class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600 transition-colors flex items-center gap-2"
onclick="openServerManager()">