simpledht 0.1.2__py3-none-any.whl → 0.1.3__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.3"
24
24
 
25
25
  from .dht_node import DHTNode
26
26
  from .cli import main as cli_main
@@ -0,0 +1,235 @@
1
+ Metadata-Version: 2.4
2
+ Name: simpledht
3
+ Version: 0.1.3
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 <repository-url>
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
+ ```bash
107
+ simpledht start --host 0.0.0.0 --port 5000
108
+ ```
109
+
110
+ To start a node and connect to existing nodes:
111
+ ```bash
112
+ simpledht start --host 0.0.0.0 --port 5001 --bootstrap "PUBLIC_IP:5000"
113
+ ```
114
+
115
+ #### Storing Data
116
+
117
+ To store a key-value pair:
118
+ ```bash
119
+ simpledht put --host PUBLIC_IP --port 5000 mykey "my value"
120
+ ```
121
+
122
+ #### Retrieving Data
123
+
124
+ To retrieve a value:
125
+ ```bash
126
+ simpledht get --host PUBLIC_IP --port 5000 mykey
127
+ ```
128
+
129
+ ### Cross-Network Example
130
+
131
+ 1. Start Node 1 (First network):
132
+ ```bash
133
+ simpledht start --host 0.0.0.0 --port 5000
134
+ ```
135
+
136
+ 2. Start Node 2 (Second network):
137
+ ```bash
138
+ simpledht start --host 0.0.0.0 --port 5000 --bootstrap "NODE1_PUBLIC_IP:5000"
139
+ ```
140
+
141
+ 3. Store and retrieve data:
142
+ ```bash
143
+ # Store on Node 1
144
+ simpledht put --host NODE1_PUBLIC_IP --port 5000 test_key "test_value"
145
+
146
+ # Retrieve from Node 2
147
+ simpledht get --host NODE2_PUBLIC_IP --port 5000 test_key
148
+ ```
149
+
150
+ ## Network Configuration
151
+
152
+ ### Firewall Setup
153
+
154
+ Ensure the UDP port (default: 5000) is open in your firewall:
155
+
156
+ ```bash
157
+ # For UFW (Ubuntu)
158
+ sudo ufw allow 5000/udp
159
+
160
+ # For iptables
161
+ sudo iptables -A INPUT -p udp --dport 5000 -j ACCEPT
162
+ ```
163
+
164
+ ### Port Forwarding
165
+
166
+ If your node is behind a NAT router:
167
+ 1. Access your router's admin interface
168
+ 2. Set up port forwarding for UDP port 5000
169
+ 3. Forward to your node's local IP address
170
+
171
+ ## New Features in Version 0.1.2
172
+
173
+ - **Improved Bootstrap Mechanism**: Added retry logic for more reliable connections across networks
174
+ - **Data Synchronization**: Nodes automatically sync data when joining the network
175
+ - **Enhanced Error Handling**: Better handling of network timeouts and connection issues
176
+ - **Full Data Replication**: All nodes maintain a complete copy of the data for redundancy
177
+
178
+ ## Troubleshooting
179
+
180
+ ### Common Issues
181
+
182
+ 1. **Connection Timeout**
183
+ - Check if the target node is running
184
+ - Verify firewall settings
185
+ - Ensure port forwarding is configured correctly
186
+ - Try increasing the timeout: `--timeout 10`
187
+
188
+ 2. **Address Already in Use**
189
+ - The port is already being used by another process
190
+ - Try a different port number
191
+ - Check running processes: `netstat -tuln | grep 5000`
192
+
193
+ 3. **No Response from Node**
194
+ - Verify the node is running
195
+ - Check network connectivity: `ping NODE_IP`
196
+ - Test port connectivity: `nc -vzu NODE_IP 5000`
197
+
198
+ ### Error Messages
199
+
200
+ - `Failed to bootstrap with IP:PORT`: Invalid bootstrap node format
201
+ - `No response received`: Node is not responding
202
+ - `Address already in use`: Port conflict
203
+ - `Failed to get public IP`: Network connectivity issue
204
+ - `Connection attempt X/3 timed out, retrying...`: Network latency or connectivity issues
205
+
206
+ ## Architecture
207
+
208
+ The DHT implementation uses:
209
+ - UDP sockets for communication
210
+ - SHA-256 for node ID generation
211
+ - Automatic public IP detection
212
+ - Data replication between nodes
213
+ - Bootstrap nodes for network discovery
214
+ - Retry mechanism for reliable connections
215
+
216
+ ## Security Considerations
217
+
218
+ - This is a basic implementation and should not be used in production without additional security measures
219
+ - Consider adding:
220
+ - Encryption for data in transit
221
+ - Authentication for node joining
222
+ - Rate limiting to prevent abuse
223
+ - Input validation
224
+
225
+ ## Contributing
226
+
227
+ 1. Fork the repository
228
+ 2. Create a feature branch
229
+ 3. Commit your changes
230
+ 4. Push to the branch
231
+ 5. Create a Pull Request
232
+
233
+ ## License
234
+
235
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,10 @@
1
+ simpledht/__init__.py,sha256=j0WY2O6SGOuBS3CVdz_u-9R-fIoR6ArZ3XfP2qIrWMc,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.3.dist-info/licenses/LICENSE,sha256=MrSAzCY_7J3C4Hp8PaXaaFJP2ygfmuAWoLTVowEE3B0,1073
6
+ simpledht-0.1.3.dist-info/METADATA,sha256=cnSOqwQOc4hZAT7w2QGolEvcz0Op_3PLHELYhKYIIfI,5809
7
+ simpledht-0.1.3.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
8
+ simpledht-0.1.3.dist-info/entry_points.txt,sha256=Hm3BYz1MykAhg94m3JSYsMcdEQEia3bdRocokc-0wxs,49
9
+ simpledht-0.1.3.dist-info/top_level.txt,sha256=VjRxeoXfQJeoPoFhr5JGGMAI5NSLkYJl0WbySmpZ4bs,10
10
+ simpledht-0.1.3.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,,