simpledht 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
simpledht/__init__.py CHANGED
@@ -20,7 +20,7 @@ Example usage:
20
20
  node.bootstrap('other_node_ip:5000')
21
21
  """
22
22
 
23
- __version__ = "0.1.2"
23
+ __version__ = "0.1.4"
24
24
 
25
25
  from .dht_node import DHTNode
26
26
  from .cli import main as cli_main
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: simpledht
3
+ Version: 0.1.4
4
+ Summary: A simple distributed hash table implementation
5
+ Home-page: https://github.com/dhruvldrp9/simpledht
6
+ Author: Dhruvkumar Patel
7
+ Author-email: dhruv.ldrp9@gmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: requests>=2.25.1
15
+ Requires-Dist: click>=8.0.1
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license-file
23
+ Dynamic: requires-dist
24
+ Dynamic: requires-python
25
+ Dynamic: summary
26
+
27
+ # Distributed Hash Table (DHT) Implementation
28
+
29
+ A 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.
30
+
31
+ ## Features
32
+
33
+ - Cross-network node communication
34
+ - Key-value storage and retrieval
35
+ - Automatic node discovery
36
+ - Data replication between nodes
37
+ - Data synchronization when joining the network
38
+ - Reliable bootstrapping with retry mechanism
39
+ - Simple CLI interface
40
+ - Public IP detection
41
+ - Local network support
42
+ - Python library interface for programmatic use
43
+
44
+ ## Installation
45
+
46
+ ### From PyPI (Recommended)
47
+
48
+ ```bash
49
+ pip install simpledht
50
+ ```
51
+
52
+ ### From Source
53
+
54
+ 1. Clone the repository:
55
+ ```bash
56
+ git clone https://github.com/dhruvldrp9/SimpleDHT
57
+ cd SimpleDHT
58
+ ```
59
+
60
+ 2. Create and activate a virtual environment:
61
+ ```bash
62
+ python -m venv env
63
+ source env/bin/activate # On Windows: env\Scripts\activate
64
+ ```
65
+
66
+ 3. Install the package in development mode:
67
+ ```bash
68
+ pip install -e .
69
+ ```
70
+
71
+ ## Usage
72
+
73
+ ### As a Python Library
74
+
75
+ The package can be used programmatically in your Python code:
76
+
77
+ ```python
78
+ from simpledht import DHTNode
79
+
80
+ # Create and start a node
81
+ node = DHTNode(host='0.0.0.0', port=5000)
82
+ node.start()
83
+
84
+ # Store data
85
+ node.put('mykey', 'myvalue')
86
+
87
+ # Retrieve data
88
+ value = node.get('mykey')
89
+
90
+ # Connect to another node
91
+ node.bootstrap('other_node_ip:5000')
92
+
93
+ # Stop the node when done
94
+ node.stop()
95
+ ```
96
+
97
+ See the `examples/` directory for more detailed usage examples:
98
+ - `basic_usage.py`: Simple example of creating and connecting nodes
99
+ - `distributed_storage.py`: Advanced example showing distributed storage with multiple nodes
100
+
101
+ ### Command Line Interface
102
+
103
+ #### Starting a Node
104
+
105
+ To start a new DHT node:
106
+
107
+ ```bash
108
+ python -m simpledht.cli start --host 0.0.0.0 --port 5000
109
+ ```
110
+
111
+ To start a node and connect to existing nodes:
112
+
113
+ ```bash
114
+ python -m simpledht.cli start --host 0.0.0.0 --port 5001 --bootstrap "PUBLIC_IP:5000"
115
+ ```
116
+
117
+ #### Storing Data
118
+
119
+ To store a key-value pair:
120
+
121
+ ```bash
122
+ python -m simpledht.cli put --host PUBLIC_IP --port 5000 mykey "my value"
123
+ ```
124
+
125
+ #### Retrieving Data
126
+
127
+ ```bash
128
+ python -m simpledht.cli get --host PUBLIC_IP --port 5000 mykey
129
+ ```
130
+
131
+ ### Cross-Network Example
132
+
133
+ 1. Start Node 1 (First network):
134
+ ```bash
135
+ python -m simpledht.cli start --host 0.0.0.0 --port 5000
136
+ ```
137
+
138
+ 2. Start Node 2 (Second network):
139
+ ```bash
140
+ python -m simpledht.cli start --host 0.0.0.0 --port 5000 --bootstrap "NODE1_PUBLIC_IP:5000"
141
+ ```
142
+
143
+ 3. Store and retrieve data:
144
+ ```bash
145
+ # Store on Node 1
146
+ python -m simpledht.cli put --host NODE1_PUBLIC_IP --port 5000 test_key "test_value"
147
+
148
+ # Retrieve from Node 2
149
+ python -m simpledht.cli get --host NODE2_PUBLIC_IP --port 5000 test_key
150
+ ```
151
+
152
+ ## Network Configuration
153
+
154
+ ### Firewall Setup
155
+
156
+ Ensure the UDP port (default: 5000) is open in your firewall:
157
+
158
+ ```bash
159
+ # For UFW (Ubuntu)
160
+ sudo ufw allow 5000/udp
161
+
162
+ # For iptables
163
+ sudo iptables -A INPUT -p udp --dport 5000 -j ACCEPT
164
+ ```
165
+
166
+ ### Port Forwarding
167
+
168
+ If your node is behind a NAT router:
169
+ 1. Access your router's admin interface
170
+ 2. Set up port forwarding for UDP port 5000
171
+ 3. Forward to your node's local IP address
172
+
173
+ ## New Features in Version 0.1.3
174
+
175
+ - **Improved Bootstrap Mechanism**: Added retry logic for more reliable connections across networks
176
+ - **Data Synchronization**: Nodes automatically sync data when joining the network
177
+ - **Enhanced Error Handling**: Better handling of network timeouts and connection issues
178
+ - **Full Data Replication**: All nodes maintain a complete copy of the data for redundancy
179
+ - **Alternative Command Method**: Added support for running via `python -m simpledht.cli`
180
+
181
+ ## Troubleshooting
182
+
183
+ ### Common Issues
184
+
185
+ 1. **Connection Timeout**
186
+ - Check if the target node is running
187
+ - Verify firewall settings
188
+ - Ensure port forwarding is configured correctly
189
+ - Try increasing the timeout: `--timeout 10`
190
+
191
+ 2. **Address Already in Use**
192
+ - The port is already being used by another process
193
+ - Try a different port number
194
+ - Check running processes: `netstat -tuln | grep 5000`
195
+
196
+ 3. **No Response from Node**
197
+ - Verify the node is running
198
+ - Check network connectivity: `ping NODE_IP`
199
+ - Test port connectivity: `nc -vzu NODE_IP 5000`
200
+
201
+ ### Error Messages
202
+
203
+ - `Failed to bootstrap with IP:PORT`: Invalid bootstrap node format
204
+ - `No response received`: Node is not responding
205
+ - `Address already in use`: Port conflict
206
+ - `Failed to get public IP`: Network connectivity issue
207
+ - `Connection attempt X/3 timed out, retrying...`: Network latency or connectivity issues
208
+ - `simpledht: command not found`: The command-line tool is not in your PATH. Use the Python module directly: `python -m simpledht.cli`
209
+
210
+ ## Architecture
211
+
212
+ The DHT implementation uses:
213
+ - UDP sockets for communication
214
+ - SHA-256 for node ID generation
215
+ - Automatic public IP detection
216
+ - Data replication between nodes
217
+ - Bootstrap nodes for network discovery
218
+ - Retry mechanism for reliable connections
219
+
220
+ ## Security Considerations
221
+
222
+ - This is a basic implementation and should not be used in production without additional security measures
223
+ - Consider adding:
224
+ - Encryption for data in transit
225
+ - Authentication for node joining
226
+ - Rate limiting to prevent abuse
227
+ - Input validation
228
+
229
+ ## Contributing
230
+
231
+ 1. Fork the repository
232
+ 2. Create a feature branch
233
+ 3. Commit your changes
234
+ 4. Push to the branch
235
+ 5. Create a Pull Request
236
+
237
+ ## License
238
+
239
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,10 @@
1
+ simpledht/__init__.py,sha256=wKPkOXmeKWw7EGzWO8OfiniWd9tdJ2ALL0Ee4pc-ZKw,546
2
+ simpledht/cli.py,sha256=9QgsyZv1-SKwblj2hYLsGKRjiCyBFjlGalafdqhoXrk,4877
3
+ simpledht/dht_node.py,sha256=58fd7Yq8gPLVbHaaJMW-9gnrC2YjPMF0EtD3I81EI6Q,14864
4
+ simpledht/test_dht.py,sha256=tsWGhtLkTArFJIdkaWManekhFx2KCUO0Gp93EGBUAlw,2346
5
+ simpledht-0.1.4.dist-info/licenses/LICENSE,sha256=MrSAzCY_7J3C4Hp8PaXaaFJP2ygfmuAWoLTVowEE3B0,1073
6
+ simpledht-0.1.4.dist-info/METADATA,sha256=yhcyaR_fM-5u2NoyzKgezVwb1AwSPuupgZrL-IpTB_M,6151
7
+ simpledht-0.1.4.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
8
+ simpledht-0.1.4.dist-info/entry_points.txt,sha256=Hm3BYz1MykAhg94m3JSYsMcdEQEia3bdRocokc-0wxs,49
9
+ simpledht-0.1.4.dist-info/top_level.txt,sha256=VjRxeoXfQJeoPoFhr5JGGMAI5NSLkYJl0WbySmpZ4bs,10
10
+ simpledht-0.1.4.dist-info/RECORD,,
@@ -1,27 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: simpledht
3
- Version: 0.1.2
4
- Summary: A simple distributed hash table implementation
5
- Home-page: https://github.com/dhruvldrp9/simpledht
6
- Author: Dhruvkumar Patel
7
- Author-email: dhruv.ldrp9@gmail.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.6
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: requests>=2.25.1
15
- Requires-Dist: click>=8.0.1
16
- Dynamic: author
17
- Dynamic: author-email
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: description-content-type
21
- Dynamic: home-page
22
- Dynamic: license-file
23
- Dynamic: requires-dist
24
- Dynamic: requires-python
25
- Dynamic: summary
26
-
27
- A simple distributed hash table implementation
@@ -1,10 +0,0 @@
1
- simpledht/__init__.py,sha256=UMGuX6JHuDsQG_JuvBv4Q5JT2Yq9zzPwTuqgRdHJVow,546
2
- simpledht/cli.py,sha256=9QgsyZv1-SKwblj2hYLsGKRjiCyBFjlGalafdqhoXrk,4877
3
- simpledht/dht_node.py,sha256=58fd7Yq8gPLVbHaaJMW-9gnrC2YjPMF0EtD3I81EI6Q,14864
4
- simpledht/test_dht.py,sha256=tsWGhtLkTArFJIdkaWManekhFx2KCUO0Gp93EGBUAlw,2346
5
- simpledht-0.1.2.dist-info/licenses/LICENSE,sha256=MrSAzCY_7J3C4Hp8PaXaaFJP2ygfmuAWoLTVowEE3B0,1073
6
- simpledht-0.1.2.dist-info/METADATA,sha256=n9kVjGyjUno8VTeN5IgM2isJO2UVBxfsm_p51ckxy98,779
7
- simpledht-0.1.2.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
8
- simpledht-0.1.2.dist-info/entry_points.txt,sha256=Hm3BYz1MykAhg94m3JSYsMcdEQEia3bdRocokc-0wxs,49
9
- simpledht-0.1.2.dist-info/top_level.txt,sha256=VjRxeoXfQJeoPoFhr5JGGMAI5NSLkYJl0WbySmpZ4bs,10
10
- simpledht-0.1.2.dist-info/RECORD,,