A secure P2P file transfer library with optional encryption and NAT traversal support
Project description
nectar2p
nectar2p — A secure and fast open-source Python library for P2P file transfers, featuring optional encryption and NAT traversal support. With nectar2p, you can easily transfer files between devices on the same network or across different networks.
Features
- Secure File Transfer: Provides RSA and AES encryption for secure data transmission.
- Optional Encryption: Enable or disable encryption for file transfer as per requirement.
- NAT Traversal: Supports connections between devices behind NATs.
- Modular Design: Easily integrable and customizable for various use cases.
- Format Support: Nectar2P supports all file formats.
Installation
nectar2p requires Python 3.6+ and depends on the cryptography library. Follow these steps to install the project:
# Download or clone the project
# Install Nectar2P
pip install nectar2p
Usage
Overview
nectar2p provides two main classes for P2P file transfer:
- NectarSender: Used for sending files.
- NectarReceiver: Used for receiving files.
These classes support secure file transfer with optional encryption and NAT traversal.
Basic Usage
File Sending (Sender)
from nectar2p.nectar_sender import NectarSender
def main():
receiver_host = "public.receiver.ip"
receiver_port = 5000
sender = NectarSender(receiver_host, receiver_port, enable_encryption=True)
try:
sender.initiate_secure_connection()
sender.send_file("path/to/your/file.txt")
finally:
sender.close_connection()
if __name__ == "__main__":
main()
File Receiving (Receiver)
from nectar2p.nectar_receiver import NectarReceiver
def main():
host = "0.0.0.0" # Allows connection from any IP
port = 5000
receiver = NectarReceiver(host, port, enable_encryption=True)
try:
receiver.wait_for_sender()
receiver.receive_file("path/to/save/file.txt")
finally:
receiver.close_connection()
if __name__ == "__main__":
main()
Using NAT Traversal for Cross-Network Transfers
The NectarSender and NectarReceiver classes use a STUN server for NAT traversal, allowing direct connections between devices on different networks. Public IP addresses are automatically retrieved through the STUN server.
Enabling/Disabling Encryption
Encryption can be optionally enabled or disabled during file transfer. When enable_encryption is set to True, RSA and AES encryption are used. When set to False, files are transferred without encryption.
# Encryption enabled
sender = NectarSender("receiver_ip", 5000, enable_encryption=True)
# Encryption disabled
receiver = NectarReceiver("0.0.0.0", 5000, enable_encryption=False)
Project Structure
Explanation of main files and folders used in the project:
nectar2p/
├── nectar2p/
│ ├── __init__.py # Main package file
│ ├── nectar_sender.py # Class managing file sending operations
│ ├── nectar_receiver.py # Class managing file receiving operations
│ ├── encryption/
│ │ ├── __init__.py # Encryption module
│ │ ├── rsa_handler.py # RSA operations
│ │ └── aes_handler.py # AES operations
│ ├── networking/
│ │ ├── __init__.py # Networking module
│ │ ├── connection.py # Connection operations
│ │ └── nat_traversal.py # NAT traversal operations
├── setup.py # Setup file
└── README.md # Project overview and instructions
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributing
Contributions are welcome! Feel free to submit pull requests or open issues on GitHub for any bugs, suggestions, or improvements.
Contact
For any questions or suggestions, please feel free to reach out: glimor@proton.me
Support the Project
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nectar2p-1.0.0.tar.gz.
File metadata
- Download URL: nectar2p-1.0.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e5e16a78c25b36d3075297330a32a9b0b377a092236b9a85a3f093d131ed954
|
|
| MD5 |
04ddcba3748afef8b2c9ca83d3622366
|
|
| BLAKE2b-256 |
75a5055c7ff3c533931244e409c3ffd777ec1dada260946b1eeab280f5738df7
|
File details
Details for the file Nectar2P-1.0.0-py3-none-any.whl.
File metadata
- Download URL: Nectar2P-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
288e1d0fe5da13bdb9c16a48bfc89cebf96c932a83f7cfe8af2f53ccbf314211
|
|
| MD5 |
b7e517f7f7c7610078ece786ac912d98
|
|
| BLAKE2b-256 |
f8a867af12cdbe2e31926b507efcc2c9d5c20d7b9a974d7eddcff3fa0a68b340
|