A lightweight, cross-platform TFTP (Trivial File Transfer Protocol) daemon written in C++.
- Cross-platform: Supports Linux, macOS, and Windows
- RFC Compliant: Implements TFTP protocol according to RFC 1350
- Modern C++: Built with C++17 standard
- Configurable: JSON-based configuration with command-line overrides
- Secure: Configurable access controls and file restrictions
- Logging: Comprehensive logging with configurable levels
- IPv6 Support: Optional IPv6 support
- Performance: Configurable block sizes and timeouts
- Statistics: Built-in connection and transfer statistics
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 ..
make
BUILD_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"]
},
"security": {
"read_enabled": true,
"write_enabled": false,
"max_file_size": 104857600
},
"performance": {
"block_size": 512,
"timeout": 5
},
"logging": {
"level": "INFO",
"log_file": "/var/log/simple-tftpd.log"
}
}
- 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
- 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.txt
Create /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.target
simple-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 test suite:
cd build
make test
- 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)
- 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