Skip to main content

a simple TFTP server written in rust with read and write callbacks

Project description

simpleTFTPS

simpleTFTPS is a high-performance TFTP (Trivial File Transfer Protocol) server written in Rust, providing seamless integration for C++ and Python through native bindings. It allows developers to implement custom GET and PUT logic via simple callbacks.

Features

  • Core in Rust: Fast, safe, and concurrent TFTP engine.
  • Unified Build: Simple Makefile to build everything (Rust, C++, Python).
  • Easy Integration: Native bindings for C++ and Python.
  • Customizable: Simple callback system to handle file requests and uploads.
  • Multi-threaded: Handles multiple client requests simultaneously using Rust threads.
  • Modern Python Support: Compatible with Python 3.7+ (GIL-safe).

Prerequisites

  • Rust: Installation guide
  • C++ Compiler: GCC (G++) or Clang supporting C++17
  • Python: Python 3.7 or higher (for Python bindings)
  • Make: To use the simplified build system
  • libcurl: Required for integration tests

Quick Start

Build Everything

To build the Rust library, C++ examples, and Python extension:

make

Run All Tests

To run Rust unit tests, C++ integration tests, and Python integration tests:

make test

Clean Up

To remove all build artifacts:

make clean

Usage

C++

Include the header and link against the Rust static library. Use the run() function with your callbacks.

#include "simpletftps.hpp"

extern "C" char* my_get_callback(const char* file) {
    return strdup("Data content");
}

int main() {
    run(my_get_callback, nullptr, "127.0.0.1:6969");
    return 0;
}

Python

Import the module and run the server in a thread (as run is blocking).

import simpleTFTPS
import threading

def cb_get(file):
    return "File content"

def cb_put(file):
    return False

threading.Thread(target=simpleTFTPS.run, args=("127.0.0.1:9001", cb_get, cb_put), daemon=True).start()

Project Structure

  • simpleTFTPS/: Rust implementation of the TFTP engine.
  • include/: C++ header and Python binding implementation.
  • tests/: Integration tests for C++, Python, and Rust.
  • Makefile: Unified build system.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simpletftps-1.1.0.tar.gz (23.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simpletftps-1.1.0-cp313-cp313-manylinux_2_39_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

File details

Details for the file simpletftps-1.1.0.tar.gz.

File metadata

  • Download URL: simpletftps-1.1.0.tar.gz
  • Upload date:
  • Size: 23.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for simpletftps-1.1.0.tar.gz
Algorithm Hash digest
SHA256 cf3d31089c2470168a47211ea146b8e7ab3435fec39d1516215ab2c75572d3de
MD5 596059e508ec7529a31fc305cd721ada
BLAKE2b-256 21e726cb878437fd9140bd162d482dbd87b490129f09b4fbd1e364f709d5d28e

See more details on using hashes here.

File details

Details for the file simpletftps-1.1.0-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for simpletftps-1.1.0-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 ff681df8c7026cd8cb0f44659e528cd3ead70de9a1eb1820bd42b3eea4e1a9a3
MD5 02ee35d878e13fbef1eff3e6fffeddd8
BLAKE2b-256 827672b8e9c6839497ab6111182d70e6d4b3ca36dca1c7e49557568f4af4b7d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page