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.0.1.tar.gz (6.0 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.0.1-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.0.1.tar.gz.

File metadata

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

File hashes

Hashes for simpletftps-1.0.1.tar.gz
Algorithm Hash digest
SHA256 96aa27287e1e064988bbff0393d15769a4cd4830aa7ba5c247a856d602d58c67
MD5 708f1b010ce542f167670896df38c864
BLAKE2b-256 ea714bab9fcafde85a44ad814375af9029b39ae42b04137b9f724d1a9c038687

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simpletftps-1.0.1-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 92d17492922ec801f1dc577c2aea1e69105b0bf187cd6de6c20aabe09d1bcd61
MD5 e3f30b4e2b02f42e3a75a058c4b8ecf6
BLAKE2b-256 25ab7b1d67d0d3f224d06d16307b44cf114b17c1bd6e711e44f729ba3480d913

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