Refactor FastCGI server and compiler, enhance HTTP header parsing, and add WebSocket support

- Refactored FastCGIServer class to improve socket handling and added shutdown functionality.
- Updated compiler functions to streamline HTML and text literal processing.
- Enhanced split_kv function to support uppercase keys and added split_http_headers for better HTTP header parsing.
- Introduced new session management functions to validate and handle session IDs.
- Added WebSocket frame parsing and handling in the URI module.
- Created systemd service scripts for easier deployment and management of the UCE FastCGI runtime.
- Added new test cases for header handling, time parsing, and WebSocket functionality.
This commit is contained in:
udo
2026-04-18 14:04:58 +00:00
parent 984453f336
commit cd8f07aaa7
26 changed files with 913 additions and 367 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ cd "$(dirname "$0")"
cd ..
BUILDMODE=${2:-"debug"}
OPT_FLAG="O3"
OPT_FLAG="O0"
GF="uce_fastcgi"
mkdir bin > /dev/null 2>&1
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ ${EUID:-0} -ne 0 ]]; then
echo "This script must run as root." >&2
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
UNIT_NAME="uce.service"
UNIT_SOURCE="$SCRIPT_DIR/uce.service"
UNIT_DEST="/etc/systemd/system/$UNIT_NAME"
CONFIG_SOURCE="$REPO_ROOT/etc/uce/settings.cfg"
CONFIG_DEST="/etc/uce/settings.cfg"
action="${1:-setup}"
install_unit() {
install -D -m 0644 "$UNIT_SOURCE" "$UNIT_DEST"
if [[ ! -f "$CONFIG_DEST" ]]; then
install -D -m 0644 "$CONFIG_SOURCE" "$CONFIG_DEST"
fi
systemctl daemon-reload
}
case "$action" in
install)
install_unit
;;
setup)
install_unit
systemctl enable --now "$UNIT_NAME"
;;
enable)
install_unit
systemctl enable "$UNIT_NAME"
;;
start|stop|restart|status)
systemctl "$action" "$UNIT_NAME"
;;
logs)
lines="${2:-100}"
journalctl -u "$UNIT_NAME" -n "$lines" --no-pager
;;
*)
echo "Usage: $0 [install|setup|enable|start|stop|restart|status|logs [lines]]" >&2
exit 1
;;
esac
+22
View File
@@ -0,0 +1,22 @@
[Unit]
Description=UCE FastCGI Runtime
After=network-online.target mariadb.service memcached.service
Wants=network-online.target
[Service]
Type=simple
WorkingDirectory=/Code/uce.openfu.com/uce
ExecStartPre=/usr/bin/mkdir -p /tmp/uce/work /tmp/uce/uploads /tmp/uce/sessions
ExecStartPre=/usr/bin/rm -f /run/uce.sock
ExecStartPre=/usr/bin/bash /Code/uce.openfu.com/uce/scripts/build_linux.sh
ExecStart=/Code/uce.openfu.com/uce/bin/uce_fastcgi.linux.bin
ExecStopPost=/usr/bin/rm -f /run/uce.sock
Restart=always
RestartSec=2
TimeoutStopSec=15
KillMode=mixed
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target