2026-02-15 22:49:32 +01:00
|
|
|
// API helpers for Fail2ban UI.
|
|
|
|
|
"use strict";
|
2025-12-05 14:30:28 +01:00
|
|
|
|
2026-02-15 22:49:32 +01:00
|
|
|
// =========================================================================
|
|
|
|
|
// Server-Scoped Requests
|
|
|
|
|
// =========================================================================
|
|
|
|
|
|
|
|
|
|
// Adds the server ID to the URL if a server is selected.
|
2025-12-05 14:30:28 +01:00
|
|
|
function withServerParam(url) {
|
|
|
|
|
if (!currentServerId) {
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
return url + (url.indexOf('?') === -1 ? '?' : '&') + 'serverId=' + encodeURIComponent(currentServerId);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-15 22:49:32 +01:00
|
|
|
// Adds the server ID to the headers if a server is selected.
|
2025-12-05 14:30:28 +01:00
|
|
|
function serverHeaders(headers) {
|
|
|
|
|
headers = headers || {};
|
|
|
|
|
if (currentServerId) {
|
|
|
|
|
headers['X-F2B-Server'] = currentServerId;
|
|
|
|
|
}
|
|
|
|
|
return headers;
|
|
|
|
|
}
|