tractor/tractor
Tyler Goodlet 63fac5a809 Implement peer-info tracking for UDS streams
Such that any UDS socket pair is represented (and with the recent
updates to) a `USDAddress` via a similar pair-`tuple[str, int]` as TCP
sockets, a pair of the `.filepath: Path` & the peer proc's `.pid: int`
which we read from the underlying `socket.socket` using
`.set/getsockopt()` calls

Impl deats,
- using the Linux specific APIs, we add a `get_peer_info()` which reads
  the `(pid, uid, gid)` using the `SOL_SOCKET` and `SOL_PEECRED` opts to
  `sock.getsockopt()`.
  |_ this presumes the client has been correspondingly configured to
     deliver the creds via a `sock.setsockopt(SOL_SOCKET, SO_PASSCRED,
     1)` call - this required us to override `trio.open_unix_socket()`.
- override `trio.open_unix_socket()` as per the above bullet to ensure
  connecting peers always transmit "credentials" options info to the
  listener.
- update `.get_stream_addrs()` to always call `get_peer_info()` and
  extract the peer's pid for the `raddr` and use `os.getpid()` for
  `laddr` (obvi).
  |_ as part of the new impl also `log.info()` the creds-info deats and
    socket-file path.
  |_ handle the oddity where it depends which of `.getpeername()` or
    `.getsockname()` will return the file-path; i think it's to do with
    who is client vs. server?

Related refinements,
- set `.layer_key: int = 4` for the "transport layer" ;)
- tweak some typing and multi-line unpacking in `.ipc/_tcp`.
2025-07-08 12:57:28 -04:00
..
_testing General improvements 2025-07-08 12:57:28 -04:00
devx move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
experimental Drop now-deprecated deps on modern `trio`/Python 2025-03-16 16:06:24 -04:00
ipc Implement peer-info tracking for UDS streams 2025-07-08 12:57:28 -04:00
msg Finally switch to using address protocol in all runtime 2025-07-08 12:57:28 -04:00
trionics Only set shield flag when trio nursery mode is used 2025-04-13 17:57:37 -03:00
__init__.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
_addr.py Rework/simplify transport addressing 2025-07-08 12:57:28 -04:00
_child.py Trying to make full suite pass with uds 2025-07-08 12:57:28 -04:00
_clustering.py Clean up some imports in `._clustering` 2025-03-27 13:38:47 -04:00
_context.py Finally switch to using address protocol in all runtime 2025-07-08 12:57:28 -04:00
_discovery.py Trying to make full suite pass with uds 2025-07-08 12:57:28 -04:00
_entry.py Finally switch to using address protocol in all runtime 2025-07-08 12:57:28 -04:00
_exceptions.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
_forkserver_override.py Re-license code base for distribution under AGPL 2021-12-14 23:33:27 -05:00
_mp_fixup_main.py Avoid importing mp for as long as possible 2022-02-17 11:55:26 -05:00
_multiaddr.py Fix doc string "its" typo.. 2025-03-20 19:50:31 -04:00
_portal.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
_root.py Finally switch to using address protocol in all runtime 2025-07-08 12:57:28 -04:00
_rpc.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
_runtime.py Trying to make full suite pass with uds 2025-07-08 12:57:28 -04:00
_spawn.py Finally switch to using address protocol in all runtime 2025-07-08 12:57:28 -04:00
_state.py Rework/simplify transport addressing 2025-07-08 12:57:28 -04:00
_streaming.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
_supervise.py Finally switch to using address protocol in all runtime 2025-07-08 12:57:28 -04:00
log.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
to_asyncio.py Continue supporting py3.11+ 2025-03-27 13:24:25 -04:00