Skip to content

Commit 16beb8e

Browse files
joamagclaude
andcommitted
feat: add owner to info_dict and enhance compat connect logging
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 136ef31 commit 16beb8e

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
*
12+
* `owner` field in `info_dict()` exposing the connection owner's name in the DIAG `/connections` endpoint
1313

1414
### Changed
1515

16-
*
16+
* Enhance `CompatLoop.connect_stream()` logging with owner name, full connection ID, and info-level output
1717

1818
### Fixed
1919

src/netius/base/compat.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,29 @@ def on_connect(connection):
264264
protocol = protocol_factory()
265265
_transport = transport.TransportStream(self, connection)
266266
_transport._set_compat(protocol)
267+
conn_id = connection.id if hasattr(connection, "id") else "?"
268+
owner_name = (
269+
connection.owner.name
270+
if hasattr(connection, "owner") and connection.owner
271+
else "?"
272+
)
273+
self._loop.info(
274+
"Compat stream connect %s:%d conn=%s owner=%s",
275+
host,
276+
port,
277+
conn_id,
278+
owner_name,
279+
)
267280
future.set_result((_transport, protocol))
268281

269282
def on_error(connection):
283+
conn_id = connection.id if hasattr(connection, "id") else "?"
284+
self._loop.info(
285+
"Compat stream connect error %s:%d conn=%s",
286+
host,
287+
port,
288+
conn_id,
289+
)
270290
future.set_exception(errors.RuntimeError("Connection issue"))
271291

272292
self._loop.connect(host, port, ssl=ssl, family=family, callback=on_complete)

src/netius/base/conn.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ def info_dict(self, full=False):
672672
socket_type=self._safe_socket_attr("type"),
673673
proxy_pending=getattr(self, "_proxy_pending", None),
674674
is_base=getattr(self, "_base", False),
675+
owner=getattr(self.owner, "name", None) if self.owner else None,
675676
)
676677
return info
677678

0 commit comments

Comments
 (0)