distributed-state-network 0.5.3__tar.gz → 0.5.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.5.3 → distributed_state_network-0.5.4}/PKG-INFO +1 -1
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/pyproject.toml +1 -1
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/dsnode.py +13 -10
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/handler.py +1 -1
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/.github/workflows/publish.yml +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/.gitignore +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/LICENSE +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/README.md +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/coverage.sh +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/documentation/ds-node-config.md +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/documentation/ds-node-server.md +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/documentation/ds-node.md +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/documentation/protocol.md +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/documentation/usage.md +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/__init__.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/create_key.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/objects/config.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/objects/endpoint.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/objects/hello_packet.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/objects/msg_types.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/objects/peers_packet.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/objects/signed_packet.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/objects/state_packet.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/util/__init__.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/util/aes.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/util/byte_helper.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/util/ecdsa.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/util/https.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/src/distributed_state_network/util/key_manager.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/technical.md +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/tests/connections.py +0 -0
- {distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/tests/test.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: distributed-state-network
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.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.5.
|
|
7
|
+
version = "0.5.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"]
|
|
@@ -72,6 +72,12 @@ class DSNode:
|
|
|
72
72
|
def get_aes_key(self) -> bytes:
|
|
73
73
|
return bytes.fromhex(self.config.aes_key)
|
|
74
74
|
|
|
75
|
+
def write_address_book(self, node_id: str, conn: Endpoint):
|
|
76
|
+
if conn.address == "127.0.0.1":
|
|
77
|
+
return
|
|
78
|
+
self.logger.info(f"Address set: {node_id} -> {conn.address}:{conn.port}")
|
|
79
|
+
self.address_book[node_id] = conn
|
|
80
|
+
|
|
75
81
|
def network_tick(self):
|
|
76
82
|
time.sleep(TICK_INTERVAL)
|
|
77
83
|
if self.shutting_down:
|
|
@@ -184,7 +190,7 @@ class DSNode:
|
|
|
184
190
|
if key == self.config.node_id:
|
|
185
191
|
continue
|
|
186
192
|
|
|
187
|
-
self.
|
|
193
|
+
self.write_address_book(key, pkt.connections[key])
|
|
188
194
|
|
|
189
195
|
if key not in self.node_states:
|
|
190
196
|
self.send_hello(self.address_book[key])
|
|
@@ -234,18 +240,16 @@ class DSNode:
|
|
|
234
240
|
if pkt.detected_address:
|
|
235
241
|
self.logger.info(f"Server detected our IP as: {pkt.detected_address}")
|
|
236
242
|
# Update our own connection in the address book with the detected IP
|
|
237
|
-
self.
|
|
243
|
+
self.write_address_book(self.config.node_id, pkt.detected_address, self.config.port)
|
|
238
244
|
|
|
239
|
-
|
|
240
|
-
if pkt.node_id not in self.address_book:
|
|
241
|
-
self.address_book[pkt.node_id] = pkt.connection
|
|
245
|
+
self.write_address_book(pkt.node_id, con)
|
|
242
246
|
|
|
243
247
|
if pkt.node_id not in self.node_states:
|
|
244
248
|
self.node_states[pkt.node_id] = StatePacket(pkt.node_id, 0, b'', { })
|
|
245
249
|
|
|
246
250
|
return pkt.node_id
|
|
247
251
|
|
|
248
|
-
def handle_hello(self, data: bytes, detected_address: str
|
|
252
|
+
def handle_hello(self, data: bytes, detected_address: str) -> bytes:
|
|
249
253
|
pkt = HelloPacket.from_bytes(data)
|
|
250
254
|
self.logger.info(f"Received HELLO from {pkt.node_id}")
|
|
251
255
|
if pkt.version != self.version:
|
|
@@ -254,9 +258,7 @@ class DSNode:
|
|
|
254
258
|
raise Exception(505) # Version not supported
|
|
255
259
|
|
|
256
260
|
self.cred_manager.ensure_public(pkt.node_id, pkt.ecdsa_public_key)
|
|
257
|
-
|
|
258
|
-
if pkt.node_id not in self.address_book:
|
|
259
|
-
self.address_book[pkt.node_id] = pkt.connection
|
|
261
|
+
self.write_address_book(pkt.node_id, Endpoint(detected_address, pkt.connection.port))
|
|
260
262
|
|
|
261
263
|
if pkt.node_id not in self.node_states:
|
|
262
264
|
self.node_states[pkt.node_id] = StatePacket(pkt.node_id, 0, b'', { })
|
|
@@ -280,6 +282,8 @@ class DSNode:
|
|
|
280
282
|
|
|
281
283
|
def send_ping(self, node_id: str):
|
|
282
284
|
try:
|
|
285
|
+
conn = self.connection_from_node(node_id)
|
|
286
|
+
self.logger.debug(f"PING => {node_id} ({conn.address}:{conn.port})")
|
|
283
287
|
self.send_request_to_node(node_id, MSG_PING, b' ')
|
|
284
288
|
except Exception as e:
|
|
285
289
|
raise Exception(f'PING => {node_id}: {e}')
|
|
@@ -324,7 +328,6 @@ class DSNode:
|
|
|
324
328
|
|
|
325
329
|
def bootstrap(self, con: Endpoint):
|
|
326
330
|
bootstrap_id = self.send_hello(con)
|
|
327
|
-
self.address_book[bootstrap_id] = con
|
|
328
331
|
content = self.send_update(bootstrap_id)
|
|
329
332
|
self.handle_update(content)
|
|
330
333
|
self.request_peers(bootstrap_id)
|
|
@@ -8,7 +8,7 @@ from distributed_state_network.objects.config import DSNodeConfig
|
|
|
8
8
|
from distributed_state_network.util.aes import generate_aes_key
|
|
9
9
|
from distributed_state_network.util import stop_thread
|
|
10
10
|
|
|
11
|
-
VERSION = "0.5.
|
|
11
|
+
VERSION = "0.5.4"
|
|
12
12
|
logging.basicConfig(level=logging.INFO)
|
|
13
13
|
|
|
14
14
|
# Silence Flask and Werkzeug logging
|
{distributed_state_network-0.5.3 → distributed_state_network-0.5.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.5.3 → distributed_state_network-0.5.4}/documentation/ds-node-config.md
RENAMED
|
File without changes
|
{distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/documentation/ds-node-server.md
RENAMED
|
File without changes
|
{distributed_state_network-0.5.3 → distributed_state_network-0.5.4}/documentation/ds-node.md
RENAMED
|
File without changes
|
{distributed_state_network-0.5.3 → distributed_state_network-0.5.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|