simpledht 0.1.2__tar.gz → 0.1.4__tar.gz

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.
@@ -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.
@@ -27,7 +27,7 @@ pip install simpledht
27
27
 
28
28
  1. Clone the repository:
29
29
  ```bash
30
- git clone <repository-url>
30
+ git clone https://github.com/dhruvldrp9/SimpleDHT
31
31
  cd SimpleDHT
32
32
  ```
33
33
 
@@ -77,48 +77,50 @@ See the `examples/` directory for more detailed usage examples:
77
77
  #### Starting a Node
78
78
 
79
79
  To start a new DHT node:
80
+
80
81
  ```bash
81
- simpledht start --host 0.0.0.0 --port 5000
82
+ python -m simpledht.cli start --host 0.0.0.0 --port 5000
82
83
  ```
83
84
 
84
85
  To start a node and connect to existing nodes:
86
+
85
87
  ```bash
86
- simpledht start --host 0.0.0.0 --port 5001 --bootstrap "PUBLIC_IP:5000"
88
+ python -m simpledht.cli start --host 0.0.0.0 --port 5001 --bootstrap "PUBLIC_IP:5000"
87
89
  ```
88
90
 
89
91
  #### Storing Data
90
92
 
91
93
  To store a key-value pair:
94
+
92
95
  ```bash
93
- simpledht put --host PUBLIC_IP --port 5000 mykey "my value"
96
+ python -m simpledht.cli put --host PUBLIC_IP --port 5000 mykey "my value"
94
97
  ```
95
98
 
96
99
  #### Retrieving Data
97
100
 
98
- To retrieve a value:
99
101
  ```bash
100
- simpledht get --host PUBLIC_IP --port 5000 mykey
102
+ python -m simpledht.cli get --host PUBLIC_IP --port 5000 mykey
101
103
  ```
102
104
 
103
105
  ### Cross-Network Example
104
106
 
105
107
  1. Start Node 1 (First network):
106
108
  ```bash
107
- simpledht start --host 0.0.0.0 --port 5000
109
+ python -m simpledht.cli start --host 0.0.0.0 --port 5000
108
110
  ```
109
111
 
110
112
  2. Start Node 2 (Second network):
111
113
  ```bash
112
- simpledht start --host 0.0.0.0 --port 5000 --bootstrap "NODE1_PUBLIC_IP:5000"
114
+ python -m simpledht.cli start --host 0.0.0.0 --port 5000 --bootstrap "NODE1_PUBLIC_IP:5000"
113
115
  ```
114
116
 
115
117
  3. Store and retrieve data:
116
118
  ```bash
117
119
  # Store on Node 1
118
- simpledht put --host NODE1_PUBLIC_IP --port 5000 test_key "test_value"
120
+ python -m simpledht.cli put --host NODE1_PUBLIC_IP --port 5000 test_key "test_value"
119
121
 
120
122
  # Retrieve from Node 2
121
- simpledht get --host NODE2_PUBLIC_IP --port 5000 test_key
123
+ python -m simpledht.cli get --host NODE2_PUBLIC_IP --port 5000 test_key
122
124
  ```
123
125
 
124
126
  ## Network Configuration
@@ -142,12 +144,13 @@ If your node is behind a NAT router:
142
144
  2. Set up port forwarding for UDP port 5000
143
145
  3. Forward to your node's local IP address
144
146
 
145
- ## New Features in Version 0.1.2
147
+ ## New Features in Version 0.1.3
146
148
 
147
149
  - **Improved Bootstrap Mechanism**: Added retry logic for more reliable connections across networks
148
150
  - **Data Synchronization**: Nodes automatically sync data when joining the network
149
151
  - **Enhanced Error Handling**: Better handling of network timeouts and connection issues
150
152
  - **Full Data Replication**: All nodes maintain a complete copy of the data for redundancy
153
+ - **Alternative Command Method**: Added support for running via `python -m simpledht.cli`
151
154
 
152
155
  ## Troubleshooting
153
156
 
@@ -176,6 +179,7 @@ If your node is behind a NAT router:
176
179
  - `Address already in use`: Port conflict
177
180
  - `Failed to get public IP`: Network connectivity issue
178
181
  - `Connection attempt X/3 timed out, retrying...`: Network latency or connectivity issues
182
+ - `simpledht: command not found`: The command-line tool is not in your PATH. Use the Python module directly: `python -m simpledht.cli`
179
183
 
180
184
  ## Architecture
181
185
 
@@ -5,11 +5,11 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="simpledht",
8
- version="0.1.2",
8
+ version="0.1.4",
9
9
  author="Dhruvkumar Patel",
10
10
  author_email="dhruv.ldrp9@gmail.com",
11
11
  description="A simple distributed hash table implementation",
12
- long_description="A simple distributed hash table implementation",
12
+ long_description=long_description,
13
13
  long_description_content_type="text/markdown",
14
14
  url="https://github.com/dhruvldrp9/simpledht",
15
15
  packages=find_packages(),
@@ -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.
simpledht-0.1.2/PKG-INFO DELETED
@@ -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,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
File without changes
File without changes
File without changes
File without changes