Merge branch 'EntireTwix:main' into main

This commit is contained in:
Expand-sys 2022-12-11 11:16:34 +11:00 committed by GitHub
commit 19b6acc48f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 23 deletions

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
.vscode
build
ccash_config.hpp
deployment/.yamllint
deployment/.yamllint
config

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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 |
| 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 |

View file

@ -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.

View file

@ -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<uint32_t>::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<uint32_t>::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<uint32_t>::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<uint32_t>::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<uint32_t>::max()))
{
res = BankResponse{k400BadRequest, "\"Missing/Invalid JSON arg(s)\""};
}