simpledht 0.1.0__py3-none-any.whl → 0.1.1__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
@@ -1,10 +1,28 @@
1
1
  """
2
2
  SimpleDHT - A simple distributed hash table implementation
3
+
4
+ Example usage:
5
+ from simpledht import DHTNode
6
+
7
+ # Create a new node
8
+ node = DHTNode(host='0.0.0.0', port=5000)
9
+
10
+ # Start the node
11
+ node.start()
12
+
13
+ # Store a value
14
+ node.put('mykey', 'myvalue')
15
+
16
+ # Retrieve a value
17
+ value = node.get('mykey')
18
+
19
+ # Connect to another node
20
+ node.bootstrap('other_node_ip:5000')
3
21
  """
4
22
 
5
- __version__ = "0.1.0"
23
+ __version__ = "0.1.1"
6
24
 
7
25
  from .dht_node import DHTNode
8
- from .cli import main
26
+ from .cli import main as cli_main
9
27
 
10
- __all__ = ["DHTNode", "main"]
28
+ __all__ = ["DHTNode", "cli_main"]
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.4
2
+ Name: simpledht
3
+ Version: 0.1.1
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
@@ -0,0 +1,10 @@
1
+ simpledht/__init__.py,sha256=g6zuNY67roLXDgvxl7JXEXbY23tVWDvWL4FQE3v1vdk,546
2
+ simpledht/cli.py,sha256=5KrXFqxHAHuU9RleB1FPRyI2YZwKwaJijXH-DAmZV5k,3225
3
+ simpledht/dht_node.py,sha256=FZHLigu7NLkJ9smWyJyLK2FBFu2kKy9kxr9Mig6yh0M,8481
4
+ simpledht/test_dht.py,sha256=tsWGhtLkTArFJIdkaWManekhFx2KCUO0Gp93EGBUAlw,2346
5
+ simpledht-0.1.1.dist-info/licenses/LICENSE,sha256=MrSAzCY_7J3C4Hp8PaXaaFJP2ygfmuAWoLTVowEE3B0,1073
6
+ simpledht-0.1.1.dist-info/METADATA,sha256=iTVFk2v6EjXM0RhR1Mis2-6iIT9ZFl1aCmkTLkKD4jM,779
7
+ simpledht-0.1.1.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
8
+ simpledht-0.1.1.dist-info/entry_points.txt,sha256=Hm3BYz1MykAhg94m3JSYsMcdEQEia3bdRocokc-0wxs,49
9
+ simpledht-0.1.1.dist-info/top_level.txt,sha256=VjRxeoXfQJeoPoFhr5JGGMAI5NSLkYJl0WbySmpZ4bs,10
10
+ simpledht-0.1.1.dist-info/RECORD,,
@@ -1,193 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: simpledht
3
- Version: 0.1.0
4
- Summary: A simple distributed hash table implementation
5
- Home-page: https://github.com/yourusername/simpledht
6
- Author: Your Name
7
- Author-email: your.email@example.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
- - Simple CLI interface
38
- - Public IP detection
39
- - Local network support
40
-
41
- ## Installation
42
-
43
- ### From PyPI (Recommended)
44
-
45
- ```bash
46
- pip install simpledht
47
- ```
48
-
49
- ### From Source
50
-
51
- 1. Clone the repository:
52
- ```bash
53
- git clone <repository-url>
54
- cd SimpleDHT
55
- ```
56
-
57
- 2. Create and activate a virtual environment:
58
- ```bash
59
- python -m venv env
60
- source env/bin/activate # On Windows: env\Scripts\activate
61
- ```
62
-
63
- 3. Install the package in development mode:
64
- ```bash
65
- pip install -e .
66
- ```
67
-
68
- ## Usage
69
-
70
- ### Starting a Node
71
-
72
- To start a new DHT node:
73
- ```bash
74
- python cli.py start --host 0.0.0.0 --port 5000
75
- ```
76
-
77
- To start a node and connect to existing nodes:
78
- ```bash
79
- python cli.py start --host 0.0.0.0 --port 5001 --bootstrap "PUBLIC_IP:5000"
80
- ```
81
-
82
- ### Storing Data
83
-
84
- To store a key-value pair:
85
- ```bash
86
- python cli.py put --host PUBLIC_IP --port 5000 mykey "my value"
87
- ```
88
-
89
- ### Retrieving Data
90
-
91
- To retrieve a value:
92
- ```bash
93
- python cli.py get --host PUBLIC_IP --port 5000 mykey
94
- ```
95
-
96
- ### Cross-Network Example
97
-
98
- 1. Start Node 1 (First network):
99
- ```bash
100
- python cli.py start --host 0.0.0.0 --port 5000
101
- ```
102
-
103
- 2. Start Node 2 (Second network):
104
- ```bash
105
- python cli.py start --host 0.0.0.0 --port 5000 --bootstrap "NODE1_PUBLIC_IP:5000"
106
- ```
107
-
108
- 3. Store and retrieve data:
109
- ```bash
110
- # Store on Node 1
111
- python cli.py put --host NODE1_PUBLIC_IP --port 5000 test_key "test_value"
112
-
113
- # Retrieve from Node 2
114
- python cli.py get --host NODE2_PUBLIC_IP --port 5000 test_key
115
- ```
116
-
117
- ## Network Configuration
118
-
119
- ### Firewall Setup
120
-
121
- Ensure the UDP port (default: 5000) is open in your firewall:
122
-
123
- ```bash
124
- # For UFW (Ubuntu)
125
- sudo ufw allow 5000/udp
126
-
127
- # For iptables
128
- sudo iptables -A INPUT -p udp --dport 5000 -j ACCEPT
129
- ```
130
-
131
- ### Port Forwarding
132
-
133
- If your node is behind a NAT router:
134
- 1. Access your router's admin interface
135
- 2. Set up port forwarding for UDP port 5000
136
- 3. Forward to your node's local IP address
137
-
138
- ## Troubleshooting
139
-
140
- ### Common Issues
141
-
142
- 1. **Connection Timeout**
143
- - Check if the target node is running
144
- - Verify firewall settings
145
- - Ensure port forwarding is configured correctly
146
- - Try increasing the timeout: `--timeout 10`
147
-
148
- 2. **Address Already in Use**
149
- - The port is already being used by another process
150
- - Try a different port number
151
- - Check running processes: `netstat -tuln | grep 5000`
152
-
153
- 3. **No Response from Node**
154
- - Verify the node is running
155
- - Check network connectivity: `ping NODE_IP`
156
- - Test port connectivity: `nc -vzu NODE_IP 5000`
157
-
158
- ### Error Messages
159
-
160
- - `Failed to bootstrap with IP:PORT`: Invalid bootstrap node format
161
- - `No response received`: Node is not responding
162
- - `Address already in use`: Port conflict
163
- - `Failed to get public IP`: Network connectivity issue
164
-
165
- ## Architecture
166
-
167
- The DHT implementation uses:
168
- - UDP sockets for communication
169
- - SHA-256 for node ID generation
170
- - Automatic public IP detection
171
- - Data replication between nodes
172
- - Bootstrap nodes for network discovery
173
-
174
- ## Security Considerations
175
-
176
- - This is a basic implementation and should not be used in production without additional security measures
177
- - Consider adding:
178
- - Encryption for data in transit
179
- - Authentication for node joining
180
- - Rate limiting to prevent abuse
181
- - Input validation
182
-
183
- ## Contributing
184
-
185
- 1. Fork the repository
186
- 2. Create a feature branch
187
- 3. Commit your changes
188
- 4. Push to the branch
189
- 5. Create a Pull Request
190
-
191
- ## License
192
-
193
- This project is licensed under the MIT License - see the LICENSE file for details.
@@ -1,10 +0,0 @@
1
- simpledht/__init__.py,sha256=Rz_9ENT9rhI8ocZTZl_EmiHpiit8oYXiGVipRXKD2Vw,174
2
- simpledht/cli.py,sha256=5KrXFqxHAHuU9RleB1FPRyI2YZwKwaJijXH-DAmZV5k,3225
3
- simpledht/dht_node.py,sha256=FZHLigu7NLkJ9smWyJyLK2FBFu2kKy9kxr9Mig6yh0M,8481
4
- simpledht/test_dht.py,sha256=tsWGhtLkTArFJIdkaWManekhFx2KCUO0Gp93EGBUAlw,2346
5
- simpledht-0.1.0.dist-info/licenses/LICENSE,sha256=MrSAzCY_7J3C4Hp8PaXaaFJP2ygfmuAWoLTVowEE3B0,1073
6
- simpledht-0.1.0.dist-info/METADATA,sha256=_FnoM3ghlti3zd_zEgCS1HPmQVOfeQFaXTGfB442_7U,4503
7
- simpledht-0.1.0.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
8
- simpledht-0.1.0.dist-info/entry_points.txt,sha256=Hm3BYz1MykAhg94m3JSYsMcdEQEia3bdRocokc-0wxs,49
9
- simpledht-0.1.0.dist-info/top_level.txt,sha256=VjRxeoXfQJeoPoFhr5JGGMAI5NSLkYJl0WbySmpZ4bs,10
10
- simpledht-0.1.0.dist-info/RECORD,,