Skip to content

Send files securely via TCP/TLS 1.3 in the local network (written in Rust)

Notifications You must be signed in to change notification settings

trinnguyen/sendfile-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sendfile-cli

Overview

  • Send files securely via TCP/TLS 1.3 in local network (no Internet needed)
  • Automatically generate TLS private/public keys pair for each connection

Process

  • Each receiver runs a TCP server to listen for connections from sender
  • Initiate state machines for server and client, communicate using a custom protocol
  • Custom protocol for TCP packets:
    <package> := <package_type> <data-length> <data>?
    <package_type> := Send | Accept | Reject | StartFile | EndFile | FileData | Finish
    <data-length> := NUMBER
    <data> := FileInfo[] | Byte[]
  • Length
    • <package_type>: 1 byte (number range from 0..2^8)
    • : 2 bytes (number range from 0..2^16)
    • : byte array (maximum 61 bytes)

State machines (mermaid)

Receiver (or server)

stateDiagram-v2
    [*] --> Init
    Init --> InternalAnswer: Send?
    InternalAnswer --> Finish: Reject!
    InternalAnswer --> WaitForFile: Accept!
    WaitForFile --> StartReceivingFile: StartFile?
    StartReceivingFile --> ReceiveFileData: FileData?
    ReceiveFileData --> ReceiveFileData: FileData?
    ReceiveFileData --> EndReceivingFile: EndFile?
    EndReceivingFile --> StartReceivingFile: StartFile?
    EndReceivingFile --> Finish: Finish?

Sender (or client)

stateDiagram-v2
    [*] --> Init
    Init --> WaitForResponse: Send!
    WaitForResponse --> Finish: Reject?
    WaitForResponse --> Accepted: Accept?
    Accepted --> StartSendingFile: StartFile!
    StartSendingFile --> SendFileData: FileData!
    SendFileData --> SendFileData: FileData!
    SendFileData --> EndSendingFile: EndFile!
    EndSendingFile --> StartSendingFile: StartFile!
    EndSendingFile --> Finish: Finish!

Run examples

  • Run server

    RUST_LOG=debug cargo run -- -s 7878
    
  • Run client

    RUST_LOG=debug cargo run -- -c 127.0.0.1:7878 -f test-data/file1.txt -f test-data/file2.txt
    

About

Send files securely via TCP/TLS 1.3 in the local network (written in Rust)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages