Skip to content

xspeed1989/file_deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Deploy

A secure file deployment tool that facilitates file transfers between development and target environments, with support for post-deployment scripting and remote debugging capabilities.

Features

  • Secure file transfer using TLS encryption
  • Password authentication for upload protection
  • Post-upload script execution
  • Remote deployment automation
  • Directory structure preservation during transfers
  • Cross-platform compatibility (Linux/Windows)

Prerequisites

  • Rust 1.74.0 or later
  • Cargo (Rust's package manager)

Compilation

Building from source

# Clone the repository
git clone https://github.com/xspeed1989/file_deploy.git
cd file_deploy

# Build in debug mode
cargo build

# Build in release mode for optimized performance
cargo build --release

Cross-compilation for Windows from Linux

# Install Windows target
rustup target add x86_64-pc-windows-gnu

# Install Windows linker (on Debian/Ubuntu)
sudo apt install mingw-w64

# Cross-compile for Windows
cargo build --release --target x86_64-pc-windows-gnu

The compiled binary will be located at target/release/file_deploy (or target/x86_64-pc-windows-gnu/release/file_deploy.exe for Windows).

Usage

Server Mode

Start a server to receive files:

file_deploy serv \
  --listen 0.0.0.0:4399 \
  --cert /path/to/server.crt \
  --key /path/to/server.key \
  --password your_secure_password \
  --script /path/to/post_deploy_script.sh \
  /allowed/directory/1 /allowed/directory/2

Parameters:

  • --listen: Address to listen on (default: 0.0.0.0:4399)
  • --cert: TLS certificate file path (required)
  • --key: TLS private key file path (required)
  • --password: Authentication password (required)
  • --script: Script to execute after file upload (optional)
  • Positional arguments: Allowed directories where files can be saved

The server will output its certificate fingerprint, which is needed for client authentication.

Client Mode

Deploy files to a server:

file_deploy deploy \
  --server server_ip:4399 \
  --fingerprint server_certificate_fingerprint \
  --password your_secure_password \
  /local/file1=>/remote/destination1 /local/directory=>/remote/destination

Parameters:

  • --server: Server address (required)
  • --fingerprint: Server certificate's SHA256 fingerprint (required)
  • --password: Authentication password (required)
  • --delimiter: Path delimiter for separating local and remote paths (default: =>)
  • Positional arguments: Files or directories to upload in format local_path=>remote_path

Example: Remote Development and Debugging Workflow

This example demonstrates how to use File Deploy for C/C++ cross-platform development, deploying Windows applications from a Linux development environment.

Setup

1. Prerequisites

  • Linux development machine with VS Code installed
  • Windows target machine with network connectivity
  • File Deploy compiled for both platforms
  • VS Code C/C++ Extension Package installed
  • CMake
  • mingw-w64 on linux side
  • gdbserver on windows side

2. Certificate Generation for Testing

# Generate a self-signed certificate for testing
mkdir -p test_certs
cd test_certs
openssl req -x509 -newkey rsa:4096 -nodes -keyout server.key -out server.crt -days 365 -subj "/CN=localhost"
cd ..

3. Server Setup (on Windows)

# Start the server on Windows
.\file_deploy.exe serv --listen 0.0.0.0:4399 --cert .\server.crt --key .\server.key --password secure123 --script .\post_deploy.bat C:\DeployTarget

Note the certificate fingerprint displayed when starting the server.

4. Development Workflow (on Linux)

  1. Create a Visual Studio Code project for Windows:
# Create project directory
mkdir -p ~/projects/windows_app
cd ~/projects/windows_app

# Setup a basic C++ Windows application
cat > main.cc << EOL
#include <windows.h>
#include <iostream>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    MessageBoxA(NULL, "Hello from Linux-developed app!", "Remote Deploy Demo", MB_OK);
    return 0;
}
EOL

# Create CMakeLists.txt
cat > main.cc << EOL
cmake_minimum_required(VERSION 3.19)

project(test)

add_executable(test main.cc)

target_link_options(test PRIVATE "-static")
EOL

# Create VS Code launch configuration for remote debugging
mkdir -p .vscode
cat > .vscode/launch.json << EOL
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${command:cmake.launchTargetPath}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerServerAddress": "IP:PORT",
            "preLaunchTask": "deploy",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }

    ]
}
EOL

# Create vscode tasks.json
cat > .vscode/tasks.json << EOL
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "deploy",
            "type": "process",
            "command": "/hdd/develop/file_deploy/target/release/file_deploy",
            "args": [
                "deploy",
                "--server",
                "192.168.2.179:4399",
                "--fingerprint",
                "385afaea03a2a2ace1a3d54e5eea14e53eb7766992ede2a0dd0daa67c2d32533",
                "--password",
                "123456",
                "${command:cmake.launchTargetPath}=>C:\\Users\\King\\Desktop",
            ],
        }
    ]
}
EOL
  1. Build and deploy the application:
# Build and deploy
code .
  1. Create Windows post-deployment script (on Windows target):
@echo off
REM This is post_deploy.bat on the Windows machine
echo Starting application...
C:\path\to\gdbserver\gdbserver.exe --once 0.0.0.0:1234 C:\DeployTarget\app.exe
  1. Just press F5 to debug the application remotely using VS Code's remote debugging features.

Dependencies

This project uses the following open-source libraries:

  • tokio - Asynchronous runtime for Rust
  • clap - Command-line argument parser
  • rustls - TLS implementation in Rust
  • prost - Protocol Buffers implementation
  • sha2 - SHA-2 hash functions
  • tokio-rustls - Tokio TLS integration
  • crc32c - CRC32C implementation
  • x509-parser - X.509 certificate parser

License

You may use this code under either the Apache 2.0 license or the MIT license, at your option.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

Cross-platform file deployment tool

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages