-
Notifications
You must be signed in to change notification settings - Fork 53
Silgy switches and constants
Jurek Muszyński edited this page Oct 9, 2019
·
66 revisions
Silgy engine and library use a number of switches and constants, defined as macros in the header files. You can use silgy_app.h to turn some of them on, or redefine them:
#define APP_MIN_USERNAME_LEN 3
#define APP_MIN_PASSWORD_LEN 8
#define DBMYSQL
#define USERS
#define HTTPS
If not present in silgy_app.h, they will have their default values defined in silgy.h, silgy_lib.h and silgy_usr.h.
Macro | Description | Default |
---|---|---|
ALLOW_BEARER_AUTH | If ls cookie is not present in request, use Authorization Bearer value | |
APP_ADMIN_EMAIL | Admin email used by USERS module | |
APP_ASYNC_ID | Unique integer needed when there's more than one Silgy application using ASYNC on the same machine | |
APP_CONTACT_EMAIL | Contact email used by USERS module | |
APP_DESCRIPTION | If defined, it will be used by OUT_HTML_HEADER macro, in html header | |
APP_DOMAIN | Domain name, used in redirections with DOMAINONLY and by the visits counter | |
APP_EMAIL_FROM_USER | Send an email using silgy_email() as a specific user | noreply |
APP_ERROR_PAGE | Render your own error page. You also need to define void silgy_app_error_page(int ci, int code) in silgy_app.cpp . |
|
APP_IP | Application host IP used by IP-blocking by BLACKLISTAUTOUPDATE | |
APP_JSON_BUFSIZE | Maximum length of JSON string | 65568 |
APP_JSON_MAX_ELEMS | Maximum number of elements in JSON objects | 10 |
APP_JSON_MAX_LEVELS | Maximum number of levels in JSON objects | 4 |
APP_KEYWORDS | If defined, it will be used by OUT_HTML_HEADER macro, in html header | |
APP_LOGIN_URI | Used for redirection when access to protected resource has been requested, see silgy_set_auth_level() | login |
APP_MAX_STATICS | Maximum number of static resources | 1000 |
APP_MIN_USERNAME_LEN | Minimum user name length for USERS module | 2 |
APP_MIN_PASSWORD_LEN | Minimum password length for USERS module | 5 |
APP_SESID_LEN | Session id length used in cookies | 15 |
APP_VERSION | Displayed at the beginning of the log | 1.0 |
APP_WEBSITE | Website name, for example used in OUT_HTML_HEADER macro | Silgy Web Application |
ASYNC | Enable ASYNC | |
ASYNC_EXCLUDE_AUSES | Don't share application part of the user session (auses) between silgy_app and silgy_svc | |
ASYNC_MQ_MAXMSG | Max messages in message queue | 10 |
ASYNC_REQ_MSG_SIZE | Request message size in bytes | 8192 |
ASYNC_RES_MSG_SIZE | Response message size in bytes | 8192 |
ASYNC_USE_APP_CONTINUE | For backward compatibility. 1. Make CALL_ASYNC macros to take an extra argument – data; 2. Make the engine call silgy_app_continue() after CALL_ASYNC has returned. This was default before v4.3 | |
BLACKLISTAUTOUPDATE | Automatically add malicious IPs to the file defined in blockedIPList | |
COMPRESS_TRESHOLD | Minimum response content size to compress (bytes) | 500 |
COMPRESS_LEVEL | Deflate parameter (see zlib) | Z_BEST_SPEED |
CONN_TIMEOUT | HTTP connection timeout (seconds) | 180 |
DBMYSQL | Open MySQL connection at the start and close it during clean up. Use dbHost, dbPort, dbName, dbUser and dbPassword | |
DBMYSQLRECONNECT | Open MySQL connection with auto-reconnect option. I recommend not to use this option at the beginning, until you're familiar with MySQL settings, for reconnect happens quietly and without you knowing, this may be impacting your app's performance. See wait_timeout. | |
DEF_RES_AUTH_LEVEL | Default resource authorization level, see silgy_set_auth_level() | AUTH_LEVEL_NONE |
DEF_USER_AUTH_LEVEL | Default user authorization level, see silgy_set_auth_level() | AUTH_LEVEL_USER |
DOMAINONLY | Always redirect to APP_DOMAIN | |
DONT_LOOK_FOR_INDEX | By default, when there's a plain GET / request, and res/index.html is present, Silgy serves it. Use this flag to disable this. |
|
DONT_NOTIFY_NEW_USER | Disable notifying new user about the new account created with silgy_usr_add_user() | |
DONT_PASS_QS_ON_LOGIN_REDIRECTION | When logged in session is required for the resource and there's no logged in session, request will be redirected to APP_LOGIN_URI. By default the query string is passed as well. Use this switch to disable this. | |
DONT_RESCAN_RES | By default, Silgy engine rescans res and resmin directories every 60 seconds, rereading the files when changed. Use this flag to disable this. |
|
DUMP | Highest level debug output. Use with care, as this may produce quite a huge log files. | |
EXPIRES_STATICS | Used to calculate response header value for static resources (days from today, updated every midnight). If 0, Expires header for statics will not be sent. | 90 |
EXPIRES_GENERATED | Used to calculate response header value for rendered content (days from today, updated every midnight). If 0, Expires header for generated content will not be sent. | 30 |
FD_MON_POLL | Monitor connected sockets using poll() | Default on Linux |
FD_MON_SELECT | Monitor connected sockets using select() | Default on Windows |
HSTS_INCLUDE_SUBDOMAINS | Add includeSubDomains to Strict-Transport-Security response header | |
HSTS_MAX_AGE | HSTS max-age parameter | 31536000 |
HTTPS | Enable HTTPS. Both ports (httpPort & httpsPort) will be open and listened to. OpenSSL, certificate and the key pair are required (see How-to) | |
ICONV | Enable silgy_convert(). On Windows, you also need to add iconv library to m.bat. | |
JSON_KEY_LEN | Maximum JSON field name length | 31 |
JSON_VAL_LEN | Maximum JSON string value length | 255 |
JSON_NO_AUTO_AMPERSANDS | Don't add ampersands to CALL_REST() and JSON_xxx macros | |
LUSES_TIMEOUT | Logged in session caching timeout (seconds) | 1800 |
MAX_BLACKLIST | Blocked IP list size | 10000 |
MAX_MESSAGES | Maximum number of messages | 1000 |
MAX_STRINGS | Maximum number of strings | 1000 |
MAX_PAYLOAD_SIZE | Maximum incoming payload size in bytes | 16777216 (16 MB) |
MAX_ULA_BEFORE_FIRST_SLOW | Maximum unsuccessful login attempts before first slowing down (1 attempt per minute will be allowed) | 10 |
MAX_ULA_BEFORE_SECOND_SLOW | Maximum unsuccessful login attempts before second slowing down (1 attempt per hour will be allowed) | 25 |
MAX_ULA_BEFORE_THIRD_SLOW | Maximum unsuccessful login attempts before third slowing down (1 attempt per 23 hours will be allowed) | 100 |
MAX_ULA_BEFORE_LOCK | Maximum unsuccessful login attempts before locking user out | 1000 |
MAX_WHITELIST | Whitelist size | 10000 |
MEM_TINY | Sets the memory model | |
MEM_SMALL | Sets the memory model | (default) |
MEM_MEDIUM | Sets the memory model | |
MEM_LARGE | Sets the memory model | |
MEM_XLARGE | Sets the memory model | |
MEM_XXLARGE | Sets the memory model | |
MEM_XXXLARGE | Sets the memory model | |
MEM_XXXXLARGE | Sets the memory model | |
MSG_FORMAT_JSON | Make OUT_MSG_DESCRIPTION() to send response in JSON | |
NO_HSTS | Turn HSTS off | |
NO_IDENTITY | By default Silgy introduces itself in HTTP headers, with Server: Silgy and User-Agent: Silgy in |
|
NO_NOSNIFF | By default, there's a X-Content-Type-Options: nosniff header added to a response with content. Use this flag to turn it off. | |
NO_SAMEORIGIN | By default, there's a X-Frame-Options: SAMEORIGIN header added to a response with content. Use this flag to turn it off. | |
CALL_REST(). Use this flag to disable this. | ||
OUTCHECKREALLOC | Sets the OUT() and OUT_BIN() mode. Every write checks available space, resizes if necessary. | (default) |
OUTCHECK | Sets the OUT() and OUT_BIN() mode. Every write checks available space, stop writing when exhausted. | |
OUTFAST | Sets the OUT() and OUT_BIN() mode. No check, fast and dangerous. | |
QS_DEF_HTML_ESCAPE | Sets the QS mode. HTML-escapes value, i.e. ' will become ' . |
(default) |
QS_DEF_SQL_ESCAPE | Sets the QS mode. SQL-escapes value, i.e. ' will become \' . |
|
QS_DEF_DONT_ESCAPE | Sets the QS mode. Don't escape value. | |
REST_CALL_DONT_CACHE_ADDRINFO | By default CALL_REST() caches last 100 addresses to avoid unnecessary DNS querying. Use this flag to disable this. | |
STR_001 | Users' passwords pepper, part 1. Use random, 4−15 characters long string. | abcde |
STR_002 | Users' passwords pepper, part 2. Use random, 4−15 characters long string. | fghij |
STR_003 | Users' passwords pepper, part 3. Use random, 4−15 characters long string. | klmno |
STR_004 | Users' passwords pepper, part 4. Use random, 4−15 characters long string. | pqrst |
STR_005 | Users' passwords pepper, part 5. Use random, 4−15 characters long string. | uvwxy |
STRINGS_SEP | Strings' separator in strings.LL-CC files | | |
TMP_BUFSIZE | Temporary buffer (used by OUT()) size in bytes | OUT_BUFSIZE |
USER_ACTIVATION_HOURS | How many hours user has to activate account | 24 |
USER_KEEP_LOGGED_DAYS | ls cookie validity period | 30 |
USES_TIMEOUT | Anonymous session timeout (seconds) | 300 |
USERS | Use users module. It provides an API for handling all registered users logic, including common things like i.e. password reset. You need to have DBMYSQL defined as well. | |
USERSBYEMAIL | Use email to authenticate users. Mutually exclusive with USERSBYLOGIN. | |
USERSBYLOGIN | Use login or email to authenticate users. Mutually exclusive with USERSBYEMAIL | (default) |