Docs, small fixes

This commit is contained in:
jokob-sk
2025-01-11 20:20:09 +11:00
parent 74c6faccc7
commit 6ad90610ea
6 changed files with 72 additions and 35 deletions

View File

@@ -22,7 +22,7 @@ If direct scans are not possible (Wi-Fi Extenders, VPNs and inaccessible network
* **Examples for one and two subnets:**
* One subnet: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0']`
* Two subnets: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0','192.168.1.0/24 --interface=eth1 -vlan=107']`
* Two subnets: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0','192.168.1.0/24 --interface=eth1 --vlan=107']`
If you get timeout messages, decrease the network mask (e.g.: from `/16` to `/24`) or increase the `TIMEOUT` setting (e.g.: `ARPSCAN_RUN_TIMEOUT` to `300` (5-minute timeout)) for the plugin and the interval between scans (e.g.: `ARPSCAN_RUN_SCHD` to `*/10 * * * *` (scans every 10 minutes)).
@@ -89,7 +89,6 @@ By default, Hyper-V only allows untagged packets through to the VM interface, bl
2. Within the VM, set up sub-interfaces for each VLAN to enable scanning. On Ubuntu 22.04, Netplan can be used. In /etc/netplan/00-installer-config.yaml, add VLAN definitions:
```yaml
network:
ethernets:
eth0:

View File

@@ -201,8 +201,17 @@ function mapIndx(oldIndex)
// Query total numbers of Devices by status
//------------------------------------------------------------------------------
function getDevicesTotals() {
maxDelay = 180; //cap at 180 seconds
// Fetch data via AJAX
let maxRetries = Math.ceil(Math.log2(maxDelay)); // Calculate maximum retries to cap at maxDelay seconds
let attempt = 0;
let calledUpdateAPI = false;
function fetchDataWithBackoff() {
// Calculate the delay (2^attempt seconds, capped at maxDelay seconds)
const delay = Math.min(2 ** attempt, maxDelay) * 1000;
// Attempt to fetch data
$.ajax({
url: '/php/server/query_json.php',
type: "GET",
@@ -213,7 +222,7 @@ function getDevicesTotals() {
},
success: function(response) {
if (response && response.data) {
resultJSON = response.data[0]; // Assuming the structure {"data": [ ... ]}
const resultJSON = response.data[0]; // Assuming the structure {"data": [ ... ]}
// Save the result to cache
setCache("getDevicesTotals", JSON.stringify(resultJSON));
@@ -225,11 +234,28 @@ function getDevicesTotals() {
}
},
error: function(xhr, status, error) {
console.error("Failed to fetch devices data:", error);
console.error("Failed to fetch devices data (Attempt " + (attempt + 1) + "):", error);
// try updating the API once
if(calledUpdateAPI == false)
{
calledUpdateAPI = true;
updateApi("devices_tiles");
}
// Retry logic
if (attempt < maxRetries) {
attempt++;
setTimeout(fetchDataWithBackoff, delay);
} else {
console.error("Maximum retries reached. Unable to fetch devices data.");
}
}
});
}
// Start the first fetch attempt
fetchDataWithBackoff();
}
function processDeviceTotals(devicesData) {

View File

@@ -10,8 +10,12 @@
//------------------------------------------------------------------------------
// DB File Path
$DBFILE = dirname(__FILE__).'/../../../db/app.db';
$DBFILE_LOCKED_FILE = dirname(__FILE__).'/../../../log/db_is_locked.log';
// $DBFILE = dirname(__FILE__).'/../../../db/app.db';
// $DBFILE_LOCKED_FILE = dirname(__FILE__).'/../../../log/db_is_locked.log';
$scriptDir = realpath(dirname(__FILE__)); // Resolves symlinks to the actual physical path
$DBFILE = $scriptDir . '/../../../db/app.db';
$DBFILE_LOCKED_FILE = $scriptDir . '/../../../log/db_is_locked.log';
//------------------------------------------------------------------------------
// check if authenticated
@@ -32,6 +36,14 @@ function SQLite3_connect($trytoreconnect = true, $retryCount = 0) {
global $db_locked;
$db_locked = false;
if (!file_exists($DBFILE)) {
die("Database file not found: $DBFILE");
}
if (!file_exists(dirname($DBFILE_LOCKED_FILE))) {
die("Log directory not found: " . dirname($DBFILE_LOCKED_FILE));
}
// Write unlock status to the locked file
file_put_contents($DBFILE_LOCKED_FILE, '0');
@@ -70,7 +82,7 @@ class CustomDatabaseWrapper {
private $maxRetries;
private $retryDelay;
public function __construct($filename, $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $maxRetries = 10, $retryDelay = 1000, $encryptionKey = null) {
public function __construct($filename, $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $maxRetries = 3, $retryDelay = 1000, $encryptionKey = null) {
$this->sqlite = new SQLite3($filename, $flags, $encryptionKey);
$this->maxRetries = $maxRetries;
$this->retryDelay = $retryDelay;
@@ -116,7 +128,7 @@ class CustomDatabaseWrapper {
file_put_contents($DBFILE_LOCKED_FILE, '0');
$message = 'Error executing query (attempts: ' . $attempts . '), query: ' . $query;
write_notification($message);
// write_notification($message);
error_log("Query failed after {$this->maxRetries} attempts: " . $this->sqlite->lastErrorMsg());
}

View File

@@ -1,7 +1,7 @@
{
"API_CUSTOM_SQL_description": "You can specify a custom SQL query which will generate a JSON file and then expose it via the <a href=\"/api/table_custom_endpoint.json\" target=\"_blank\"><code>table_custom_endpoint.json</code> file endpoint</a>.",
"API_CUSTOM_SQL_name": "Custom endpoint",
"API_TOKEN_description": "API token for secure communication. Generate one or enter any value. It's sent in the request header and used in the <code>SYNC</code> plugin, GraphQL server and other API endpoints. You can use the API endpoints to create custom integrations as descibed in the a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">API documentation</a>.",
"API_TOKEN_description": "API token for secure communication. Generate one or enter any value. It's sent in the request header and used in the <code>SYNC</code> plugin, GraphQL server and other API endpoints. You can use the API endpoints to create custom integrations as descibed in the <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">API documentation</a>.",
"API_TOKEN_name": "API token",
"API_display_name": "API",
"API_icon": "<i class=\"fa fa-arrow-down-up-across-line\"></i>",

2
front/php/templates/language/it_it.json Normal file → Executable file
View File

@@ -1,7 +1,7 @@
{
"API_CUSTOM_SQL_description": "Puoi specificare una query SQL personalizzata che genererà un file JSON e quindi lo esporrà tramite l'<a href=\"/api/table_custom_endpoint.json\" target=\"_blank\"><code>table_custom_endpoint.json</code>endpoint del file</a>.",
"API_CUSTOM_SQL_name": "Endpoint personalizzato",
"API_TOKEN_description": "Token API per comunicazioni sicure. Generane uno o inserisci un valore qualsiasi. Viene inviato nell'intestazione della richiesta e utilizzato nel plugin <code>SYNC</code>, nel server GraphQL e in altri endpoint API. Puoi utilizzare gli endpoint API per creare integrazioni personalizzate come descritto nella a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">documentazione API</a>.",
"API_TOKEN_description": "Token API per comunicazioni sicure. Generane uno o inserisci un valore qualsiasi. Viene inviato nell'intestazione della richiesta e utilizzato nel plugin <code>SYNC</code>, nel server GraphQL e in altri endpoint API. Puoi utilizzare gli endpoint API per creare integrazioni personalizzate come descritto nella <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">documentazione API</a>.",
"API_TOKEN_name": "Token API",
"API_display_name": "API",
"API_icon": "<i class=\"fa fa-arrow-down-up-across-line\"></i>",

View File

@@ -1,7 +1,7 @@
{
"API_CUSTOM_SQL_description": "Вы можете указать собственный SQL-запрос, который будет генерировать файл JSON, а затем предоставлять его через конечную точку файла <a href=\"/api/table_custom_endpoint.json\" target=\"_blank\"><code>table_custom_endpoint.json</code></a>.",
"API_CUSTOM_SQL_name": "Пользовательская конечная точка",
"API_TOKEN_description": "API-токен для безопасной связи. Сгенерируйте его или введите любое значение. Он передается в заголовке запроса и используется в плагине <code>SYNC</code>, сервере GraphQL и других конечных точках API. Вы можете использовать конечные точки API для создания пользовательских интеграций, как описано в a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">документации по API</a>.",
"API_TOKEN_description": "API-токен для безопасной связи. Сгенерируйте его или введите любое значение. Он передается в заголовке запроса и используется в плагине <code>SYNC</code>, сервере GraphQL и других конечных точках API. Вы можете использовать конечные точки API для создания пользовательских интеграций, как описано в <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">документации по API</a>.",
"API_TOKEN_name": "API token",
"API_display_name": "API",
"API_icon": "<i class=\"fa fa-arrow-down-up-across-line\"></i>",