Version: v0.2.0-beta | Status: Beta release - Core protocol complete, hot-reload and performance benchmarks added
A lightweight, cross-platform TFTP (Trivial File Transfer Protocol) daemon written in C++17. Implements RFC 1350 with full support for TFTP options (RFC 2347), windowed transfers, and comprehensive security features.
- RFC 1350 Compliant: Full TFTP protocol implementation
- TFTP Options (RFC 2347): blksize, timeout, tsize, windowsize negotiation
- Windowed Transfers: Sliding window with configurable window size
- Retransmission: Automatic retry with configurable max retries and timeout handling
- Transfer Modes: netascii, octet, and mail mode support
- Access Control: Directory allowlists and path traversal protection
- File Filtering: Extension allowlists and file size limits
- Client Filtering: IP address allowlists
- Permission Control: Configurable read/write permissions
- JSON Configuration: Full configuration file support with validation
- Configuration Serialization: Save and export configuration
- Command-line Overrides: Runtime configuration options
- Hot Reload: Reload configuration without restart (SIGHUP signal)
- Cross-platform: Linux, macOS, and Windows
- IPv6 Support: Optional IPv6 support
- Modern C++: Built with C++17 standard
- Logging: Comprehensive logging with configurable levels
Copyright 2024 SimpleDaemons
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- CMake 3.16 or higher
- C++17 compatible compiler
- jsoncpp library
- Platform-specific development libraries
mkdir build
cd build
cmake ..
makeBUILD_TESTS: Build test suite (default: ON)BUILD_EXAMPLES: Build examples (default: OFF)ENABLE_LOGGING: Enable logging (default: ON)ENABLE_IPV6: Enable IPv6 support (default: ON)
# Start server with default settings
./simple-tftpd start
# Start server with custom configuration
./simple-tftpd start --config /etc/simple-tftpd/config.json
# Start server with command-line options
./simple-tftpd start --listen 0.0.0.0 --port 69 --root /var/tftp--help, -h: Show help message--version, -v: Show version information--config, -c FILE: Use specified configuration file--verbose, -V: Enable verbose logging--daemon, -d: Run as daemon--foreground, -f: Run in foreground--listen ADDR: Listen on specific address--port PORT: Listen on specific port--root DIR: Set root directory for file operations
start: Start the TFTP serverstop: Stop the TFTP serverrestart: Restart the TFTP serverstatus: Show server statusreload: Reload configurationtest: Test server configurationstats: Show server statisticsconnections: List active connections
The daemon can be configured using a JSON configuration file or command-line options.
{
"network": {
"listen_address": "0.0.0.0",
"listen_port": 69,
"ipv6_enabled": true
},
"filesystem": {
"root_directory": "/var/tftp",
"allowed_directories": ["/var/tftp/public", "/var/tftp/private"]
},
"security": {
"read_enabled": true,
"write_enabled": false,
"max_file_size": 104857600,
"overwrite_protection": true,
"allowed_extensions": ["bin", "img"],
"allowed_clients": ["10.0.0.10", "fe80::1"]
},
"performance": {
"block_size": 512,
"timeout": 5,
"window_size": 1,
"max_retries": 5
},
"logging": {
"level": "INFO",
"log_file": "/var/log/simple-tftpd.log",
"console_logging": true
}
}- Read Request (RRQ): Client downloads files from server
- Write Request (WRQ): Client uploads files to server
- Data Packets: File data transfer
- Acknowledgment Packets: Transfer confirmation
- Error Packets: Error reporting
- Transfer Modes: netascii, octet, mail
- Configurable read/write permissions
- File size limits
- Directory access restrictions
- Overwrite protection
- Client address validation
- File extension allow lists
- Configurable block sizes (default: 512 bytes)
- Adjustable timeouts
- Windowed transfer support
- Connection pooling
- Efficient memory management
The daemon provides comprehensive logging with configurable levels:
- DEBUG: Detailed debugging information
- INFO: General information messages
- WARNING: Warning messages
- ERROR: Error messages
- FATAL: Fatal error messages
# Download a file
tftp localhost 69
tftp> get filename.txt
# Upload a file (if write enabled)
tftp localhost 69
tftp> put filename.txtCreate /etc/systemd/system/simple-tftpd.service:
[Unit]
Description=Simple TFTP Daemon
After=network.target
[Service]
Type=simple
User=tftp
ExecStart=/usr/bin/simple-tftpd start --config /etc/simple-tftpd/config.json
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.targetsimple-tftpd/
├── cmake/ # CMake configuration files
├── config/ # Configuration files
├── docs/ # Documentation
├── include/ # Header files
│ └── simple_tftpd/
├── scripts/ # Build and utility scripts
├── src/ # Source files
│ ├── core/ # Core TFTP functionality
│ ├── utils/ # Utility classes
│ ├── tests/ # Test suite
│ └── examples/ # Example programs
├── tools/ # Development tools
├── CMakeLists.txt # Main CMake file
└── README.md # This file
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Run the unit test suite:
cd build
make simple-tftpd-tests
./bin/simple-tftpd-testsRun the integration test suite (requires server to be built):
cd build
make simple-tftpd-integration-tests
./bin/simple-tftpd-integration-testsRun all tests via CMake:
cd build
make testThe integration tests cover:
- Basic read/write transfers
- Option negotiation (blksize, timeout, tsize, windowsize)
- Windowed transfers
- Security features (extension filtering, client allowlists)
- Error handling
- Transfer modes (netascii, octet, mail)
- Permission Denied: Ensure the daemon has access to the root directory
- Port Already in Use: Check if port 69 is available or use a different port
- File Not Found: Verify the root directory exists and contains the requested files
- Connection Refused: Check firewall settings and ensure the daemon is running
Enable debug logging for troubleshooting:
./simple-tftpd start --verbose- TFTP options support (blksize, timeout, tsize, windowsize)
- Windowed transfers with retransmission
- JSON configuration serialization
- File extension and client address filtering
- Integration test suite
- Configuration hot-reload (SIGHUP signal support)
- Enhanced test coverage (integration tests + performance benchmarks)
- Performance benchmarks
- Multicast TFTP support
- Authentication and authorization
- SSL/TLS support
- Web-based management interface
- SNMP monitoring
- Rate limiting
- Advanced logging (syslog, structured logging)
For issues and questions:
- Check the documentation
- Search existing issues
- Create a new issue with detailed information
- RFC 1350: The TFTP Protocol
- RFC 2347: TFTP Option Extension
- RFC 2348: TFTP Blocksize Option
- RFC 2349: TFTP Timeout Interval and Transfer Size Options