Skip to content

driver: SendToConfirmed reports whether the daemon sent a datagram - #54

Draft
TeoSlayer wants to merge 1 commit into
mainfrom
feat/dgram-confirm
Draft

TeoSlayer wants to merge 1 commit into
mainfrom
feat/dgram-confirm

Conversation

@TeoSlayer

Copy link
Copy Markdown
Contributor

Summary

Driver.SendTo returns nil as soon as the datagram is written to the daemon's socket; a datagram the daemon then fails to send (unknown node, port policy, no free ports) is only logged there. This adds a send that waits for the daemon's answer.

Changes

  • SendToConfirmed(dst, port, data) (confirmed bool, err error) sends the new cmdSendToConfirm (0x39) and waits for cmdSendToOK (0x3A) or an error.
    • (true, nil): the daemon handed the datagram to its tunnel (not a delivery guarantee).
    • (false, err): the daemon could not send it, or did not answer in time.
    • (false, nil): the daemon predates confirmed sends. It answered "unknown command", so the datagram went out with the legacy fire-and-forget command and its outcome is unknown. The driver probes once and remembers.
  • SendTo is unchanged. A confirmed send is a request/reply exchange and waits behind an in-flight dial on the same Driver, so SendTo stays the choice where throughput matters.

The daemon side is pilot-protocol/pilotprotocol#494. Either can land first: an old driver against a new daemon behaves as before, and this driver falls back against an old daemon.

Test Plan

  • go build ./..., go vet ./..., go test ./...
  • Unit tests for the confirmed, error and fallback paths
  • Run against a daemon with the handler and one without

🤖 Generated with Claude Code

SendTo is fire-and-forget: the daemon never replies, so a datagram it failed
to send (no route, port policy, ephemeral ports exhausted) still returns nil.

SendToConfirmed sends the daemon's new cmdSendToConfirm (0x39) and waits for
cmdSendToOK (0x3A) or the daemon's error. Against a daemon that predates the
command (it answers "unknown command") the datagram is sent with the legacy
cmdSendTo and reported as unconfirmed; the probe is done once per Driver.
SendTo is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@TeoSlayer
TeoSlayer marked this pull request as draft October 1, 2026 15:45
@TeoSlayer

Copy link
Copy Markdown
Contributor Author

Converted to draft after review. One bug to fix before this lands in the shared library: the IPC has no request IDs, and replies are matched by opcode only (driver/ipc.go, deliverReply). After a 30 s timeout, the late reply is delivered to the next confirmed send. In a scratch test, a second send that the daemon rejected returned confirmed=true because it received the first send's late reply. A caller would be told a datagram went out when it did not.

Everything else checked out: CI is green, and a new driver against a v1.14.1 daemon returns (false, nil) with the datagram still arriving through the legacy path, so there is no hang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant