{"id":30884300,"url":"https://github.com/dhruvldrp9/simpledht","last_synced_at":"2026-02-28T17:04:05.196Z","repository":{"id":291004985,"uuid":"976239774","full_name":"dhruvldrp9/SimpleDHT","owner":"dhruvldrp9","description":"A Python-based Distributed Hash Table (DHT) implementation enabling cross-network key-value storage, automatic node discovery, and data replication with a simple CLI and library interface.","archived":false,"fork":false,"pushed_at":"2025-05-10T11:28:07.000Z","size":58,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T14:52:05.873Z","etag":null,"topics":["cross-network-node-communation","data","data-replication","data-synchronization","dht","dht-python","distributed-hash-table","key-value-storage","nat","netowork","node-discovery","peer-to-peer","peer-to-peer-network","python","sha-256","simple","udp","udp-socket-communication"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/simpledht/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dhruvldrp9.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-01T18:48:26.000Z","updated_at":"2025-09-02T07:41:21.000Z","dependencies_parsed_at":"2025-05-01T21:23:25.620Z","dependency_job_id":"9cc896de-7cdf-4819-856b-b46b8eda438d","html_url":"https://github.com/dhruvldrp9/SimpleDHT","commit_stats":null,"previous_names":["dhruvldrp9/simpledht"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dhruvldrp9/SimpleDHT","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhruvldrp9%2FSimpleDHT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhruvldrp9%2FSimpleDHT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhruvldrp9%2FSimpleDHT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhruvldrp9%2FSimpleDHT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhruvldrp9","download_url":"https://codeload.github.com/dhruvldrp9/SimpleDHT/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhruvldrp9%2FSimpleDHT/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29943686,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T13:49:17.081Z","status":"ssl_error","status_checked_at":"2026-02-28T13:48:50.396Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-network-node-communation","data","data-replication","data-synchronization","dht","dht-python","distributed-hash-table","key-value-storage","nat","netowork","node-discovery","peer-to-peer","peer-to-peer-network","python","sha-256","simple","udp","udp-socket-communication"],"created_at":"2025-09-08T10:15:28.169Z","updated_at":"2026-02-28T17:04:05.166Z","avatar_url":"https://github.com/dhruvldrp9.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Distributed Hash Table (DHT) Implementation\n\nA Python-based Distributed Hash Table implementation that allows nodes to connect across different networks using IP addresses. This implementation supports key-value storage and retrieval across multiple nodes.\n\n## Features\n\n- Cross-network node communication\n- Key-value storage and retrieval\n- Automatic node discovery\n- Data replication between nodes\n- Data synchronization when joining the network\n- Reliable bootstrapping with retry mechanism\n- Simple CLI interface\n- Public IP detection\n- Local network support\n- Python library interface for programmatic use\n\n## Installation\n\n### From PyPI (Recommended)\n\n```bash\npip install simpledht\n```\n\n### From Source\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/dhruvldrp9/SimpleDHT\ncd SimpleDHT\n```\n\n2. Create and activate a virtual environment:\n```bash\npython -m venv env\nsource env/bin/activate  # On Windows: env\\Scripts\\activate\n```\n\n3. Install the package in development mode:\n```bash\npip install -e .\n```\n\n## Usage\n\n### As a Python Library\n\nThe package can be used programmatically in your Python code:\n\n```python\nfrom simpledht import DHTNode\n\n# Create and start a node\nnode = DHTNode(host='0.0.0.0', port=5000)\nnode.start()\n\n# Store data\nnode.put('mykey', 'myvalue')\n\n# Retrieve data\nvalue = node.get('mykey')\n\n# Connect to another node\nnode.bootstrap('other_node_ip:5000')\n\n# Stop the node when done\nnode.stop()\n```\n\nSee the `examples/` directory for more detailed usage examples:\n- `basic_usage.py`: Simple example of creating and connecting nodes\n- `distributed_storage.py`: Advanced example showing distributed storage with multiple nodes\n\n### Command Line Interface\n\n#### Starting a Node\n\nTo start a new DHT node:\n\n```bash\npython -m simpledht.cli start --host 0.0.0.0 --port 5000\n```\n\nTo start a node and connect to existing nodes:\n\n```bash\npython -m simpledht.cli start --host 0.0.0.0 --port 5001 --bootstrap \"PUBLIC_IP:5000\"\n```\n\n#### Storing Data\n\nTo store a key-value pair:\n\n```bash\npython -m simpledht.cli put --host PUBLIC_IP --port 5000 mykey \"my value\"\n```\n\n#### Retrieving Data\n\n```bash\npython -m simpledht.cli get --host PUBLIC_IP --port 5000 mykey\n```\n\n### Cross-Network Example\n\n1. Start Node 1 (First network):\n```bash\npython -m simpledht.cli start --host 0.0.0.0 --port 5000\n```\n\n2. Start Node 2 (Second network):\n```bash\npython -m simpledht.cli start --host 0.0.0.0 --port 5000 --bootstrap \"NODE1_PUBLIC_IP:5000\"\n```\n\n3. Store and retrieve data:\n```bash\n# Store on Node 1\npython -m simpledht.cli put --host NODE1_PUBLIC_IP --port 5000 test_key \"test_value\"\n\n# Retrieve from Node 2\npython -m simpledht.cli get --host NODE2_PUBLIC_IP --port 5000 test_key\n```\n\n## Network Configuration\n\n### Firewall Setup\n\nEnsure the UDP port (default: 5000) is open in your firewall:\n\n```bash\n# For UFW (Ubuntu)\nsudo ufw allow 5000/udp\n\n# For iptables\nsudo iptables -A INPUT -p udp --dport 5000 -j ACCEPT\n```\n\n### Port Forwarding\n\nIf your node is behind a NAT router:\n1. Access your router's admin interface\n2. Set up port forwarding for UDP port 5000\n3. Forward to your node's local IP address\n\n## New Features in Version 0.1.3\n\n- **Improved Bootstrap Mechanism**: Added retry logic for more reliable connections across networks\n- **Data Synchronization**: Nodes automatically sync data when joining the network\n- **Enhanced Error Handling**: Better handling of network timeouts and connection issues\n- **Full Data Replication**: All nodes maintain a complete copy of the data for redundancy\n- **Alternative Command Method**: Added support for running via `python -m simpledht.cli`\n\n## Troubleshooting\n\n### Common Issues\n\n1. **Connection Timeout**\n   - Check if the target node is running\n   - Verify firewall settings\n   - Ensure port forwarding is configured correctly\n   - Try increasing the timeout: `--timeout 10`\n\n2. **Address Already in Use**\n   - The port is already being used by another process\n   - Try a different port number\n   - Check running processes: `netstat -tuln | grep 5000`\n\n3. **No Response from Node**\n   - Verify the node is running\n   - Check network connectivity: `ping NODE_IP`\n   - Test port connectivity: `nc -vzu NODE_IP 5000`\n\n### Error Messages\n\n- `Failed to bootstrap with IP:PORT`: Invalid bootstrap node format\n- `No response received`: Node is not responding\n- `Address already in use`: Port conflict\n- `Failed to get public IP`: Network connectivity issue\n- `Connection attempt X/3 timed out, retrying...`: Network latency or connectivity issues\n- `simpledht: command not found`: The command-line tool is not in your PATH. Use the Python module directly: `python -m simpledht.cli`\n\n## Architecture\n\nThe DHT implementation uses:\n- UDP sockets for communication\n- SHA-256 for node ID generation\n- Automatic public IP detection\n- Data replication between nodes\n- Bootstrap nodes for network discovery\n- Retry mechanism for reliable connections\n\n## Security Considerations\n\n- This is a basic implementation and should not be used in production without additional security measures\n- Consider adding:\n  - Encryption for data in transit\n  - Authentication for node joining\n  - Rate limiting to prevent abuse\n  - Input validation\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Commit your changes\n4. Push to the branch\n5. Create a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhruvldrp9%2Fsimpledht","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhruvldrp9%2Fsimpledht","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhruvldrp9%2Fsimpledht/lists"}