Skip to content

Repository files navigation

Arnelify Logo

Arnelify Server for C & C++C++G++C-Lang

🚀 About

Arnelify® Server for C & C++ — a multi-language server with HTTP 3.0 and WebTransport support.

All supported protocols:

#ProtocolTransport
1TCP2WebTransport
2TCP2HTTP 3.0
3TCP1WebSocket
4TCP1HTTP 2.0
5TCP1HTTP 1.1

📋 Minimal Requirements

Important: It's strongly recommended to use in a container that has been built from the gcc v15.2.0 image.

  • CPU: Apple M1 / Intel Core i7 / AMD Ryzen 7
  • OS: Debian 11 / MacOS 15 / Windows 10 with WSL2.
  • RAM: 4 GB

📦 Installation

Run in terminal:

git clone git@github.com:arnelify/arnelify-server-cpp.git

🎉 TCP2 / WebTransport

📚 Configuration

OptionDescription
BLOCK_SIZE_KBThe size of the allocated memory used for processing large packets.
CERT_PEMPath to the TLS cert-file in PEM format.
COMPRESSIONIf this option is enabled, the server will use BROTLI compression if the client application supports it. This setting increases CPU resource consumption. The server will not use compression if the data size exceeds the value of BLOCK_SIZE_KB.
HANDSHAKE_TIMEOUTMaximum time in seconds to complete the TLS handshake.
KEY_PEMPath to the TLS private key-file in PEM format.
MAX_MESSAGE_SIZE_MBMaximum size of a single message the server will accept from a client.
PING_TIMEOUTMaximum time the server will wait for a ping from the client.
PORTDefines which port the server will listen on.
SEND_TIMEOUTMaximum time for the client to receive a response from the server.
THREAD_LIMITDefines the maximum number of threads that will handle requests.

📚 Examples

#include<iostream>
#include"json.h"
#include"lib.hpp"intmain() {
WebTransportOpts opts(
/* block_size_kb */64,
/* cert_pem */"certs/cert.pem",
/* compression */false,
/* handshake_timeout */30,
/* key_pem */"certs/key.pem",
/* max_message_size_kb */64,
/* ping_timeout */15,
/* port */4433,
/* send_timeout */30,
/* thread_limit */4);
WebTransport wt(opts);
WebTransportLogger wt_logger = [](const std::string& _level,
const std::string& message) -> void {
std::cout << "[Arnelify Server]: " << message << std::endl;
};
wt.logger(wt_logger);
WebTransportHandler wt_handler = [](WebTransportCtx& ctx,
WebTransportBytes& bytes,
WebTransportStream& stream) -> void {
stream.push(ctx, bytes);
stream.close();
};
wt.on("connect", wt_handler);
wt.start();
}

🎉 TCP2 / HTTP 3.0

📚 Configuration

OptionDescription
ALLOW_EMPTY_FILESIf this option is enabled, the server will not reject empty files.
BLOCK_SIZE_KBThe size of the allocated memory used for processing large packets.
CERT_PEMPath to the TLS cert-file in PEM format.
CHARSETDefines the encoding that the server will recommend to all client applications.
COMPRESSIONIf this option is enabled, the server will use BROTLI compression if the client application supports it. This setting increases CPU resource consumption. The server will not use compression if the data size exceeds the value of BLOCK_SIZE_KB.
KEEP_ALIVEdefines how long the HTTP server keeps a connection.
KEEP_EXTENSIONSIf this option is enabled, file extensions will be preserved.
KEY_PEMPath to the TLS private key-file in PEM format.
MAX_FIELDSDefines the maximum number of fields in the received form.
MAX_FIELDS_SIZE_TOTAL_MBDefines the maximum total size of all fields in the form. This option does not include file sizes.
MAX_FILESDefines the maximum number of files in the form.
MAX_FILES_SIZE_TOTAL_MBDefines the maximum total size of all files in the form.
MAX_FILE_SIZE_MBDefines the maximum size of a single file in the form.
PORTDefines which port the server will listen on.
STORAGE_PATHSpecifies the upload directory for storage.
THREAD_LIMITDefines the maximum number of threads that will handle requests.

📚 Examples

#include<iostream>
#include"json.h"
#include"lib.hpp"intmain() {
Http3Opts opts(
/* allow_empty_files */true,
/* block_size_kb */64,
/* cert_pem */"certs/cert.pem",
/* charset */"utf-8",
/* compression */true,
/* keep_alive */30,
/* keep_extensions */true,
/* key_pem */"certs/key.pem",
/* max_fields*/60,
/* max_fields_size_total_mb */1,
/* max_files */1,
/* max_files_size_total_mb */60,
/* max_file_size_mb */60,
/* port */4433,
/* storage_path */"/var/www/cpp/storage",
/* thread_limit */4);
Http3 http3(opts);
Http3Logger http3_logger = [](const std::string& _level,
const std::string& message) -> void {
std::cout << "[Arnelify Server]: " << message << std::endl;
};
http3.logger(http3_logger);
Http3Handler http3_handler = [](Http3Req& ctx, Http3Stream& stream) -> void {
Json::StreamWriterBuilder writer;
writer["indentation"] = "";
writer["emitUTF8"] = true;
const std::string res = Json::writeString(writer, ctx);
const Http1Res bytes(res.begin(), res.end());
stream.set_code(200);
stream.push_bytes(bytes, false);
stream.end();
};
http3.on("/", http3_handler);
http3.start();
}

🎉 TCP1 / WebSocket

📚 Configuration

OptionDescription
BLOCK_SIZE_KBThe size of the allocated memory used for processing large packets.
COMPRESSIONIf this option is enabled, the server will use BROTLI compression if the client application supports it. This setting increases CPU resource consumption. The server will not use compression if the data size exceeds the value of BLOCK_SIZE_KB.
MAX_MESSAGE_SIZE_MBMaximum size of a single message the server will accept from a client.
PING_TIMEOUTMaximum time the server will wait for a ping from the client.
PORTDefines which port the server will listen on.
RATE_LIMITDefines the maximum number of connections allowed from a single IP address.
READ_TIMEOUTMaximum time allowed for a client to send a request to the server.
SEND_TIMEOUTMaximum time allowed for the client to receive a response from the server.
THREAD_LIMITDefines the maximum number of threads that will handle requests.

📚 Examples

#include<iostream>
#include"json.h"
#include"lib.hpp"intmain() {
WebSocketOpts opts(
/* block_size_kb */64,
/* compression */false,
/* max_message_size_kb */64,
/* ping_timeout */15,
/* port */4433,
/* rate_limit */5,
/* read_timeout */30,
/* send_timeout */30,
/* thread_limit */4);
WebSocket ws(opts);
WebSocketLogger ws_logger = [](const std::string& _level,
const std::string& message) -> void {
std::cout << "[Arnelify Server]: " << message << std::endl;
};
ws.logger(ws_logger);
WebSocketHandler ws_handler = [](WebSocketCtx& ctx, WebSocketBytes& bytes,
WebSocketStream& stream) -> void {
stream.push(ctx, bytes);
stream.close();
};
ws.on("connect", ws_handler);
ws.start();
}

🎉 TCP1 / HTTP 2.0

📚 Configuration

OptionDescription
ALLOW_EMPTY_FILESIf this option is enabled, the server will not reject empty files.
BLOCK_SIZE_KBThe size of the allocated memory used for processing large packets.
CERT_PEMPath to the TLS cert-file in PEM format.
CHARSETDefines the encoding that the server will recommend to all client applications.
COMPRESSIONIf this option is enabled, the server will use BROTLI compression if the client application supports it. This setting increases CPU resource consumption. The server will not use compression if the data size exceeds the value of BLOCK_SIZE_KB.
KEEP_ALIVEdefines how long the HTTP server keeps a connection.
KEEP_EXTENSIONSIf this option is enabled, file extensions will be preserved.
KEY_PEMPath to the TLS private key-file in PEM format.
MAX_FIELDSDefines the maximum number of fields in the received form.
MAX_FIELDS_SIZE_TOTAL_MBDefines the maximum total size of all fields in the form. This option does not include file sizes.
MAX_FILESDefines the maximum number of files in the form.
MAX_FILES_SIZE_TOTAL_MBDefines the maximum total size of all files in the form.
MAX_FILE_SIZE_MBDefines the maximum size of a single file in the form.
PORTDefines which port the server will listen on.
STORAGE_PATHSpecifies the upload directory for storage.
THREAD_LIMITDefines the maximum number of threads that will handle requests.

📚 Examples

#include<iostream>
#include"json.h"
#include"lib.hpp"intmain() {
Http2Opts opts(
/* allow_empty_files */true,
/* block_size_kb */64,
/* cert_pem */"certs/cert.pem",
/* charset */"utf-8",
/* compression */true,
/* keep_alive */30,
/* keep_extensions */true,
/* key_pem */"certs/key.pem",
/* max_fields*/60,
/* max_fields_size_total_mb */1,
/* max_files */1,
/* max_files_size_total_mb */60,
/* max_file_size_mb */60,
/* port */4433,
/* storage_path */"/var/www/cpp/storage",
/* thread_limit */4);
Http2 http2(opts);
Http2Logger http2_logger = [](const std::string& _level,
const std::string& message) -> void {
std::cout << "[Arnelify Server]: " << message << std::endl;
};
http2.logger(http2_logger);
Http2Handler http2_handler = [](Http2Req& ctx, Http2Stream& stream) -> void {
Json::StreamWriterBuilder writer;
writer["indentation"] = "";
writer["emitUTF8"] = true;
const std::string res = Json::writeString(writer, ctx);
const Http1Res bytes(res.begin(), res.end());
stream.set_code(200);
stream.push_bytes(bytes, false);
stream.end();
};
http2.on("/", http2_handler);
http2.start();
}

🎉 TCP1 / HTTP 1.1

📚 Configuration

OptionDescription
ALLOW_EMPTY_FILESIf this option is enabled, the server will not reject empty files.
BLOCK_SIZE_KBThe size of the allocated memory used for processing large packets.
CHARSETDefines the encoding that the server will recommend to all client applications.
COMPRESSIONIf this option is enabled, the server will use BROTLI compression if the client application supports it. This setting increases CPU resource consumption. The server will not use compression if the data size exceeds the value of BLOCK_SIZE_KB.
KEEP_ALIVEdefines how long the HTTP server keeps a connection.
KEEP_EXTENSIONSIf this option is enabled, file extensions will be preserved.
MAX_FIELDSDefines the maximum number of fields in the received form.
MAX_FIELDS_SIZE_TOTAL_MBDefines the maximum total size of all fields in the form. This option does not include file sizes.
MAX_FILESDefines the maximum number of files in the form.
MAX_FILES_SIZE_TOTAL_MBDefines the maximum total size of all files in the form.
MAX_FILE_SIZE_MBDefines the maximum size of a single file in the form.
PORTDefines which port the server will listen on.
STORAGE_PATHSpecifies the upload directory for storage.
THREAD_LIMITDefines the maximum number of threads that will handle requests.

📚 Examples

#include<iostream>
#include"json.h"
#include"lib.hpp"intmain() {
Http1Opts opts(
/* allow_empty_files */true,
/* block_size_kb */64,
/* charset */"utf-8",
/* compression */true,
/* keep_alive */30,
/* keep_extensions */true,
/* max_fields*/60,
/* max_fields_size_total_mb */1,
/* max_files */1,
/* max_files_size_total_mb */60,
/* max_file_size_mb */60,
/* port */4433,
/* storage_path */"/var/www/cpp/storage",
/* thread_limit */4);
Http1 http1(opts);
Http1Logger http1_logger = [](const std::string& _level,
const std::string& message) -> void {
std::cout << "[Arnelify Server]: " << message << std::endl;
};
http1.logger(http1_logger);
Http1Handler http1_handler = [](Http1Req& ctx, Http1Stream& stream) -> void {
Json::StreamWriterBuilder writer;
writer["indentation"] = "";
writer["emitUTF8"] = true;
const std::string res = Json::writeString(writer, ctx);
const Http1Res bytes(res.begin(), res.end());
stream.set_code(200);
stream.push_bytes(bytes, false);
stream.end();
};
http1.on("/", http1_handler);
http1.start();
}

⚖️ MIT License

This software is licensed under the MIT License. The original author's name, logo, and the original name of the software must be included in all copies or substantial portions of the software.

🛠️ Contributing

Join us to help improve this software, fix bugs or implement new functionality. Active participation will help keep the software up-to-date, reliable, and aligned with the needs of its users.

VSCode Configs (optional):

"includePath": [
"/opt/homebrew/Cellar/jsoncpp/1.9.6/include/json",
"${workspaceFolder}/src"
],

Run in terminal:

docker compose up -d --build
docker ps
docker exec -it <CONTAINER ID> bash
make build

For TCP2 / WebTransport:

make test_wt

For TCP2 / HTTP 3.0:

make test_http3

For TCP1 / WebSocket:

make test_ws

For TCP1 / HTTP 2.0:

make test_http2

For TCP1 / HTTP 1.1:

make test_http1

⭐ Release Notes

Version 1.0.8 — a multi-language server with HTTP 3.0 and WebTransport support.

We are excited to introduce the Arnelify Server for NodeJS! Please note that this version is raw and still in active development.

Change log:

  • HTTP 3.0 + WebTransport.
  • Security-aware logging with attack detection.
  • Async Runtime & Multi-Threading.
  • Large file upload and download support.
  • BROTLI compression (still in development).
  • FFI, PYO3 and NEON support.
  • Significant refactoring and optimizations.

Please use this version with caution, as it may contain bugs and unfinished features. We are actively working on improving and expanding the server's capabilities, and we welcome your feedback and suggestions.

🔗 Links

About

Arnelify® Server for C++ - is a multi-language server with HTTP 3.0 and WebTransport support.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages