Add unix socket listening mode

This commit is contained in:
2025-08-19 17:57:07 -04:00
parent 800d8cb6b0
commit 4044f0a871
7 changed files with 192 additions and 61 deletions

View File

@@ -81,6 +81,7 @@ void ConfigParser::parse_server_config(const auto &toml_data,
parse_section(toml_data, "server", [&](const auto &srv) {
parse_field(srv, "bind_address", config.bind_address);
parse_field(srv, "port", config.port);
parse_field(srv, "unix_socket_path", config.unix_socket_path);
parse_field(srv, "max_request_size_bytes", config.max_request_size_bytes);
parse_field(srv, "accept_threads", config.accept_threads);
parse_field(srv, "network_threads", config.network_threads);
@@ -114,11 +115,24 @@ bool ConfigParser::validate_config(const Config &config) {
bool valid = true;
// Validate server configuration
if (config.server.port <= 0 || config.server.port > 65535) {
std::cerr
<< "Configuration error: server.port must be between 1 and 65535, got "
<< config.server.port << std::endl;
valid = false;
if (config.server.unix_socket_path.empty()) {
// TCP mode validation
if (config.server.port <= 0 || config.server.port > 65535) {
std::cerr << "Configuration error: server.port must be between 1 and "
"65535, got "
<< config.server.port << std::endl;
valid = false;
}
} else {
// Unix socket mode validation
if (config.server.unix_socket_path.length() >
107) { // UNIX_PATH_MAX is typically 108
std::cerr << "Configuration error: unix_socket_path too long (max 107 "
"chars), got "
<< config.server.unix_socket_path.length() << " chars"
<< std::endl;
valid = false;
}
}
if (config.server.max_request_size_bytes == 0) {