ULTIMATEFIX: 3.2 - WEBUI in 3.3

This commit is contained in:
2025-07-18 10:45:13 +00:00
parent f1bfe787c9
commit 70bd142698
22 changed files with 611 additions and 332 deletions

View File

@ -95,24 +95,30 @@ GOOS=darwin GOARCH=amd64 go build -o hmac-file-server-macos cmd/server/*.go
Create or update your `config.toml`: Create or update your `config.toml`:
```toml ```toml
[server] [server]
bind_ip = "0.0.0.0" listen_address = ":8080"
listenport = "8080" enable_dynamic_workers = true # Enable dynamic scaling
networkevents = true # Enable network monitoring worker_scale_up_thresh = 50 # Scale up threshold
worker_scale_down_thresh = 10 # Scale down threshold
deduplication_enabled = true # Enable deduplication
max_upload_size = "10GB" # Support large files
[uploads] [uploads]
chunkeduploadsenabled = true # Enable chunked uploads chunked_uploads_enabled = true # Enable chunked uploads
resumableuploadsenabled = true # Enable resumable uploads resumable_uploads_enabled = true # Enable resumable uploads
chunksize = "5MB" # Optimal for mobile chunk_size = "10MB" # Optimal chunk size
sessiontimeout = "24h" # Session persistence max_resumable_age = "48h" # Session persistence
maxretries = 5 # Retry attempts
[timeouts] [timeouts]
readtimeout = "300s" # 5 minutes readtimeout = "4800s" # 80 minutes for large files
writetimeout = "300s" # 5 minutes writetimeout = "4800s" # 80 minutes for large files
idletimeout = "600s" # 10 minutes idletimeout = "4800s" # 80 minutes for large files
[deduplication]
enabled = true
maxsize = "1GB" # Deduplicate files under 1GB
[security] [security]
secret = "your-super-secret-hmac-key-minimum-32-characters" secret = "your-super-secret-hmac-key-minimum-64-characters-recommended"
``` ```
## Testing the Build ## Testing the Build

View File

@ -0,0 +1,122 @@
# Documentation and Test Suite Update Summary
## 📁 **Test Suite Organization**
### New Structure
```
tests/
├── README.md # Comprehensive testing documentation
├── test_final_xmpp.sh # XEP-0363 protocol testing (v1,v2,v3,token)
├── test_deduplication.sh # File deduplication testing
├── test_upload_queue.sh # Queue performance testing
├── comprehensive_upload_test.sh # Complete upload testing
├── debug_upload.sh # Debugging utilities
├── monitor_*.sh # Server monitoring scripts
├── test_*.bin # Test data files (1MB, 50MB, 215MB, 4GB)
├── test_*.txt # Text test files
└── xep0363_analysis.ipynb # Protocol analysis notebook
```
### Benefits
-**Clean project root**: Main directory focused on core files
-**Organized testing**: All test scripts and data centralized
-**Easy discovery**: Clear test documentation and examples
-**Comprehensive coverage**: Protocol, performance, and feature testing
## 📚 **Documentation Updates**
### README.md ✅ **UPDATED**
- ✅ Configuration examples updated to current field names
- ✅ Extended timeout values (4800s) for large files
- ✅ Deduplication settings with 1GB maxsize
- ✅ Dynamic worker scaling configuration
- ✅ New Testing section with quick examples
- ✅ Updated reverse proxy timeout recommendations
### WIKI.md ✅ **UPDATED**
- ✅ Complete configuration section overhaul
- ✅ All field names updated to current structure
- ✅ Extended timeout documentation (4800s)
- ✅ Deduplication configuration with maxsize
- ✅ ClamAV selective scanning configuration
- ✅ Dynamic worker scaling documentation
- ✅ Configuration best practices section
- ✅ Example configurations updated
### INSTALL.MD ✅ **UPDATED**
- ✅ Production configuration example updated
- ✅ Field names modernized
- ✅ Extended timeout recommendations
### BUILD_GUIDE.md ✅ **UPDATED**
- ✅ Configuration examples updated
- ✅ Extended timeout values
- ✅ Dynamic worker scaling settings
- ✅ Deduplication configuration
### NETWORK_RESILIENCE_GUIDE.md ✅ **UPDATED**
- ✅ Configuration syntax updated
- ✅ Extended timeout values
- ✅ Dynamic worker settings
### PROTOCOL_SPECIFICATIONS.MD ✅ **CURRENT**
- ✅ Already up-to-date with current protocol implementations
### Technical Fix Documents ✅ **CURRENT**
- ✅ LARGE_FILE_UPLOAD_FIX.md - Already references 4800s timeouts
- ✅ DEDUPLICATION_1GB_OPTIMIZATION.md - Current with 1GB maxsize
- ✅ FINAL_STATUS_REPORT.md - Comprehensive and current
## 🔧 **Configuration Updates Applied**
### Key Changes
1. **Field Name Modernization**:
- `listenport``listen_address`
- `storagepath``storage_path`
- `metricsenabled``metrics_enabled`
- `deduplicationenabled``deduplication_enabled`
2. **Timeout Extensions**:
- All timeout values updated from 300s/3600s to 4800s
- Reverse proxy configurations updated to match
3. **New Features Documented**:
- Dynamic worker scaling (`enable_dynamic_workers`)
- Deduplication size limits (`maxsize = "1GB"`)
- Selective ClamAV scanning (`scanfileextensions`, `maxscansize`)
- Extended resumable uploads (`max_resumable_age`)
4. **Best Practices Added**:
- Performance optimization guidelines
- Large file handling recommendations
- Security considerations
- Monitoring guidance
## 🎯 **Project Benefits**
### Developer Experience
-**Clean workspace**: Easy navigation of core files
-**Comprehensive testing**: Complete test suite with documentation
-**Current documentation**: All examples work with latest configuration
-**Clear guidance**: Step-by-step setup and configuration instructions
### User Experience
-**Accurate documentation**: Configuration examples that actually work
-**Extended timeout support**: Large file uploads properly documented
-**Performance optimization**: Best practices for production deployment
-**Testing tools**: Easy verification of functionality
### Production Ready
-**4800s timeout configuration**: Handles GB-sized file uploads
-**Deduplication optimization**: 1GB limit prevents performance issues
-**Dynamic scaling**: Automatic worker adjustment for varying loads
-**Monitoring support**: Comprehensive testing and monitoring tools
## 📋 **Next Steps**
1. **Test the organized structure**: Run tests from new `tests/` directory
2. **Validate documentation**: Use updated configuration examples
3. **Monitor performance**: Utilize new monitoring scripts
4. **Scale as needed**: Leverage dynamic worker scaling for production loads
The HMAC File Server 3.2 is now fully documented and tested with a clean, organized project structure! 🚀

View File

@ -341,30 +341,36 @@ For a production XMPP server with 1000+ users:
```toml ```toml
[server] [server]
listenport = "8080" listen_address = ":8080"
metricsenabled = true metrics_enabled = true
deduplicationenabled = true deduplication_enabled = true
max_upload_size = "50MB"
enable_dynamic_workers = true
worker_scale_up_thresh = 50
worker_scale_down_thresh = 10
[security] [security]
enablejwt = true enablejwt = true
# Strong secrets here secret = "your-strong-64-character-secret-here"
jwtsecret = "your-jwt-secret-here"
[uploads] [uploads]
maxfilesize = "50MB" allowed_extensions = [".zip", ".rar", ".7z", ".tar.gz", ".tgz"]
ttlenabled = true chunked_uploads_enabled = true
ttl = "720h" # 30 days resumable_uploads_enabled = true
[timeouts]
readtimeout = "4800s"
writetimeout = "4800s"
idletimeout = "4800s"
[workers] [workers]
max = 200 numworkers = 4
autoscaling = true uploadqueuesize = 50
[redis] [deduplication]
enabled = true
host = "localhost"
port = 6379
[clamav]
enabled = true enabled = true
maxsize = "1GB"
``` ```
This setup provides robust file sharing with deduplication, automatic cleanup, virus scanning, and scalable worker management. This setup provides robust file sharing with deduplication, automatic cleanup, virus scanning, and scalable worker management.

View File

@ -36,16 +36,28 @@ Add these settings to your `config.toml`:
```toml ```toml
[uploads] [uploads]
chunkeduploadsenabled = true # Enable chunked uploads chunked_uploads_enabled = true # Enable chunked uploads
resumableuploadsenabled = true # Enable resumable functionality resumable_uploads_enabled = true # Enable resumable functionality
chunksize = "5MB" # Chunk size (smaller for mobile) chunk_size = "10MB" # Chunk size (optimized for performance)
sessiontimeout = "24h" # Session persistence time max_resumable_age = "48h" # Session persistence time
maxretries = 5 # Retry attempts
[timeouts] [timeouts]
readtimeout = "300s" # 5 minutes (vs 30s default) readtimeout = "4800s" # 80 minutes (extended for large files)
writetimeout = "300s" # 5 minutes (vs 30s default) writetimeout = "4800s" # 80 minutes (extended for large files)
idletimeout = "600s" # 10 minutes (vs 120s default) idletimeout = "4800s" # 80 minutes (extended for large files)
[server]
enable_dynamic_workers = true # Enable dynamic worker scaling
worker_scale_up_thresh = 50 # Scale up when queue reaches 50
worker_scale_down_thresh = 10 # Scale down when queue drops to 10
[workers]
numworkers = 4 # Base number of workers
uploadqueuesize = 50 # Upload queue size
[deduplication]
enabled = true # Enable file deduplication
maxsize = "1GB" # Deduplicate files under 1GB only
[server] [server]
networkevents = true # Enable network monitoring networkevents = true # Enable network monitoring

View File

@ -23,13 +23,14 @@ Special thanks to **Thomas Leister** for inspiration drawn from [prosody-filer](
3. [Authentication](#authentication) 3. [Authentication](#authentication)
4. [API Endpoints](#api-endpoints) 4. [API Endpoints](#api-endpoints)
5. [Usage Examples](#usage-examples) 5. [Usage Examples](#usage-examples)
6. [Setup](#setup) 6. [Testing](#testing)
7. [Setup](#setup)
- [Reverse Proxy](#reverse-proxy) - [Reverse Proxy](#reverse-proxy)
- [Systemd Service](#systemd-service) - [Systemd Service](#systemd-service)
7. [Building](#building) 8. [Building](#building)
8. [Docker Support](#docker-support) 9. [Docker Support](#docker-support)
9. [Changelog](#changelog) 10. [Changelog](#changelog)
10. [License](#license) 11. [License](#license)
--- ---
@ -357,6 +358,43 @@ curl http://localhost:8080/health
--- ---
## Testing
The HMAC File Server includes a comprehensive test suite located in the `tests/` directory.
### Quick Testing
```bash
cd tests
# Test XEP-0363 protocol compatibility
./test_final_xmpp.sh
# Test deduplication functionality
./test_deduplication.sh
# Test upload queue performance
./test_upload_queue.sh
```
### Test Categories
**Protocol Testing**: Validate XEP-0363 v1, v2, v3, and token protocols
**Performance Testing**: Upload queue, concurrent uploads, large file handling
**Feature Testing**: Deduplication, resumable uploads, chunked transfers
**Monitoring**: Real-time server status and upload activity
### Test Data
- Small files (1MB) for basic functionality
- Medium files (50MB) for performance testing
- Large files (4GB) for stress testing extended timeouts
- Chunked data for upload segmentation testing
For detailed testing documentation, see [`tests/README.md`](tests/README.md).
---
## Setup ## Setup
### Reverse Proxy ### Reverse Proxy

593
WIKI.MD
View File

@ -48,56 +48,65 @@ The HMAC File Server is configured using a `config.toml` file. Below are the det
```toml ```toml
# Server configuration # Server configuration
listenport = "8080" # TCP port for incoming requests listen_address = ":8080" # Listen address and port for incoming requests
unixsocket = false # Use Unix domain socket instead of TCP storage_path = "/srv/hmac-file-server/uploads" # Directory to store uploaded files
storagepath = "/path/to/hmac-file-server/data/" # Directory to store uploaded files metrics_enabled = true # Enable Prometheus metrics
loglevel = "debug" # Logging level: "debug", "info", "warn", "error" metrics_path = "/metrics" # Path for Prometheus metrics endpoint
logfile = "/path/to/hmac-file-server.log" # Path to log file; leave empty to use stdout pid_file = "/var/run/hmac-file-server.pid" # Path to PID file
metricsenabled = true # Enable Prometheus metrics max_upload_size = "10GB" # Maximum file upload size
metricsport = "9090" # Port for Prometheus metrics max_header_bytes = 1048576 # Maximum header size (1MB)
deduplicationenabled = true cleanup_interval = "24h" # Interval for cleanup operations
minfreebytes = "5GB" # Minimum free disk space required max_file_age = "720h" # Maximum age for files (30 days)
filettl = "2Y" # Time-to-live for files pre_cache = true # Pre-cache file structures on startup
filettlenabled = false # Enable TTL checks and cleanup pre_cache_workers = 4 # Number of workers for pre-caching
autoadjustworkers = true # Automatically adjust worker threads based on load pre_cache_interval = "1h" # Interval for pre-cache operations
networkevents = false # Enable detailed network event logging global_extensions = [".txt", ".dat", ".iso", ".mp4", ".mkv", ".avi", ".mov"] # Global allowed extensions
pidfilepath = "./hmac-file-server.pid" # Path to PID file deduplication_enabled = true # Enable file deduplication
precaching = true # Pre-cache file structures on startup min_free_bytes = "1GB" # Minimum free disk space required
file_naming = "original" # File naming strategy: "original", "HMAC"
# New option to force network protocol force_protocol = "" # Force protocol: "http", "https" or empty for auto
forceprotocol = "auto" # Options: "ipv4", "ipv6", "auto" enable_dynamic_workers = true # Enable dynamic worker scaling
worker_scale_up_thresh = 50 # Queue length to scale up workers
worker_scale_down_thresh = 10 # Queue length to scale down workers
``` ```
#### Configuration Options #### Configuration Options
- **listenport**: - **listen_address**:
- *Type*: `String` - *Type*: `String`
- *Description*: Specifies the TCP port on which the server listens for incoming requests. - *Description*: Specifies the address and port on which the server listens for incoming requests.
- *Default*: `"8080"` - *Default*: `":8080"`
- **unixsocket**: - **storage_path**:
- *Type*: `Boolean`
- *Description*: Determines whether to use a Unix domain socket instead of a TCP port for communication.
- *Default*: `false`
- **storagepath**:
- *Type*: `String` - *Type*: `String`
- *Description*: Defines the directory path where uploaded files are stored. Ensure this path exists and has appropriate permissions. - *Description*: Defines the directory path where uploaded files are stored. Ensure this path exists and has appropriate permissions.
- *Default*: `"/path/to/hmac-file-server/data/"` - *Default*: `"/srv/hmac-file-server/uploads"`
- **loglevel**: - **metrics_enabled**:
- *Type*: `String`
- *Description*: Sets the verbosity level of logs.
- *Options*: `"debug"`, `"info"`, `"warn"`, `"error"`
- *Default*: `"debug"`
- **logfile**:
- *Type*: `String`
- *Description*: Specifies the file path for logging. If left empty, logs are output to `stdout`.
- *Default*: `"/path/to/hmac-file-server.log"`
- **metricsenabled**:
- *Type*: `Boolean` - *Type*: `Boolean`
- *Description*: Enables or disables Prometheus metrics collection.
- *Default*: `true`
- **max_upload_size**:
- *Type*: `String`
- *Description*: Maximum allowed file upload size. Supports B, KB, MB, GB, TB units.
- *Default*: `"10GB"`
- **deduplication_enabled**:
- *Type*: `Boolean`
- *Description*: Enables file deduplication to save storage space by using hard links for identical files.
- *Default*: `true`
- **enable_dynamic_workers**:
- *Type*: `Boolean`
- *Description*: Enables automatic scaling of worker threads based on upload queue length.
- *Default*: `true`
- **file_naming**:
- *Type*: `String`
- *Description*: Strategy for naming uploaded files.
- *Options*: `"original"` (preserve original names), `"HMAC"` (use HMAC-based names)
- *Default*: `"original"`
- *Description*: Enables or disables the Prometheus metrics endpoint. - *Description*: Enables or disables the Prometheus metrics endpoint.
- *Default*: `true` - *Default*: `true`
@ -111,50 +120,6 @@ forceprotocol = "auto" # Options: "ipv4", "ipv6", "auto"
- *Description*: Enables or disables file deduplication to optimize storage usage. - *Description*: Enables or disables file deduplication to optimize storage usage.
- *Default*: `true` - *Default*: `true`
- **minfreebytes**:
- *Type*: `String`
- *Description*: Specifies the minimum free disk space required for the server to operate effectively.
- *Default*: `"5GB"`
- **filettl**:
- *Type*: `String`
- *Description*: Sets the default Time-to-Live (TTL) for files, determining how long files are retained before deletion.
- *Format*: Duration (e.g., `"2Y"` for two years)
- *Default*: `"2Y"`
- **filettlenabled**:
- *Type*: `Boolean`
- *Description*: Enables or disables TTL checks and automatic file cleanup based on the `filettl` value.
- *Default*: `false`
- **autoadjustworkers**:
- *Type*: `Boolean`
- *Description*: Automatically adjusts the number of worker threads based on server load and system resources.
- *Default*: `true`
- **networkevents**:
- *Type*: `Boolean`
- *Description*: Enables detailed logging of network events, which can be useful for debugging but may increase log verbosity.
- *Default*: `false`
- **pidfilepath**:
- *Type*: `String`
- *Description*: Specifies the file path where the server writes its Process ID (PID) file. This is useful for managing the server process.
- *Default*: `"./hmac-file-server.pid"`
- **precaching**:
- *Type*: `Boolean`
- *Description*: Enables pre-caching of file structures on startup to improve access speed and performance.
- *Default*: `true`
- **forceprotocol**:
- *Type*: `String`
- *Description*: Specifies the network protocol to use for server communication.
- `"ipv4"`: Forces the server to use IPv4.
- `"ipv6"`: Forces the server to use IPv6.
- `"auto"`: Uses the system's default behavior (dual-stack).
- *Default*: `"auto"`
--- ---
### Deduplication Settings ### Deduplication Settings
@ -163,20 +128,26 @@ forceprotocol = "auto" # Options: "ipv4", "ipv6", "auto"
# Deduplication settings # Deduplication settings
[deduplication] [deduplication]
enabled = true enabled = true
directory = "/path/to/hmac-file-server/deduplication/" # Path to deduplication metadata store directory = "/opt/hmac-file-server/data/dedup" # Path to deduplication storage
maxsize = "1GB" # Maximum file size for deduplication
``` ```
#### Configuration Options #### Configuration Options
- **enabled**: - **enabled**:
- *Type*: `Boolean` - *Type*: `Boolean`
- *Description*: Enables or disables the deduplication feature, which helps in eliminating duplicate files to save storage space. - *Description*: Enables or disables the deduplication feature, which uses hard links to eliminate duplicate files and save storage space.
- *Default*: `true` - *Default*: `true`
- **directory**: - **directory**:
- *Type*: `String` - *Type*: `String`
- *Description*: Specifies the directory path where deduplication metadata is stored. Ensure this directory exists and has appropriate permissions. - *Description*: Specifies the directory path where deduplicated files are stored. Files are organized by their SHA256 hash.
- *Default*: `"/path/to/hmac-file-server/deduplication/"` - *Default*: `"/opt/hmac-file-server/data/dedup"`
- **maxsize**:
- *Type*: `String`
- *Description*: Maximum file size eligible for deduplication. Larger files are not deduplicated to avoid performance impact.
- *Default*: `"1GB"`
--- ---
@ -222,30 +193,32 @@ charset = "utf-8" # Filesystem character set encoding
```toml ```toml
# Timeout settings # Timeout settings
[timeouts] [timeouts]
readtimeout = "3600s" # Maximum time to read a request readtimeout = "4800s" # Maximum time to read a request (80 minutes for large files)
writetimeout = "3600s" # Maximum time to write a response writetimeout = "4800s" # Maximum time to write a response (80 minutes for large files)
idletimeout = "3600s" # Maximum keep-alive time for idle connections idletimeout = "4800s" # Maximum keep-alive time for idle connections
``` ```
#### Configuration Options #### Configuration Options
- **readtimeout**: - **readtimeout**:
- *Type*: `String` - *Type*: `String`
- *Description*: Sets the maximum duration for reading the entire request, including the body. - *Description*: Sets the maximum duration for reading the entire request, including the body. Extended timeout for large file uploads.
- *Format*: Duration (e.g., `"3600s"` for one hour) - *Format*: Duration (e.g., `"4800s"` for 80 minutes)
- *Default*: `"3600s"` - *Default*: `"4800s"`
- **writetimeout**: - **writetimeout**:
- *Type*: `String` - *Type*: `String`
- *Description*: Defines the maximum duration before timing out writes of the response. - *Description*: Defines the maximum duration before timing out writes of the response. Extended timeout for large file downloads.
- *Format*: Duration (e.g., `"3600s"` for one hour) - *Format*: Duration (e.g., `"4800s"` for 80 minutes)
- *Default*: `"3600s"` - *Default*: `"4800s"`
- **idletimeout**: - **idletimeout**:
- *Type*: `String` - *Type*: `String`
- *Description*: Specifies the maximum amount of time to wait for the next request when keep-alives are enabled. - *Description*: Specifies the maximum amount of time to wait for the next request when keep-alives are enabled.
- *Format*: Duration (e.g., `"3600s"` for one hour) - *Format*: Duration (e.g., `"4800s"` for 80 minutes)
- *Default*: `"3600s"` - *Default*: `"4800s"`
**Note**: These extended timeout values are specifically configured for handling large file uploads and downloads (GB-sized files). Ensure your reverse proxy configuration has matching timeout values.
--- ---
@ -321,8 +294,8 @@ maxversions = 1 # Number of file versions to retain
```toml ```toml
# Logging settings # Logging settings
[logging] [logging]
level = "debug" level = "info"
file = "/path/to/hmac-file-server.log" file = "/var/log/hmac-file-server.log"
max_size = 100 # Maximum log file size in MB max_size = 100 # Maximum log file size in MB
max_backups = 7 # Number of backup log files to keep max_backups = 7 # Number of backup log files to keep
max_age = 30 # Maximum age of log files in days max_age = 30 # Maximum age of log files in days
@ -335,12 +308,12 @@ compress = true # Compress old log files
- *Type*: `String` - *Type*: `String`
- *Description*: Sets the verbosity level of logs. - *Description*: Sets the verbosity level of logs.
- *Options*: `"debug"`, `"info"`, `"warn"`, `"error"` - *Options*: `"debug"`, `"info"`, `"warn"`, `"error"`
- *Default*: `"debug"` - *Default*: `"info"`
- **file**: - **file**:
- *Type*: `String` - *Type*: `String`
- *Description*: Specifies the file path for logging. If left empty, logs are output to `stdout`. - *Description*: Specifies the file path for logging. If left empty, logs are output to `stdout`.
- *Default*: `"/path/to/hmac-file-server.log"` - *Default*: `"/var/log/hmac-file-server.log"`
- **max_size**: - **max_size**:
- *Type*: `Integer` - *Type*: `Integer`
@ -369,43 +342,41 @@ compress = true # Compress old log files
```toml ```toml
# Upload settings # Upload settings
[uploads] [uploads]
resumableuploadsenabled = false allowed_extensions = [".zip", ".rar", ".7z", ".tar.gz", ".tgz", ".gpg", ".enc", ".pgp"]
chunkeduploadsenabled = true chunked_uploads_enabled = true
chunksize = "32MB" # Chunk size for uploads chunk_size = "10MB" # Chunk size for uploads
allowedextensions = [ resumable_uploads_enabled = true
".txt", ".pdf", ".png", ".jpg", ".jpeg", ".gif", max_resumable_age = "48h" # Maximum age for resumable uploads
".mpeg", ".mpg", ".m4v", ".3gp", ".3g2", ".mp3", ".ogg"
]
``` ```
#### Configuration Options #### Configuration Options
- **resumableuploadsenabled**: - **allowed_extensions**:
- *Type*: `Boolean`
- *Description*: Enables or disables support for resumable (chunked) file uploads.
- *Default*: `false`
- **chunkeduploadsenabled**:
- *Type*: `Boolean`
- *Description*: Specifically enables or disables chunked uploads.
- *Default*: `true`
- **chunksize**:
- *Type*: `String`
- *Description*: Defines the size of each chunk in chunked uploads.
- *Format*: Size (e.g., `"32MB"`)
- *Default*: `"32MB"`
- **allowedextensions**:
- *Type*: `Array of Strings` - *Type*: `Array of Strings`
- *Description*: Lists the file extensions permitted for upload. - *Description*: Lists the file extensions permitted for upload.
- *Default*: - *Default*: `[".zip", ".rar", ".7z", ".tar.gz", ".tgz", ".gpg", ".enc", ".pgp"]`
```toml
allowedextensions = [ - **chunked_uploads_enabled**:
".txt", ".pdf", ".png", ".jpg", ".jpeg", ".gif", - *Type*: `Boolean`
".mpeg", ".mpg", ".m4v", ".3gp", ".3g2", ".mp3", ".ogg" - *Description*: Enables or disables chunked file uploads for better performance with large files.
] - *Default*: `true`
```
- **chunk_size**:
- *Type*: `String`
- *Description*: Defines the size of each chunk in chunked uploads.
- *Format*: Size (e.g., `"10MB"`)
- *Default*: `"10MB"`
- **resumable_uploads_enabled**:
- *Type*: `Boolean`
- *Description*: Enables or disables support for resumable uploads that can be continued after interruption.
- *Default*: `true`
- **max_resumable_age**:
- *Type*: `String`
- *Description*: Maximum time a resumable upload session remains valid.
- *Format*: Duration (e.g., `"48h"`)
- *Default*: `"48h"`
--- ---
@ -414,30 +385,34 @@ allowedextensions = [
```toml ```toml
# Downloads settings # Downloads settings
[downloads] [downloads]
resumabledownloadsenabled = false resumable_downloads_enabled = true
chunkeddownloadsenabled = true chunked_downloads_enabled = true
chunksize = "32MB" chunk_size = "8192" # Chunk size for downloads
allowed_extensions = [".txt", ".pdf", ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".svg", ".webp"]
``` ```
#### Configuration Options #### Configuration Options
- **resumabledownloadsenabled**: - **resumable_downloads_enabled**:
- *Type*: `Boolean` - *Type*: `Boolean`
- *Description*: Enables or disables support for resumable (chunked) downloads. - *Description*: Enables or disables support for resumable downloads.
- *Default*: `false`
- **chunkeddownloadsenabled**:
- *Type*: `Boolean`
- *Description*: Specifically enables or disables chunked downloads.
- *Default*: `true` - *Default*: `true`
- **chunksize**: - **chunked_downloads_enabled**:
- *Type*: `Boolean`
- *Description*: Enables or disables chunked downloads for better performance.
- *Default*: `true`
- **chunk_size**:
- *Type*: `String` - *Type*: `String`
- *Description*: Defines the size of each chunk in chunked downloads. - *Description*: Defines the size of each chunk in chunked downloads.
- *Format*: Size (e.g., `"32MB"`) - *Format*: Size (e.g., `"8192"` bytes)
- *Default*: `"32MB"` - *Default*: `"8192"`
> **Note**: Downloads inherit allowed extensions from the uploads configuration. There is no separate `allowedextensions` setting for downloads. - **allowed_extensions**:
- *Type*: `Array of Strings`
- *Description*: Lists the file extensions permitted for download.
- *Default*: `[".txt", ".pdf", ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".svg", ".webp"]`
--- ---
@ -447,12 +422,12 @@ chunksize = "32MB"
# ClamAV settings # ClamAV settings
[clamav] [clamav]
clamavenabled = true clamavenabled = true
clamavsocket = "/path/to/clamav/clamd.ctl" # Path to ClamAV socket clamavsocket = "/var/run/clamav/clamd.ctl" # Path to ClamAV socket
numscanworkers = 4 # Number of concurrent scan workers numscanworkers = 2 # Number of concurrent scan workers
scanfileextensions = [ # Only scan potentially dangerous file types, skip large media files
".exe", ".dll", ".bin", ".com", ".bat", scanfileextensions = [".txt", ".pdf", ".doc", ".docx", ".xls", ".xlsx", ".exe", ".zip", ".rar", ".7z", ".tar", ".gz"]
".sh", ".php", ".js" # Skip scanning files larger than 200MB (ClamAV limit)
] maxscansize = "200MB"
``` ```
#### Configuration Options #### Configuration Options
@ -465,23 +440,22 @@ scanfileextensions = [
- **clamavsocket**: - **clamavsocket**:
- *Type*: `String` - *Type*: `String`
- *Description*: Specifies the file path to the ClamAV socket (`.ctl` file). Ensure ClamAV is installed and the socket path is correct. - *Description*: Specifies the file path to the ClamAV socket (`.ctl` file). Ensure ClamAV is installed and the socket path is correct.
- *Default*: `"/path/to/clamav/clamd.ctl"` - *Default*: `"/var/run/clamav/clamd.ctl"`
- **numscanworkers**: - **numscanworkers**:
- *Type*: `Integer` - *Type*: `Integer`
- *Description*: Sets the number of concurrent workers dedicated to scanning files with ClamAV. - *Description*: Sets the number of concurrent workers dedicated to scanning files with ClamAV.
- *Default*: `4` - *Default*: `2`
- **scanfileextensions**: - **scanfileextensions**:
- *Type*: `Array of Strings` - *Type*: `Array of Strings`
- *Description*: Lists the file extensions that should be scanned for viruses. - *Description*: Lists the file extensions that should be scanned for viruses. Excludes large media files for performance.
- *Default*: - *Default*: `[".txt", ".pdf", ".doc", ".docx", ".xls", ".xlsx", ".exe", ".zip", ".rar", ".7z", ".tar", ".gz"]`
```toml
scanfileextensions = [ - **maxscansize**:
".exe", ".dll", ".bin", ".com", ".bat", - *Type*: `String`
".sh", ".php", ".js" - *Description*: Maximum file size for virus scanning. Files larger than this are skipped to avoid ClamAV limits.
] - *Default*: `"200MB"`
```
--- ---
@ -532,21 +506,23 @@ redishealthcheckinterval = "120s" # Interval for Redis health checks
```toml ```toml
# Workers settings # Workers settings
[workers] [workers]
numworkers = 10 # Number of worker threads numworkers = 4 # Number of worker threads
uploadqueuesize = 5000 # Size of upload queue uploadqueuesize = 50 # Size of upload queue
``` ```
#### Configuration Options #### Configuration Options
- **numworkers**: - **numworkers**:
- *Type*: `Integer` - *Type*: `Integer`
- *Description*: Specifies the number of worker threads to handle file operations. - *Description*: Specifies the base number of worker threads to handle file operations. Works with dynamic worker scaling.
- *Default*: `10` - *Default*: `4`
- **uploadqueuesize**: - **uploadqueuesize**:
- *Type*: `Integer` - *Type*: `Integer`
- *Description*: Sets the size of the upload queue buffer. - *Description*: Sets the size of the upload queue buffer. Used with dynamic scaling thresholds.
- *Default*: `5000` - *Default*: `50`
**Note**: When `enable_dynamic_workers = true` in the server section, the worker count automatically scales between 4-8 workers based on queue length (scale up at 50, scale down at 10).
--- ---
@ -696,98 +672,89 @@ The enhanced command-line validation system provides comprehensive coverage with
## Example Configuration ## Example Configuration
Below is an example `config.toml` file with default settings: Below is an example `config.toml` file with current settings:
```toml ```toml
# Example HMAC File Server configuration # Example HMAC File Server configuration
# Server configuration [server]
listenport = "8080" listen_address = ":8080"
bind_ip = "0.0.0.0" storage_path = "/srv/hmac-file-server/uploads"
unixsocket = false metrics_enabled = true
storagepath = "/path/to/hmac-file-server/data/" metrics_path = "/metrics"
metricsenabled = true pid_file = "/var/run/hmac-file-server.pid"
metricsport = "9090" max_upload_size = "10GB"
deduplicationenabled = true max_header_bytes = 1048576
minfreebytes = "5GB" cleanup_interval = "24h"
filettl = "2Y" max_file_age = "720h"
filettlenabled = false pre_cache = true
autoadjustworkers = true pre_cache_workers = 4
networkevents = false pre_cache_interval = "1h"
pidfilepath = "./hmac-file-server.pid" global_extensions = [".txt", ".dat", ".iso", ".mp4", ".mkv", ".avi", ".mov", ".wmv", ".flv", ".webm", ".mpeg"]
precaching = true deduplication_enabled = true
filenaming = "HMAC" min_free_bytes = "1GB"
forceprotocol = "auto" file_naming = "original"
force_protocol = ""
enable_dynamic_workers = true
worker_scale_up_thresh = 50
worker_scale_down_thresh = 10
[uploads]
allowed_extensions = [".zip", ".rar", ".7z", ".tar.gz", ".tgz", ".gpg", ".enc", ".pgp"]
chunked_uploads_enabled = true
chunk_size = "10MB"
resumable_uploads_enabled = true
max_resumable_age = "48h"
[downloads]
resumable_downloads_enabled = true
chunked_downloads_enabled = true
chunk_size = "8192"
allowed_extensions = [".txt", ".pdf", ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".svg", ".webp"]
[security]
secret = "f6g4ldPvQM7O2UTFeBEUUj33VrXypDAcsDt0yqKrLiOr5oQW"
enablejwt = false
jwtsecret = "f6g4ldPvQM7O2UTFeBEUUj33VrXypDAcsDt0yqKrLiOr5oQW"
jwtalgorithm = "HS256"
jwtexpiration = "24h"
# Logging settings
[logging] [logging]
level = "debug" level = "info"
file = "/path/to/hmac-file-server.log" file = "/var/log/hmac-file-server.log"
max_size = 100 max_size = 100
max_backups = 7 max_backups = 7
max_age = 30 max_age = 30
compress = true compress = true
# Deduplication settings
[deduplication] [deduplication]
enabled = true enabled = true
directory = "/path/to/hmac-file-server/deduplication/" directory = "/opt/hmac-file-server/data/dedup"
maxsize = "1GB"
# ISO settings
[iso] [iso]
enabled = false enabled = true
size = "1TB" size = "1GB"
mountpoint = "/path/to/hmac-file-server/iso/" mountpoint = "/mnt/iso"
charset = "utf-8" charset = "utf-8"
containerfile = "/mnt/iso/container.iso"
# Timeout settings
[timeouts] [timeouts]
readtimeout = "3600s" readtimeout = "4800s"
writetimeout = "3600s" writetimeout = "4800s"
idletimeout = "3600s" idletimeout = "4800s"
# Security settings
[security]
secret = "your-secure-secret-key"
enablejwt = false
jwtsecret = "your-jwt-secret"
jwtalgorithm = "HS256"
jwtexpiration = "24h"
# Versioning settings
[versioning] [versioning]
enableversioning = false enableversioning = false
maxversions = 1 maxversions = 1
# Upload settings
[uploads]
resumableuploadsenabled = false
chunkeduploadsenabled = true
chunksize = "32MB"
allowedextensions = [
".txt", ".pdf", ".png", ".jpg", ".jpeg", ".gif",
".bmp", ".tiff", ".svg", ".webp", ".wav", ".mp4",
".avi", ".mkv", ".mov", ".wmv", ".flv", ".webm",
".mpeg", ".mpg", ".m4v", ".3gp", ".3g2", ".mp3", ".ogg"
]
# Download settings
[downloads]
resumabledownloadsenabled = false
chunkeddownloadsenabled = true
chunksize = "32MB"
# ClamAV settings
[clamav] [clamav]
clamavenabled = true clamavenabled = true
clamavsocket = "/path/to/clamav/clamd.ctl" clamavsocket = "/var/run/clamav/clamd.ctl"
numscanworkers = 4 numscanworkers = 2
scanfileextensions = [ scanfileextensions = [".txt", ".pdf", ".doc", ".docx", ".xls", ".xlsx", ".exe", ".zip", ".rar", ".7z", ".tar", ".gz"]
".exe", ".dll", ".bin", ".com", ".bat", maxscansize = "200MB"
".sh", ".php", ".js"
]
# Redis settings
[redis] [redis]
redisenabled = true redisenabled = true
redisdbindex = 0 redisdbindex = 0
@ -795,14 +762,53 @@ redisaddr = "localhost:6379"
redispassword = "" redispassword = ""
redishealthcheckinterval = "120s" redishealthcheckinterval = "120s"
# Workers settings
[workers] [workers]
numworkers = 10 numworkers = 4
uploadqueuesize = 5000 uploadqueuesize = 50
[file]
# Add file-specific configurations here
[build]
version = "3.2"
``` ```
--- ---
## Configuration Best Practices
### Performance Optimizations
**Large File Handling**: The server is configured for efficient large file uploads:
- Extended timeouts (`4800s`) prevent disconnections during GB-sized transfers
- Dynamic worker scaling (`enable_dynamic_workers = true`) adjusts capacity automatically
- Chunked uploads (`chunk_size = "10MB"`) improve reliability for large files
**Storage Efficiency**:
- Deduplication (`enabled = true`, `maxsize = "1GB"`) uses hard links to save space
- Selective virus scanning (`scanfileextensions`) skips large media files for performance
- Automatic cleanup (`cleanup_interval = "24h"`) maintains disk space
**Network Configuration**:
- Reverse proxy timeouts must match server settings (`proxy_read_timeout 4800`)
- Upload size limits should accommodate `max_upload_size = "10GB"`
- Queue settings (`uploadqueuesize = 50`) balance memory usage and throughput
### Security Considerations
- Use strong HMAC secrets (64+ characters)
- Limit file extensions based on your use case
- Enable ClamAV for dangerous file types only
- Monitor logs for authentication failures
### Monitoring
- Prometheus metrics available at `/metrics` endpoint
- Log rotation configured to prevent disk space issues
- Worker scaling and queue metrics help identify bottlenecks
---
## Setup Instructions ## Setup Instructions
### 1. HMAC File Server Installation ### 1. HMAC File Server Installation
@ -926,7 +932,7 @@ To set up a reverse proxy for the HMAC File Server, you can use either Apache2 o
For production deployments, consider the following reverse proxy best practices: For production deployments, consider the following reverse proxy best practices:
- **Timeouts**: Set reasonable timeouts (e.g., `proxy_read_timeout 300;` in Nginx) to avoid hanging connections. - **Timeouts**: Set extended timeouts (e.g., `proxy_read_timeout 4800;` in Nginx) for large file handling.
- **Buffer Sizes**: Increase buffer sizes for large file uploads/downloads if needed (e.g., `client_max_body_size 2G;` in Nginx). - **Buffer Sizes**: Increase buffer sizes for large file uploads/downloads if needed (e.g., `client_max_body_size 2G;` in Nginx).
- **Headers**: Always set security headers (`X-Content-Type-Options`, `X-Frame-Options`, `X-XSS-Protection`). - **Headers**: Always set security headers (`X-Content-Type-Options`, `X-Frame-Options`, `X-XSS-Protection`).
- **Forwarded Headers**: Ensure `X-Forwarded-For` and `X-Forwarded-Proto` are set for correct client IP and protocol logging. - **Forwarded Headers**: Ensure `X-Forwarded-For` and `X-Forwarded-Proto` are set for correct client IP and protocol logging.
@ -1139,77 +1145,77 @@ A sample `config.toml` for Docker deployments:
```toml ```toml
[server] [server]
listenport = "8080" listen_address = ":8080"
unixsocket = false storage_path = "/srv/hmac-file-server/uploads"
storagepath = "/opt/hmac-file-server/data/uploads" metrics_enabled = true
metricsenabled = true metrics_path = "/metrics"
metricsport = "9090" pid_file = "/var/run/hmac-file-server.pid"
deduplicationenabled = true max_upload_size = "10GB"
minfreebytes = "5GB" deduplication_enabled = true
filettl = "2y" min_free_bytes = "1GB"
filettlenabled = false file_naming = "original"
autoadjustworkers = true enable_dynamic_workers = true
networkevents = false worker_scale_up_thresh = 50
pidfilepath = "./hmac-file-server.pid" worker_scale_down_thresh = 10
precaching = false
[deduplication] [uploads]
enabled = true allowed_extensions = [".zip", ".rar", ".7z", ".tar.gz", ".tgz", ".gpg", ".enc", ".pgp"]
directory = "/opt/hmac-file-server/data/duplicates" chunked_uploads_enabled = true
chunk_size = "10MB"
resumable_uploads_enabled = true
max_resumable_age = "48h"
[downloads]
resumable_downloads_enabled = true
chunked_downloads_enabled = true
chunk_size = "8192"
allowed_extensions = [".txt", ".pdf", ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".svg", ".webp"]
[security]
secret = "f6g4ldPvQM7O2UTFeBEUUj33VrXypDAcsDt0yqKrLiOr5oQW"
enablejwt = false
jwtsecret = "f6g4ldPvQM7O2UTFeBEUUj33VrXypDAcsDt0yqKrLiOr5oQW"
jwtalgorithm = "HS256"
jwtexpiration = "24h"
[logging] [logging]
level = "debug" level = "info"
file = "./hmac-file-server.log" file = "/var/log/hmac-file-server.log"
max_size = 100 max_size = 100
max_backups = 7 max_backups = 7
max_age = 30 max_age = 30
compress = true compress = true
[deduplication]
enabled = true
directory = "./deduplication"
maxsize = "1GB"
[iso] [iso]
enabled = false enabled = true
size = "1TB" size = "1GB"
mountpoint = "/mnt/nfs_vol01/hmac-file-server/iso/" mountpoint = "/mnt/iso"
charset = "utf-8" charset = "utf-8"
containerfile = "/mnt/iso/container.iso"
[timeouts] [timeouts]
readtimeout = "3600s" readtimeout = "4800s"
writetimeout = "3600s" writetimeout = "4800s"
idletimeout = "3600s" idletimeout = "4800s"
[security]
secret = "hmac-file-server-is-the-win"
[versioning] [versioning]
enableversioning = false enableversioning = false
maxversions = 1 maxversions = 1
[uploads]
resumableuploadsenabled = false
chunkeduploadsenabled = true
chunksize = "32MB"
allowedextensions = [
".txt", ".pdf", ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".svg", ".webp",
".wav", ".mp4", ".avi", ".mkv", ".mov", ".wmv", ".flv", ".webm", ".mpeg", ".mpg",
".m4v", ".3gp", ".3g2", ".mp3", ".ogg"
]
[downloads]
chunkeddownloadsenabled = false
chunksize = "32MB"
allowedextensions = [
".txt", ".pdf", ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".svg", ".webp",
".wav", ".mp4", ".avi", ".mkv", ".mov", ".wmv", ".flv", ".webm", ".mpeg", ".mpg",
".m4v", ".3gp", ".3g2", ".mp3", ".ogg"
]
[clamav] [clamav]
clamavenabled = false clamavenabled = true
clamavsocket = "/var/run/clamav/clamd.ctl" clamavsocket = "/var/run/clamav/clamd.ctl"
numscanworkers = 4 numscanworkers = 2
scanfileextensions = [".exe", ".dll", ".bin", ".com", ".bat", ".sh", ".php", ".js"] scanfileextensions = [".txt", ".pdf", ".doc", ".docx", ".xls", ".xlsx", ".exe", ".zip", ".rar", ".7z", ".tar", ".gz"]
maxscansize = "200MB"
[redis] [redis]
redisenabled = false redisenabled = true
redisdbindex = 0 redisdbindex = 0
redisaddr = "localhost:6379" redisaddr = "localhost:6379"
redispassword = "" redispassword = ""
@ -1217,10 +1223,13 @@ redishealthcheckinterval = "120s"
[workers] [workers]
numworkers = 4 numworkers = 4
uploadqueuesize = 5000 uploadqueuesize = 50
[file] [file]
filerevision = 1 # Add file-specific configurations here
[build]
version = "3.2"
``` ```
### Quickstart with Docker Compose ### Quickstart with Docker Compose

86
tests/README.md Normal file
View File

@ -0,0 +1,86 @@
# HMAC File Server Test Suite
This directory contains test scripts, monitoring tools, and test data files for the HMAC File Server.
## Test Scripts
### Protocol Testing
- `test_final_xmpp.sh` - Complete XEP-0363 protocol testing (all variants: v1, v2, v3, token)
- `test_xmpp_simulation.sh` - XMPP client simulation for upload testing
- `test_url_formats.sh` - URL format validation and testing
- `verify_xmpp_upload.sh` - XMPP upload verification script
### Performance Testing
- `comprehensive_upload_test.sh` - Comprehensive upload performance testing
- `test_upload_queue.sh` - Queue performance and concurrent upload testing
- `test_upload_completion.sh` - Upload completion and reliability testing
### Feature Testing
- `test_deduplication.sh` - File deduplication functionality testing
- `test_direct_connection.sh` - Direct server connection testing
- `test_path_discovery.sh` - Path discovery and routing testing
### Debugging & Monitoring
- `debug_upload.sh` - Upload debugging and troubleshooting script
- `monitor_server.sh` - Server status and performance monitoring
- `monitor_nginx.sh` - Nginx proxy monitoring
- `monitor_uploads.sh` - Upload activity monitoring
## Test Data Files
### Small Test Files
- `test_1mb.txt` / `test_1mb.bin` - 1MB test files for basic functionality
- `test_upload.txt` - Small text file for quick testing
- `chunk_0.bin` - Chunked upload test data
### Large Test Files
- `test_50mb.bin` - 50MB file for medium-size upload testing
- `test_215mb.bin` - 215MB file for large upload testing
- `test_4gb.bin` / `test_4gb.txt` - 4GB files for stress testing
## Analysis Tools
- `xep0363_analysis.ipynb` - Jupyter notebook for XEP-0363 protocol analysis
## Usage Examples
### Quick Protocol Test
```bash
cd tests
./test_final_xmpp.sh
```
### Performance Testing
```bash
cd tests
./comprehensive_upload_test.sh
./test_upload_queue.sh
```
### Deduplication Testing
```bash
cd tests
./test_deduplication.sh
```
### Monitor Server
```bash
cd tests
./monitor_server.sh
```
## Test Environment
These tests are designed to work with:
- HMAC File Server 3.2
- nginx reverse proxy (standard configuration)
- Extended timeout settings (4800s)
- Deduplication enabled
- Dynamic worker scaling
## Notes
- Large test files (4GB) are intended for stress testing extended timeout configurations
- All scripts include proper error handling and cleanup
- Monitor scripts provide real-time status information
- Test scripts validate both success and failure scenarios