diff --git a/.gitignore b/.gitignore index 3b6968c..84c2ce7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode build ccash_config.hpp -deployment/.yamllint \ No newline at end of file +deployment/.yamllint +config \ No newline at end of file diff --git a/docs/FAQ.md b/docs/FAQ.md index 74de59d..ae023b1 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -20,16 +20,20 @@ #### A : Because this usecase requires none of the features a database would offer. -#### Q : People are making too many accounts/transactions maliciously to fill up space on my server! +#### Q : People are making too many accounts maliciously to fill up space on my server! #### A : Consider disabling `ADD_USER_OPEN` in the [build proccess](https://github.com/EntireTwix/CCash/blob/main/docs/building.md). +#### Q : People are making too many transactions filling up space on my server! +#### A : Consider setting the variable `MAX_LOG_SIZE` to 0 in the [build proccess](https://github.com/EntireTwix/CCash/blob/main/docs/building.md). + + #### Q : My instance is taking up too much RAM -#### A : If your memory usage is too high I would reduce log size. +#### A : Reduce log size. #### Q : My instance is taking up too much disk spac -#### A : Use the purge users endpoint to delete old or superfluous accounts or reducing log size will reduce disk space but should be a last resort. +#### A : Use the prune users endpoint to dead accounts or you can reduce log size but should be a last resort. #### Q : My instance is slow diff --git a/docs/building.md b/docs/building.md index c3a95e0..b9248c3 100644 --- a/docs/building.md +++ b/docs/building.md @@ -8,6 +8,7 @@ as CCash is very lightweight it can run on practically any device but here are s * `MAX_LOG_SIZE` should be adjusted as it takes up the most memory usage/storage of the ledger's features at ~203 bytes in memory and ~104 bytes in disk at default settings, so 5165 logs per Mb of RAM. Setting to 0 will disable logs * with no users memory usage is 8.47 Mb * Saving frequency (a runtime argument) being set to 0 will disable frequency saving and only save on close +* make backups of your save files ## Docker If you want to use the docker package, deploy information can be found [here](deploy.md) diff --git a/docs/connected_services/how_to/APIs.md b/docs/connected_services/how_to/APIs.md index aab2909..65d189d 100644 --- a/docs/connected_services/how_to/APIs.md +++ b/docs/connected_services/how_to/APIs.md @@ -5,7 +5,7 @@ | [SpaceCat](https://github.com/SpaceCat-Chan) | CCLua | [CatsCCashLuaApi](https://github.com/SpaceCat-Chan/CatsCCashLuaApi) | :heavy_check_mark: | | [Luke](https://github.com/LukeeeeBennett/ccash-client-js) | JS | [ccash client js](https://github.com/LukeeeeBennett/ccash-client-js) | :heavy_multiplication_x: | | [Doggo](https://github.com/FearlessDoggo21) | Python | [CCashPythonClient](https://github.com/FearlessDoggo21/CCashPythonClient) | :heavy_check_mark: | -| [Sam](https://github.com/STBoyden) | Rust | [ccash rs](https://git.stboyden.com/STBoyden/ccash-rs) | :heavy_check_mark: | +| [Sam](https://github.com/STBoyden) | Rust | [ccash rs](https://github.com/STBoyden/ccash-rs) | :heavy_check_mark: | for example here is a demo program for the lua API by SpaceCat diff --git a/docs/contributors.md b/docs/contributors.md index d0e0250..10b4260 100644 --- a/docs/contributors.md +++ b/docs/contributors.md @@ -1,10 +1,10 @@ # Contributors -| name | work | -| :------------------------------------------- | ---------------------------- | -| [Luke](https://github.com/LukeeeeBennett) | Docker package, JS API | -| [React](https://github.com/Reactified) | Logo, deprecated CCLua API | -| [Doggo](https://github.com/FearlessDoggo21) | HTTP suggestions, Python API | -| [SpaceCat](https://github.com/SpaceCat-Chan) | CCLua API | -| [Expand](https://github.com/Expand-sys) | Fixed docker package | -| [Sam](https://github.com/STBoyden) | Rust API | -| Caesay | Restful API suggestions | \ No newline at end of file +| name | work | +| :------------------------------------------- | ---------------------------------- | +| [Luke](https://github.com/LukeeeeBennett) | Github Actions, and JS API | +| [React](https://github.com/Reactified) | Logo, CC Wallet/Shop/ATM | +| [Doggo](https://github.com/FearlessDoggo21) | HTTP advice, Python API, and C CLI | +| [SpaceCat](https://github.com/SpaceCat-Chan) | CCLua API | +| [Expand](https://github.com/Expand-sys) | Docker, and Ansible | +| [Sam](https://github.com/STBoyden) | Rust API | +| Caesay | Restful API advice | \ No newline at end of file diff --git a/docs/features/user_side.md b/docs/features/user_side.md index 7397267..1a1513d 100644 --- a/docs/features/user_side.md +++ b/docs/features/user_side.md @@ -19,7 +19,7 @@ as explained in earlier docs a ecosystem of connected services allows you many w #### APIs for devs who wanna make more connected services, existing APIs exist in multiple lanaguages enabling faster development/maintenance. #### External -its game indepedent meaning you dont have to be in-game to use it. +its game indepedent meaning you dont have to be in-game to use it. With support for Docker and Ansible Playbook. ## Security #### HTTPS OpenSSL is used to secure the HTTP server. diff --git a/src/bank_api.cpp b/src/bank_api.cpp index 9e69c33..24e7c99 100644 --- a/src/bank_api.cpp +++ b/src/bank_api.cpp @@ -1,5 +1,7 @@ #include "bank_api.h" +// TODO: parser iterate(input).get(doc) error handling might be superfulous + #define CACHE_FOREVER resp->setExpiredTime(0) #define CORS resp->addHeader("Access-Control-Allow-Origin", "*") @@ -51,8 +53,8 @@ void api::SendFunds(req_args) else { std::string_view name; - uint64_t amount; // simdjson lacks .get(uint32_t support) - if (doc["name"].get(name) || doc["time"].get(amount)) + uint64_t amount; // as simdjson lacks .get(uint32_t support) + if (doc["name"].get(name) || doc["amount"].get(amount) || (amount > std::numeric_limits::max())) { res = BankResponse{k400BadRequest, "\"Missing/Invalid JSON arg(s)\""}; } @@ -132,10 +134,10 @@ void api::SetBal(req_args) res = BankResponse{k400BadRequest, "\"Invalid JSON\""}; } else - { + { std::string_view name; uint64_t amount; - if (doc["name"].get(name) || doc["time"].get(amount)) + if (doc["name"].get(name) || doc["amount"].get(amount) || (amount > std::numeric_limits::max())) { res = BankResponse{k400BadRequest, "\"Missing/Invalid JSON arg(s)\""}; } @@ -159,7 +161,7 @@ void api::ImpactBal(req_args) { std::string_view name; int64_t amount; - if (doc["name"].get(name) || doc["time"].get(amount)) + if (doc["name"].get(name) || doc["amount"].get(amount)) { res = BankResponse{k400BadRequest, "\"Missing/Invalid JSON arg(s)\""}; } @@ -231,7 +233,7 @@ void api::PruneUsers(req_args) #if MAX_LOG_SIZE > 0 int64_t time; uint64_t amount; - if (doc["time"].get(time) || doc["time"].get(amount)) + if (doc["time"].get(time) || doc["amount"].get(amount) || (amount > std::numeric_limits::max())) { res = BankResponse{k400BadRequest, "\"Missing/Invalid JSON arg(s)\""}; } @@ -241,7 +243,7 @@ void api::PruneUsers(req_args) } #else uint64_t amount - if (doc["time"].get(amount)) + if (doc["amount"].get(amount) || (amount > std::numeric_limits::max())) { res = BankResponse{k400BadRequest, "\"Missing/Invalid JSON arg(s)\""}; } @@ -301,7 +303,7 @@ void api::AdminAddUser(req_args) std::string_view name; uint64_t amount; std::string_view pass; - if (doc["name"].get(name) || doc["time"].get(amount) || doc["time"].get(pass)) + if (doc["name"].get(name) || doc["amount"].get(amount) || doc["time"].get(pass) || (amount > std::numeric_limits::max())) { res = BankResponse{k400BadRequest, "\"Missing/Invalid JSON arg(s)\""}; }