11 Commits

5 changed files with 60 additions and 11 deletions

View File

@@ -2,6 +2,37 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [0.4.2] - 2026-03-01
### Bug Fixes
- [`29ed2c8`](https://gitea.pufereq.pl/judas/judas_client/commit/29ed2c8e5d256aa7b75424e6d71e14463f8b9caa) **connector.py**: do not connect multiple times when BlockingIOError encountered in `Connector.connect()`
## [0.4.1] - 2026-02-28
### Bug Fixes
- [`eb46889`](https://gitea.pufereq.pl/judas/judas_client/commit/eb4688915747e2dcff3b331618c2b0185f1b611d) **connector.py**: fix `address already in use` error
## [0.4.0] - 2026-02-28
### Features
- [`ac55216`](https://gitea.pufereq.pl/judas/judas_client/commit/ac5521618ba89b25fd31f09357470ed96cd405cf) **client.py**: add custom ID support with `JUDAS_ID` env variable
- [`6486607`](https://gitea.pufereq.pl/judas/judas_client/commit/64866079d7e2087be7dd8588b22be73006605a91) **connector.py**: handle `CONTROL.CLOSE` msgs
### Miscellaneous Tasks
- [`448ffa4`](https://gitea.pufereq.pl/judas/judas_client/commit/448ffa443d0b7b464d3f70f81a0b1b3f17765484) **uv.lock**: update depedencies for Python 3.14
### Refactor
- [`11ae93e`](https://gitea.pufereq.pl/judas/judas_client/commit/11ae93ed3ceac148097f4246e53e2150a653fcf8) **client.py**: rename `Client.mac_address` -> `Client.id`
### Build
- [`2d8dc06`](https://gitea.pufereq.pl/judas/judas_client/commit/2d8dc06fa1087bb1ed968d798dc82cd0c6159e16) **uv.lock**: update judas_protocol to 0.6.0
## [0.3.0] - 2025-11-30 ## [0.3.0] - 2025-11-30
### Bug Fixes ### Bug Fixes

View File

@@ -4,7 +4,7 @@ build-backend = "uv_build"
[project] [project]
name = "judas_client" name = "judas_client"
version = "0.3.0" version = "0.4.2"
description = "A client for judas, a remote PC fleet management system." description = "A client for judas, a remote PC fleet management system."
readme = "README.md" readme = "README.md"
authors = [] authors = []

View File

@@ -4,6 +4,7 @@
from __future__ import annotations from __future__ import annotations
import logging as lg import logging as lg
import os
import uuid import uuid
from judas_protocol import Message from judas_protocol import Message
@@ -29,11 +30,18 @@ class Client:
self.server_host: str = server_host self.server_host: str = server_host
self.server_port: int = server_port self.server_port: int = server_port
self.mac_address: str = self._get_mac_address() if "JUDAS_ID" in os.environ:
self.logger.debug(f"MAC address: {self.mac_address}") self.id: str = os.environ["JUDAS_ID"]
self.logger.debug(
f"Using ID from environment variable JUDAS_ID: {self.id}"
)
else:
self.id = self._get_mac_address()
self.logger.debug(f"ID: {self.id}")
self.connector: Connector = Connector( self.connector: Connector = Connector(
mac_address=self.mac_address, mac_address=self.id,
host=self.server_host, host=self.server_host,
port=self.server_port, port=self.server_port,
on_message=self.handle_message, on_message=self.handle_message,
@@ -63,5 +71,5 @@ class Client:
def run(self) -> None: def run(self) -> None:
"""Run the client.""" """Run the client."""
self.logger.info(f"Starting Client ({self.mac_address})...") self.logger.info(f"Starting Client ({self.id})...")
self.connector.run() self.connector.run()

View File

@@ -41,6 +41,7 @@ class Connector:
self.socket: socket.socket = socket.socket( self.socket: socket.socket = socket.socket(
socket.AF_INET, socket.SOCK_STREAM socket.AF_INET, socket.SOCK_STREAM
) )
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.socket.setblocking(False) self.socket.setblocking(False)
self.selector.register( self.selector.register(
@@ -144,8 +145,8 @@ class Connector:
self.socket.connect((self.host, self.port)) self.socket.connect((self.host, self.port))
connected = True connected = True
except BlockingIOError: except BlockingIOError:
# Connection in progress # connection in progress
time.sleep(0.1) connected = True
except socket.error as e: except socket.error as e:
self.logger.error(f"[!] Connection error: {e}") self.logger.error(f"[!] Connection error: {e}")
self.logger.debug(f"[.] Retrying in {delay} seconds...") self.logger.debug(f"[.] Retrying in {delay} seconds...")
@@ -174,8 +175,17 @@ class Connector:
) )
try: try:
message: Message = Message.from_bytes(message_bytes) message: Message = Message.from_bytes(message_bytes)
# handle incoming ACKs
if ( if (
message.category == Category.CONTROL
and message.action == ControlAction.CLOSE
):
self.logger.warning(
"[!] Received CLOSE command from server, shutting down."
)
self.running = False
break
# handle incoming ACKs
elif (
message.category == Category.CONTROL message.category == Category.CONTROL
and message.action == ControlAction.ACK and message.action == ControlAction.ACK
): ):

6
uv.lock generated
View File

@@ -275,7 +275,7 @@ wheels = [
[[package]] [[package]]
name = "judas-client" name = "judas-client"
version = "0.3.0" version = "0.4.2"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "judas-protocol" }, { name = "judas-protocol" },
@@ -318,8 +318,8 @@ test = [
[[package]] [[package]]
name = "judas-protocol" name = "judas-protocol"
version = "0.5.0" version = "0.6.0"
source = { git = "https://gitea.pufereq.pl/judas/judas_protocol.git#c48b69ecee16f5824ffd8bce8921341d5fa326b7" } source = { git = "https://gitea.pufereq.pl/judas/judas_protocol.git#d16c1914ba343aed300f1c5fae0201370c3274de" }
[[package]] [[package]]
name = "markdown-it-py" name = "markdown-it-py"