mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
004fb93bbe
Signed-off-by: DL6ER <dl6er@dl6er.de>
45 lines
1.3 KiB
C
45 lines
1.3 KiB
C
/* Pi-hole: A black hole for Internet advertisements
|
|
* (c) 2019 Pi-hole, LLC (https://pi-hole.net)
|
|
* Network-wide ad blocking via your own hardware.
|
|
*
|
|
* FTL Engine
|
|
* API Implementation /api/settings
|
|
*
|
|
* This file is copyright under the latest version of the EUPL.
|
|
* Please see LICENSE file for your rights under this license. */
|
|
|
|
#include "FTL.h"
|
|
#include "api.h"
|
|
// get_FTL_db_filesize()
|
|
#include "files.h"
|
|
// get_sqlite3_version()
|
|
#include "database/common.h"
|
|
// get_number_of_queries_in_DB()
|
|
#include "database/query-table.h"
|
|
|
|
int api_settings_web(struct mg_connection *conn)
|
|
{
|
|
cJSON *json = JSON_NEW_OBJ();
|
|
JSON_OBJ_REF_STR(json, "layout", "boxed");
|
|
JSON_OBJ_REF_STR(json, "language", "en");
|
|
JSON_SENT_OBJECT(json);
|
|
}
|
|
|
|
int api_settings_ftldb(struct mg_connection *conn)
|
|
{
|
|
// Verify requesting client is allowed to see this ressource
|
|
if(check_client_auth(conn) < 0)
|
|
{
|
|
cJSON *json = JSON_NEW_OBJ();
|
|
JSON_OBJ_REF_STR(json, "key", "unauthorized");
|
|
JSON_SENT_OBJECT_CODE(json, 401);
|
|
}
|
|
|
|
cJSON *json = JSON_NEW_OBJ();
|
|
const int db_filesize = get_FTL_db_filesize();
|
|
JSON_OBJ_ADD_NUMBER(json, "filesize", db_filesize);
|
|
const int queries_in_database = get_number_of_queries_in_DB();
|
|
JSON_OBJ_ADD_NUMBER(json, "queries", queries_in_database);
|
|
JSON_OBJ_REF_STR(json, "sqlite_version", get_sqlite3_version());
|
|
JSON_SENT_OBJECT(json);
|
|
} |