From e0751bb7d62532e96c0c37d28f7f4a30e67464c0 Mon Sep 17 00:00:00 2001 From: Alexander Renz Date: Fri, 18 Jul 2025 11:22:26 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Tremora=20del=20Terra:=20ultimat?= =?UTF-8?q?e=20hmac-file-server=20fix=20=E2=80=93=20final=20push=20before?= =?UTF-8?q?=20the=20drop=20=F0=9F=92=BE=F0=9F=94=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config-example-xmpp.toml | 64 -------- config-network-resilience.toml | 62 ------- {test => github_tests}/hmac_icon.png | Bin {test => github_tests}/hmac_test.go | 0 {test => github_tests}/server_flags_test.go | 0 test/test_installer_config.sh | 173 -------------------- 6 files changed, 299 deletions(-) delete mode 100644 config-example-xmpp.toml delete mode 100644 config-network-resilience.toml rename {test => github_tests}/hmac_icon.png (100%) rename {test => github_tests}/hmac_test.go (100%) rename {test => github_tests}/server_flags_test.go (100%) delete mode 100755 test/test_installer_config.sh diff --git a/config-example-xmpp.toml b/config-example-xmpp.toml deleted file mode 100644 index dc0a773..0000000 --- a/config-example-xmpp.toml +++ /dev/null @@ -1,64 +0,0 @@ -# HMAC File Server - Example XMPP Configuration -# This is a sample configuration for XMPP integration with Prosody/Ejabberd - -[server] -listenport = "8080" -unixsocket = false -storagepath = "/var/lib/hmac-file-server/uploads" -metricsenabled = true -metricsport = "9090" -deduplicationenabled = true -minfreebytes = "5GB" -filettl = "2y" -filettlenabled = false -autoadjustworkers = true -networkevents = false -pidfilepath = "./hmac-file-server.pid" -precaching = false - -[deduplication] -enabled = true -directory = "/var/lib/hmac-file-server/deduplication" - -[logging] -level = "info" -file = "/var/log/hmac-file-server/hmac-file-server.log" -max_size = 100 -max_backups = 7 -max_age = 30 -compress = true - -[security] -secret = "your-super-secret-hmac-key-here-minimum-32-characters" -enablejwt = false -# jwtkey = "your-jwt-secret-key-here" -# jwtalgorithm = "HS256" -# jwtexpiry = "24h" - -[uploads] -maxfilesize = "1GB" -allowedextensions = [".jpg", ".jpeg", ".png", ".gif", ".pdf", ".txt", ".zip"] -blockedextensions = [".exe", ".bat", ".sh", ".cmd"] - -[downloads] -ratelimit = true -maxconcurrentdownloads = 10 - -[clamav] -enabled = false -host = "localhost" -port = 3310 -timeout = "30s" -maxfilesize = "100MB" - -[redis] -enabled = false -host = "localhost" -port = 6379 -password = "" -database = 0 - -[workers] -maxworkers = 10 -initialworkers = 2 -autoscaling = true diff --git a/config-network-resilience.toml b/config-network-resilience.toml deleted file mode 100644 index 8cc8ddd..0000000 --- a/config-network-resilience.toml +++ /dev/null @@ -1,62 +0,0 @@ -# HMAC File Server Configuration with Network Resilience -# Copy this to config.toml and modify as needed - -[server] -bind_ip = "0.0.0.0" -listenport = "8080" -unixsocket = false -storagepath = "./uploads" -metricsenabled = false -metricsport = "9090" -deduplicationenabled = true -networkevents = true # Enable network change detection -autoadjustworkers = true -pidfilepath = "./hmac-file-server.pid" - -[security] -secret = "your-super-secret-hmac-key-minimum-32-characters-long" -enablejwt = false -# jwtsecret = "your-jwt-secret" -# jwtalgorithm = "HS256" -# jwtexpiration = "24h" - -[uploads] -chunkeduploadsenabled = true # Enable chunked/resumable uploads -resumableuploadsenabled = true # Enable upload resumption -chunksize = "5MB" # Optimal chunk size for mobile -sessiontimeout = "24h" # How long to keep upload sessions -maxretries = 5 # Server-side retry attempts -allowedextensions = [".txt", ".pdf", ".jpg", ".jpeg", ".png", ".gif", ".zip", ".tar", ".gz"] -maxfilesize = "100MB" - -[downloads] -chunkeddownloadsenabled = true -chunksize = "5MB" - -[timeouts] -readtimeout = "300s" # 5 minutes for mobile uploads -writetimeout = "300s" # 5 minutes for responses -idletimeout = "600s" # 10 minutes keep-alive - -[logging] -level = "info" -file = "" # Empty = stdout -max_size = 100 -max_backups = 3 -max_age = 30 -compress = true - -[workers] -numworkers = 10 -uploadqueuesize = 1000 -autoscaling = true - -[redis] -redisenabled = false # Enable for session persistence -redisaddr = "localhost:6379" -redispassword = "" -redisdbindex = 0 - -[clamav] -clamavenabled = false # Enable for virus scanning -clamavsocket = "/var/run/clamav/clamd.ctl" diff --git a/test/hmac_icon.png b/github_tests/hmac_icon.png similarity index 100% rename from test/hmac_icon.png rename to github_tests/hmac_icon.png diff --git a/test/hmac_test.go b/github_tests/hmac_test.go similarity index 100% rename from test/hmac_test.go rename to github_tests/hmac_test.go diff --git a/test/server_flags_test.go b/github_tests/server_flags_test.go similarity index 100% rename from test/server_flags_test.go rename to github_tests/server_flags_test.go diff --git a/test/test_installer_config.sh b/test/test_installer_config.sh deleted file mode 100755 index 6d51181..0000000 --- a/test/test_installer_config.sh +++ /dev/null @@ -1,173 +0,0 @@ -#!/bin/bash - -# Test script to validate installer configuration generation -# Tests that the installer generates config compatible with fixed struct definitions - -set -e - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -echo -e "${BLUE}๐Ÿ” Testing Installer Configuration Generation${NC}" -echo "=============================================" -echo "" - -# Test configuration values that simulate installer input -export HMAC_SECRET="test-hmac-secret-32-characters-long-minimum" -export JWT_SECRET="test-jwt-secret-also-32-characters-long-minimum" - -# Create a test directory -TEST_DIR="/tmp/hmac-installer-test-$$" -mkdir -p "$TEST_DIR" -cd "$TEST_DIR" - -echo -e "${YELLOW}๐Ÿ“ Test directory: $TEST_DIR${NC}" -echo "" - -# Copy necessary files for testing -cp /home/renz/source/hmac-file-server-uuxo/go.mod . -cp /home/renz/source/hmac-file-server-uuxo/go.sum . -cp -r /home/renz/source/hmac-file-server-uuxo/cmd . - -# Extract the generate_config function and create a test version -cat > test_config_generation.sh << 'EOF' -#!/bin/bash - -# Simulated installer variables -DEFAULT_CONFIG_DIR="./test-config" -DATA_DIR="./test-data" -DEFAULT_LOG_DIR="./test-logs" -SERVER_PORT="8080" -METRICS_PORT="9090" -ENABLE_TLS="false" -HMAC_SECRET="test-hmac-secret-32-characters-long-minimum" -ENABLE_JWT="false" -ENABLE_CLAMAV="false" -ENABLE_REDIS="false" - -# Create directories -mkdir -p "$DEFAULT_CONFIG_DIR" -mkdir -p "$DATA_DIR/runtime" -mkdir -p "$DEFAULT_LOG_DIR" - -# Generate configuration (extracted from installer) -generate_config() { - echo "Generating test configuration..." - - cat > "$DEFAULT_CONFIG_DIR/config.toml" << EOFCONFIG -# HMAC File Server Configuration -# Generated by installer test on $(date) - -[server] -bind_ip = "0.0.0.0" -listenport = "$SERVER_PORT" -unixsocket = false -storagepath = "$DATA_DIR/uploads" -metricsenabled = true -metricsport = "$METRICS_PORT" -deduplicationenabled = true -deduplicationpath = "$DATA_DIR/deduplication" -filenaming = "HMAC" -force_protocol = "auto" -pidfilepath = "$DATA_DIR/runtime/hmac-file-server.pid" -sslenabled = false - -[security] -secret = "$HMAC_SECRET" -enablejwt = false - -[uploads] -allowedextensions = [".txt", ".pdf", ".jpg", ".jpeg", ".png", ".gif", ".webp", ".zip", ".tar", ".gz", ".7z", ".mp4", ".webm", ".ogg", ".mp3", ".wav", ".flac", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".odt", ".ods", ".odp"] -maxfilesize = "100MB" -chunkeduploadsenabled = true -chunksize = "10MB" -ttlenabled = false -ttl = "168h" - -[downloads] -chunkeddownloadsenabled = true -chunksize = "10MB" - -[logging] -level = "INFO" -file = "$DEFAULT_LOG_DIR/hmac-file-server.log" -max_size = 100 -max_backups = 3 -max_age = 30 -compress = true - -[workers] -numworkers = 10 -uploadqueuesize = 1000 -autoscaling = true - -[timeouts] -readtimeout = "30s" -writetimeout = "30s" -idletimeout = "120s" -shutdown = "30s" - -[clamav] -enabled = false - -[redis] -enabled = false -EOFCONFIG - - echo "Configuration file created: $DEFAULT_CONFIG_DIR/config.toml" -} - -# Call the function -generate_config -EOF - -chmod +x test_config_generation.sh -./test_config_generation.sh - -echo -e "${YELLOW}๐Ÿ“‹ Generated test configuration:${NC}" -echo "" -cat ./test-config/config.toml -echo "" - -# Build a test binary to validate the configuration -echo -e "${YELLOW}๐Ÿ”จ Building test binary...${NC}" -if go build -o hmac-test-server ./cmd/server/*.go; then - echo -e "${GREEN}โœ… Build successful${NC}" -else - echo -e "${RED}โŒ Build failed${NC}" - exit 1 -fi - -echo "" -echo -e "${YELLOW}๐Ÿ” Testing configuration validation...${NC}" - -# Test configuration validation -if ./hmac-test-server -config ./test-config/config.toml -validate-config -validate-quiet; then - echo -e "${GREEN}โœ… Configuration validation PASSED!${NC}" - echo "" - echo -e "${GREEN}๐ŸŽ‰ All critical fixes verified:${NC}" - echo -e "${GREEN} โœ“ Workers: numworkers/uploadqueuesize (not initial/max)${NC}" - echo -e "${GREEN} โœ“ Protocol: force_protocol (not forceprotocol)${NC}" - echo -e "${GREEN} โœ“ PID file: pidfilepath configured${NC}" - echo -e "${GREEN} โœ“ Timeouts: read/write/idle/shutdown${NC}" - echo -e "${GREEN} โœ“ Logging: level/file/max_size/max_backups/max_age${NC}" - VALIDATION_RESULT=0 -else - echo -e "${RED}โŒ Configuration validation FAILED!${NC}" - echo "" - echo -e "${YELLOW}Running detailed validation for diagnosis...${NC}" - ./hmac-test-server -config ./test-config/config.toml -validate-config -validate-verbose || true - VALIDATION_RESULT=1 -fi - -echo "" -echo -e "${YELLOW}๐Ÿงน Cleaning up test directory...${NC}" -cd / -rm -rf "$TEST_DIR" - -echo -e "${BLUE}Test completed.${NC}" -exit $VALIDATION_RESULT