mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-17 08:32:13 +11:00
commit
d71d74678e
5 changed files with 46 additions and 26 deletions
|
|
@ -67,6 +67,12 @@ else()
|
||||||
set(MULTI_THREADED_VAL true)
|
set(MULTI_THREADED_VAL true)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED ADD_USER_OPEN)
|
||||||
|
set(ADD_USER_OPEN_VAL ${ADD_USER_OPEN})
|
||||||
|
else()
|
||||||
|
set(ADD_USER_OPEN_VAL true)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(DEFINED RETURN_ON_DEL_NAME)
|
if(DEFINED RETURN_ON_DEL_NAME)
|
||||||
set(RETURN_ON_DEL_VAL true)
|
set(RETURN_ON_DEL_VAL true)
|
||||||
set(RETURN_ON_DEL_NAME_VAL "\"" + ${RETURN_ON_DEL_NAME} + "\"")
|
set(RETURN_ON_DEL_NAME_VAL "\"" + ${RETURN_ON_DEL_NAME} + "\"")
|
||||||
|
|
|
||||||
|
|
@ -38,3 +38,5 @@ etc
|
||||||
#define API_VERSION 1
|
#define API_VERSION 1
|
||||||
|
|
||||||
#define MULTI_THREADED @MULTI_THREADED_VAL@
|
#define MULTI_THREADED @MULTI_THREADED_VAL@
|
||||||
|
|
||||||
|
#define ADD_USER_OPEN @ADD_USER_OPEN_VAL@
|
||||||
|
|
@ -67,13 +67,14 @@ cp ../config/config.json config.json
|
||||||
### CMake Flags
|
### CMake Flags
|
||||||
there are multiple flags responsible configuring CCash:
|
there are multiple flags responsible configuring CCash:
|
||||||
| name | default | description | pros | cons |
|
| name | default | description | pros | cons |
|
||||||
| :--------------------- | :--------------: | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -------------------------------------------------------- |
|
| :--------------------- | :-----------: | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -------------------------------------------------------- |
|
||||||
| USER_SAVE_LOC | "users.dat" | where the users are saved | `N/A` | `N/A` |
|
| USER_SAVE_LOC | "users.dat" | where the users are saved | `N/A` | `N/A` |
|
||||||
| DROGON_CONFIG_LOC | "config.json" | where the config is located | `N/A` | `N/A` |
|
| DROGON_CONFIG_LOC | "config.json" | where the config is located | `N/A` | `N/A` |
|
||||||
| MAX_LOG_SIZE | 100 | max number of logs per user, last `n` transactions. If both this and pre log are toggled to 0 logs will not be compiled. | large history | higher memory usage |
|
| MAX_LOG_SIZE | 100 | max number of logs per user, last `n` transactions. If both this and pre log are toggled to 0 logs will not be compiled. | large history | higher memory usage |
|
||||||
| CONSERVATIVE_DISK_SAVE | `true` | when `true` only saves when changes are made | low # of disk operations | some atomic overhead |
|
| CONSERVATIVE_DISK_SAVE | `true` | when `true` only saves when changes are made | low # of disk operations | some atomic overhead |
|
||||||
| MULTI_THREADED | `true` | when `true` the program is compiled to utilize `n` threads which corresponds to how many Cores your CPU has, plus 1 for saving | speed | memory lock overhead is wasteful on single core machines |
|
| MULTI_THREADED | `true` | when `true` the program is compiled to utilize `n` threads which corresponds to how many Cores your CPU has, plus 1 for saving | speed | memory lock overhead is wasteful on single core machines |
|
||||||
| RETURN_ON_DEL_NAME | `N/A` | when defined, return on delete will be toggled and any accounts deleted will send their funds to the defined account, this prevent currency destruction | prevents destruction of currency | deleting accounts is made slower |
|
| RETURN_ON_DEL_NAME | `N/A` | when defined, return on delete will be toggled and any accounts deleted will send their funds to the defined account, this prevent currency destruction | prevents destruction of currency | deleting accounts is made slower |
|
||||||
|
| ADD_USER_OPEN | `true` | anybody can make a new account, if set to false only admins can add accounts via `AdminAddUser()` | `N/A` | spamming new users |
|
||||||
|
|
||||||
|
|
||||||
EXAMPLE:
|
EXAMPLE:
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ Valid
|
||||||
### User Management endpoint errors
|
### User Management endpoint errors
|
||||||
| name | 400 | 401 | 404 | 406 | 409 |
|
| name | 400 | 401 | 404 | 406 | 409 |
|
||||||
| :----------- | :----------------------: | :----------------------: | :----------------------: | :----------------: | :----------------------: |
|
| :----------- | :----------------------: | :----------------------: | :----------------------: | :----------------: | :----------------------: |
|
||||||
| AddUser | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_multiplication_x: | :heavy_check_mark: | :heavy_check_mark: |
|
| AddUser | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
||||||
| AdminAddUser | :heavy_check_mark: | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_check_mark: | :heavy_check_mark: |
|
| AdminAddUser | :heavy_check_mark: | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_check_mark: | :heavy_check_mark: |
|
||||||
| DelSelf | :heavy_multiplication_x: | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_check_mark: | :heavy_multiplication_x: |
|
| DelSelf | :heavy_multiplication_x: | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_check_mark: | :heavy_multiplication_x: |
|
||||||
| AdminDelUser | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_multiplication_x: |
|
| AdminDelUser | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_multiplication_x: |
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ void api::AdminVerifyAccount(req_args)
|
||||||
}
|
}
|
||||||
void api::ApiProperties(req_args)
|
void api::ApiProperties(req_args)
|
||||||
{
|
{
|
||||||
std::string info = "{\"version\":" + std::to_string(API_VERSION) + ",\"max_log\":" + std::to_string(MAX_LOG_SIZE);
|
std::string info = "{\"version\":" + std::to_string(API_VERSION) + ",\"max_log\":" + std::to_string(MAX_LOG_SIZE) + ",\"add_user_open\":" + std::to_string(ADD_USER_OPEN);
|
||||||
if constexpr (RETURN_ON_DEL)
|
if constexpr (RETURN_ON_DEL)
|
||||||
{
|
{
|
||||||
info += ",\"return_on_del\":\"" + std::string(return_account) + "\"}";
|
info += ",\"return_on_del\":\"" + std::string(return_account) + "\"}";
|
||||||
|
|
@ -257,6 +257,9 @@ void api::PruneUsers(req_args)
|
||||||
|
|
||||||
void api::AddUser(req_args)
|
void api::AddUser(req_args)
|
||||||
{
|
{
|
||||||
|
if constexpr (ADD_USER_OPEN)
|
||||||
|
{
|
||||||
|
|
||||||
SIMD_JSON_GEN;
|
SIMD_JSON_GEN;
|
||||||
BankResponse res;
|
BankResponse res;
|
||||||
if (doc.error())
|
if (doc.error())
|
||||||
|
|
@ -279,6 +282,14 @@ void api::AddUser(req_args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RESPONSE_PARSE(std::move(res));
|
RESPONSE_PARSE(std::move(res));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto resp = HttpResponse::newCustomHttpResponse(BankResponse{k404NotFound, "\"AddUser is Disabled\""});
|
||||||
|
CORS;
|
||||||
|
CACHE_FOREVER;
|
||||||
|
callback(resp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void api::AdminAddUser(req_args)
|
void api::AdminAddUser(req_args)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue