feat(protocol): resolve and connect UDP endpoints - #24
Open
Jason-Morcos wants to merge 2 commits into
Open
Conversation
Jason-Morcos
marked this pull request as ready for review
August 2, 2026 21:54
Contributor
Author
|
@codex review |
Jason-Morcos
force-pushed
the
codex/py-03-connected-endpoints
branch
from
August 2, 2026 23:33
4e43c5c to
a833db2
Compare
Contributor
Author
|
Adversarial follow-up complete for exact head Validation: 86 passed on Python 3.14 / OpenSSL 3.6.3; 20 endpoint-focused tests passed; the introduced-content safety and diff checks passed. @codex review |
Jason-Morcos
force-pushed
the
codex/py-03-connected-endpoints
branch
from
August 3, 2026 19:46
a833db2 to
d677c72
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dependency
This is a one-commit stack on #23 because the endpoint contract uses its public, redacted
EndpointError. The endpoint-specific commit isd677c72. Once #23 lands, this branch can be rebased and the PR diff will contain only that commit.Problem
DtlsCoapSessioncurrently creates anAF_INETsocket unconditionally and carries the unresolved(host, port)tuple through everysendto/recvfromcall.That has three concrete limitations:
Python's socket documentation defines the IPv4 and IPv6
getaddrinfotuple shapes, recommends constraining type/protocol, and recommends trying returned candidates in order: https://docs.python.org/3/library/socket.html#socket.getaddrinfoPublic API and behavior
ResolvedUdpEndpoint, preserving exact IPv4 or IPv6sockaddrvalues including IPv6 flow/scope IDs.reprredacted to address family only.SOCK_DGRAM/IPPROTO_UDP.local_portbehavior with a family-correct wildcard bind.family=argument toDtlsCoapSession, defaulting toAF_UNSPEC.session.endpoint.close().send/recv; short sends and socket failures become redactedEndpointErrorinstances.A connected datagram socket sets the peer used by subsequent
sendoperations and limits received datagrams to that peer: https://man7.org/linux/man-pages/man3/connect.3p.htmlCompatibility and scope
Existing constructor calls, certificate inputs,
local_port, request APIs, andConnectionError/OSErrorcatches remain valid. Resolution happens afresh on eachconnect(), so host address changes are picked up on reconnect.This PR does not change probing, authentication, handshake timing, retry policy, CoAP behavior, or lifecycle ownership. Probe concurrency and ambiguity remain a separate change.
Validation
101 passed20 passedsend/recvsmartthings_local/protocol/endpoint.py; built-wheel import passedThe LibreSSL compatibility fix from #22 and the validation workflow from #21 are now included in upstream
main.