lanp2p (netdrop) 🚀
A terminal-based peer-to-peer (P2P) file transfer tool for local networks. It enables devices on the same Wi-Fi or Ethernet network to automatically discover each other and transfer files or directories directly using UDP discovery and TCP socket streaming.
No external servers, no cloud storage, no account registration—100% direct local transfers.
✨ Features
- 🔍 Zero-Config Peer Discovery: Uses UDP broadcast beacons to automatically discover online devices on your LAN.
- ⚡ High-Speed TCP Streaming: Direct peer-to-peer data pipeline utilizing the full bandwidth of your local network.
- 📁 File & Directory Support: Seamlessly send single files or entire folders (directories are automatically packed and unpacked).
- 🔒 SHA-256 Cryptographic Verification: Computes and validates cryptographic checksums on both ends to ensure 100% data integrity.
- 🛡️ Built-in Security:
- Filename sanitization to protect against directory traversal and path manipulation attacks.
- Safe archive extraction preventing Zip/Tar Slip vulnerabilities.
- Interactive approval prompts before accepting incoming transfers.
- Automatic collision-free file naming (e.g.
file (1).ext).
- 🎨 Beautiful Terminal UI: Powered by
rich, featuring real-time progress bars, download/upload speeds in MB/s, ETA countdowns, and formatted tables. - 📦 Pip Package Ready: Standard
pyproject.tomlpackage structure, ready to install locally or publish to PyPI.
📥 Installation
Standard Pip Install
pip install .
🚀 Quick Start & Usage
1. Start Receiving Files (listen)
Run this on the machine that will receive files:
lanp2p listen
Options:
-y,--yes: Automatically accept incoming transfers without prompting.-d,--save-dir <path>: Directory where downloaded files are saved (default:./downloads).-p,--port <number>: TCP transfer port (default:50006).-n,--name <custom_name>: Set custom peer name visible on the network.
Example:
lanp2p listen -y -d ~/Downloads
2. Send a File or Folder (send)
Interactive Mode (Auto-Discover Peers)
Simply run send with the target file:
lanp2p send presentation.pdf
lanp2p will scan the local network for 2.5 seconds, display a list of online peers, and prompt you to pick one:
Found 2 peer(s):
+---+----------------------+----------------+----------+---------+
| # | Peer Name | IP Address | TCP Port | OS |
+---+----------------------+----------------+----------+---------+
| 1 | alice@MacBook-Pro | 192.168.1.45 | 50006 | Darwin |
| 2 | bob@Ubuntu-Desktop | 192.168.1.88 | 50006 | Linux |
+---+----------------------+----------------+----------+---------+
Select a peer number or enter target IP directly [1]: 1
Direct IP Mode
If you already know the recipient's IP (or if UDP broadcast is disabled by router AP isolation):
# Send a file
lanp2p send dataset.csv --to 192.168.1.45
# Send an entire folder
lanp2p send ./my_project --to 192.168.1.45
3. Scan Network Peers (peers)
List all active peers currently advertising on your local network:
lanp2p peers --ping
Output:
+---+----------------------+----------------+----------+---------+----------+
| # | Peer Name | IP Address | TCP Port | OS | Latency |
+---+----------------------+----------------+----------+---------+----------+
| 1 | cajetan@Cajetans-PC | 192.168.8.222 | 50006 | Windows | 1.2 ms |
| 2 | lab@Server01 | 192.168.8.10 | 50006 | Linux | 0.8 ms |
+---+----------------------+----------------+----------+---------+----------+
4. Scan ALL Devices on Local Wi-Fi / LAN (scan)
Discover all active devices and hardware connected to your local router (even if they aren't running lanp2p):
lanp2p scan
Output:
All Devices Discovered on Local Network (2)
+---------------------------------------------------------------------------+
| IP Address | MAC Address (Hardware) | Network Role | lanp2p Status |
|---------------+------------------------+------------------+---------------|
| 192.168.0.1 | 98-da-c4-0f-72-b6 | Gateway / Router | Not Running |
| 192.168.0.101 | da-f6-b9-90-b6-67 | LAN Device | Not Running |
+---------------------------------------------------------------------------+
5. Test Connectivity (ping)
Check TCP connectivity and latency to a peer's receiver port:
lanp2p ping 192.168.8.222
5. Network Diagnostics (info)
View local network adapters, detected IPs, and broadcast addresses:
lanp2p info
🛠️ Architecture & Protocol Design
1. Peer Discovery (UDP Port 50005)
Every 2 seconds, the DiscoveryBeaconService broadcasts a UDP datagram to 255.255.255.255 and subnet broadcast addresses:
{
"magic": "LANP2P_BEACON_V1",
"peer_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"name": "cajetan@Cajetans-PC",
"port": 50006,
"system": "Windows",
"version": "1.0",
"ips": ["192.168.8.222"],
"timestamp": 1727166000.0
}
The DiscoveryListener maintains a thread-safe registry of active peers, expiring inactive peers after 6 seconds.
2. File Transfer Framing (TCP Port 50006)
All TCP control messages are framed using a 4-byte big-endian length prefix followed by a UTF-8 JSON payload:
+---------------------------+-----------------------------------+
| 4-byte uint32 (len = N) | N bytes UTF-8 JSON control string |
+---------------------------+-----------------------------------+
Transfer Flow:
Sender Receiver (lanp2p listen)
| |
| -------- 1. TCP Connect (Port 50006) ------------------> |
| |
| -------- 2. TRANSFER_INIT (name, size, sha256) --------> |
| | [Prompt user / auto-accept]
| <------- 3. TRANSFER_RESP (status: ACCEPTED) ----------- |
| |
| ======== 4. Binary Data Stream (64 KB chunks) ========> | [Compute SHA-256 while writing .part]
| |
| | [Verify SHA-256 == expected]
| | [Atomic rename .part -> final]
| <------- 5. TRANSFER_ACK (status: SUCCESS) ------------- |
| |
📦 How to Build and Publish to PyPI
1. Build Source Distribution and Wheel
Make sure build is installed:
pip install build
python -m build
This produces:
dist/lanp2p-0.1.0-py3-none-any.whldist/lanp2p-0.1.0.tar.gz
2. Publish to PyPI with Twine
Install twine:
pip install twine
Upload to TestPyPI first (recommended):
python -m twine upload --repository testpypi dist/*
Upload to official PyPI:
python -m twine upload dist/*
🛡️ Firewall Configuration
If peers cannot discover each other or connect:
- Windows: Allow Python /
lanp2pthrough Windows Defender Firewall, or allow inbound TCP port 50006 and UDP port 50005. - Linux (UFW):
sudo ufw allow 50005/udp sudo ufw allow 50006/tcp
- Wi-Fi AP Isolation: Some public Wi-Fi networks (hotels, cafes) block client-to-client traffic. On such networks, connecting both devices to a mobile hotspot or specifying direct IPs bypasses discovery limitations.
🧪 Running Automated Tests
Run the complete test suite:
python -m unittest discover tests
📄 License
This project is licensed under the MIT License.
Release files for lanp2p 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lanp2p-0.1.2.tar.gz | 25.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lanp2p-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.6 kB
Release files / lanp2p-0.1.2.tar.gz
| Download URL | lanp2p-0.1.2.tar.gz |
|---|---|
| Size | 25.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c684b0a5d7a498cad5ad576cc16b41bc0a9934b72210f1b190726ce2dfcd240f
|
|
BLAKE2b-256 checksum How to use checksums |
6aa6947b42d5276c14e9b2cd8603944ed5075d8115dca15d5c3ac250886c1e22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Release files / lanp2p-0.1.2-py3-none-any.whl
| Download URL | lanp2p-0.1.2-py3-none-any.whl |
|---|---|
| Size | 22.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
564d6cf87ee7210f4b70b675b734ee157b49e49bcf38de531e3f2492e962b62e
|
|
BLAKE2b-256 checksum How to use checksums |
43156ef7f50ddfc25d4358486f02559c3ec6c7eba9a92b949d01635bb2d7f224
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|