https://github.com/trinnguyen/sendfile-cli
Send files securely via TCP/TLS 1.3 in the local network (written in Rust)
https://github.com/trinnguyen/sendfile-cli
file-sharing rust rustls tcp-protocol tls13
Last synced: 8 months ago
JSON representation
Send files securely via TCP/TLS 1.3 in the local network (written in Rust)
- Host: GitHub
- URL: https://github.com/trinnguyen/sendfile-cli
- Owner: trinnguyen
- Created: 2021-05-16T19:17:04.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-22T23:18:27.000Z (almost 5 years ago)
- Last Synced: 2025-05-28T22:08:17.467Z (10 months ago)
- Topics: file-sharing, rust, rustls, tcp-protocol, tls13
- Language: Rust
- Homepage:
- Size: 41 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```
:= ?
:= Send | Accept | Reject | StartFile | EndFile | FileData | Finish
:= NUMBER
:= FileInfo[] | Byte[]
```
- Length
- : 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)
```mermaid
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)
```mermaid
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
```