distributed-state-network 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.
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/PKG-INFO +1 -1
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/pyproject.toml +1 -1
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/dsnode.py +9 -6
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/handler.py +3 -1
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/objects/hello_packet.py +1 -1
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/objects/state_packet.py +1 -1
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/util/key_manager.py +2 -2
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/test.py +1 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/.github/workflows/publish.yml +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/.gitignore +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/LICENSE +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/README.md +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/coverage.sh +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/documentation/ds-node-config.md +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/documentation/ds-node-server.md +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/documentation/ds-node.md +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/documentation/protocol.md +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/documentation/usage.md +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/__init__.py +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/create_key.py +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/objects/config.py +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/objects/endpoint.py +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/objects/peers_packet.py +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/objects/signed_packet.py +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/util/__init__.py +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/util/aes.py +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/util/byte_helper.py +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/util/ecdsa.py +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/src/distributed_state_network/util/https.py +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/technical.md +0 -0
- {distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/tests/connections.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: distributed-state-network
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: A tool to distribute the state of a network device to other devices on the network
|
|
5
5
|
Project-URL: Homepage, https://github.com/erinclemmer/distributed_state_network
|
|
6
6
|
Project-URL: Issues, https://github.com/erinclemmer/distributed_state_network/issues
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "distributed-state-network"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.4"
|
|
8
8
|
authors = [{name="Erin Clemmer", email="erin.c.clemmer@gmail.com"}]
|
|
9
9
|
description = "A tool to distribute the state of a network device to other devices on the network"
|
|
10
10
|
keywords = ["distributed", "networking"]
|
|
@@ -150,10 +150,10 @@ class DSNode:
|
|
|
150
150
|
def handle_peers(self, data: bytes):
|
|
151
151
|
pkt = PeersPacket.from_bytes(data)
|
|
152
152
|
if pkt.node_id not in self.address_book:
|
|
153
|
-
raise Exception(401) # Not Authorized
|
|
153
|
+
raise Exception(401, f"Could not find {pkt.node_id} in address book") # Not Authorized
|
|
154
154
|
|
|
155
155
|
if not pkt.verify_signature(self.cred_manager.read_public(pkt.node_id)):
|
|
156
|
-
raise Exception(406) # Not Acceptable
|
|
156
|
+
raise Exception(406, "Could not verify ECDSA signature of packet") # Not Acceptable
|
|
157
157
|
|
|
158
158
|
peers = { }
|
|
159
159
|
for key in self.address_book.keys():
|
|
@@ -221,14 +221,14 @@ class DSNode:
|
|
|
221
221
|
|
|
222
222
|
# ignore if we accidentally sent an update to ourselves
|
|
223
223
|
if pkt.node_id == self.config.node_id:
|
|
224
|
-
raise Exception(406) # Not acceptable
|
|
224
|
+
raise Exception(406, "Origin and destination are the same") # Not acceptable
|
|
225
225
|
|
|
226
226
|
# don't use packets older than last update
|
|
227
227
|
if pkt.node_id in self.node_states and self.node_states[pkt.node_id].last_update > pkt.last_update:
|
|
228
|
-
raise Exception(406) # Not acceptable
|
|
228
|
+
raise Exception(406, "Update is stale") # Not acceptable
|
|
229
229
|
|
|
230
230
|
if not pkt.verify_signature(self.cred_manager.read_public(pkt.node_id)):
|
|
231
|
-
raise Exception(401) # Not authorized
|
|
231
|
+
raise Exception(401, "Could not verify ECDSA signature") # Not authorized
|
|
232
232
|
|
|
233
233
|
if pkt.node_id not in self.node_states:
|
|
234
234
|
self.node_states[pkt.node_id] = pkt
|
|
@@ -266,7 +266,10 @@ class DSNode:
|
|
|
266
266
|
for key in list(self.node_states.keys())[:]:
|
|
267
267
|
if key == self.config.node_id:
|
|
268
268
|
continue
|
|
269
|
-
|
|
269
|
+
try:
|
|
270
|
+
self.send_update(key)
|
|
271
|
+
except Exception as e:
|
|
272
|
+
print(e)
|
|
270
273
|
|
|
271
274
|
def my_con(self) -> Endpoint:
|
|
272
275
|
return self.connection_from_node(self.config.node_id)
|
|
@@ -27,9 +27,11 @@ def graceful_fail(httpd: BaseHTTPRequestHandler, body: bytes, fn: Callable):
|
|
|
27
27
|
else:
|
|
28
28
|
respond_bytes(httpd, b'')
|
|
29
29
|
except Exception as e:
|
|
30
|
-
httpd.server.node.logger.error(f"Sending Error: {e.args[0]}")
|
|
30
|
+
httpd.server.node.logger.error(f"Sending Error: {e.args[0]} {e.args[1]}")
|
|
31
31
|
httpd.send_response(e.args[0])
|
|
32
32
|
httpd.end_headers()
|
|
33
|
+
httpd.wfile.write(e.args[1].encode('utf-8'))
|
|
34
|
+
httpd.wfile.flush()
|
|
33
35
|
|
|
34
36
|
class DSNodeHandler(BaseHTTPRequestHandler):
|
|
35
37
|
server: "NodeServer"
|
|
@@ -55,6 +55,6 @@ class HelloPacket(SignedPacket):
|
|
|
55
55
|
https_certificate = bts.read_bytes() or None
|
|
56
56
|
|
|
57
57
|
if version == '' or node_id == '' or ecdsa_public_key == b'':
|
|
58
|
-
raise Exception(406) # Not acceptable
|
|
58
|
+
raise Exception(406, "Malformed packet") # Not acceptable
|
|
59
59
|
|
|
60
60
|
return HelloPacket(version, node_id, connection, ecdsa_public_key, ecdsa_signature, https_certificate)
|
|
@@ -55,7 +55,7 @@ class StatePacket(SignedPacket):
|
|
|
55
55
|
node_id = bts.read_string()
|
|
56
56
|
|
|
57
57
|
if node_id == '':
|
|
58
|
-
raise Exception(406) # Not acceptable
|
|
58
|
+
raise Exception(406, "Malformed packet") # Not acceptable
|
|
59
59
|
|
|
60
60
|
last_update = bts.read_float()
|
|
61
61
|
ecdsa_signature = bts.read_bytes()
|
|
@@ -32,7 +32,7 @@ class KeyManager:
|
|
|
32
32
|
|
|
33
33
|
def read_public(self, node_id: str) -> bytes:
|
|
34
34
|
if not os.path.exists(f'{self.folder}/{self.node_id}/{node_id}.{self.public_extension}'):
|
|
35
|
-
raise Exception(401)
|
|
35
|
+
raise Exception(401, f"Cannot find public ECDSA key for {node_id}")
|
|
36
36
|
with open(f'{self.folder}/{self.node_id}/{node_id}.{self.public_extension}', 'rb') as f:
|
|
37
37
|
return f.read()
|
|
38
38
|
|
|
@@ -42,7 +42,7 @@ class KeyManager:
|
|
|
42
42
|
def ensure_public(self, node_id: str, public_key: bytes):
|
|
43
43
|
if self.has_public(node_id):
|
|
44
44
|
if not self.verify_public(node_id, public_key):
|
|
45
|
-
raise Exception(401)
|
|
45
|
+
raise Exception(401, f"Cannot verify ECDSA key for {node_id}")
|
|
46
46
|
else:
|
|
47
47
|
self.write_public(node_id, public_key)
|
|
48
48
|
|
|
@@ -322,6 +322,7 @@ class TestNode(unittest.TestCase):
|
|
|
322
322
|
cm.read_public('test')
|
|
323
323
|
except Exception as e:
|
|
324
324
|
self.assertEqual(e.args[0], 401)
|
|
325
|
+
self.assertEqual(e.args[1], "Cannot find public ECDSA key for test")
|
|
325
326
|
|
|
326
327
|
def test_ensure_cert(self):
|
|
327
328
|
if os.path.exists('certs'):
|
{distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/.github/workflows/publish.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/documentation/ds-node-config.md
RENAMED
|
File without changes
|
{distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/documentation/ds-node-server.md
RENAMED
|
File without changes
|
{distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/documentation/ds-node.md
RENAMED
|
File without changes
|
{distributed_state_network-0.1.2 → distributed_state_network-0.1.4}/documentation/protocol.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|