Skip to content

Adding --same-key and --tcp flags to the client (needed a bug fix) - #37

Open
sbocconi wants to merge 1 commit into
mainfrom
flags
Open

Adding --same-key and --tcp flags to the client (needed a bug fix)#37
sbocconi wants to merge 1 commit into
mainfrom
flags

Conversation

@sbocconi

Copy link
Copy Markdown
Contributor

Changes

  1. Added a --same-key flag to sig0lease-client (main/cmd/sig0lease-client/main.go) for both register and refresh. When passed, it builds the KEY RR straight from the already-loaded signing key (factored out into a shared keyRRFromClientKey helper, reused by the existing additional-section logic) and adds it to the Update section — so the same key no longer needs to be retyped as a full rr-spec string.

    • It composes with --signer=: with the default auto it's recognized as already present (no duplicate Additional copy); it satisfies --signer=update's requirement automatically; and it correctly errors if combined with --signer=none or with a conflicting explicit KEY rr-spec for the same name. Help text and usage examples were updated
  2. Added --tcp (bare boolean, same style as --same-key) to register/refresh/register-tamper and verify. extractTCPFlag/queryProtocol pick "tcp" vs the default "udp", both client.New(...) call sites now use it, and help text/usage lines were updated (including fixing verify's doc, which listed a stale unused second positional arg).

Testing the client over TCP revealed a bug in handling TCP connections in miekg/dns

  1. server/server.go: replaced serveTCP's reliance on dns.Server.ListenAndServe() with a custom accept loop mirroring serveUDP (manual 2-byte-length-prefix framing, one unconditional full Unpack(), same acceptMsg accept/reject policy, same reject-response handling).

Added TCP functionality to the test script:

  1. Added PROXY_PROTOCOL="${PROXY_PROTOCOL:-udp}" to tests/utils.sh with default-unless-overridden mechanism. run_client in tests/test_update.sh now appends --tcp to every client invocation when PROXY_PROTOCOL=tcp, so the entire existing suite (every register/refresh call, ~25 call sites) runs over TCP with PROXY_PROTOCOL=tcp tests/test_update.sh, with no per-call-site changes needed.

@sbocconi sbocconi changed the title Adding --same-key and --tcp flags to the client Adding --same-key and --tcp flags to the client (needed a bug fix) Aug 26, 2026
@sbocconi

sbocconi commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

This last PR modifies some of the changes introduced by the previous one, because of an unexpected bug in miekg/dns library resulting in the fact that that TCP listener cannot be used (this was not known when making the previous PR).

@adam-burns

Copy link
Copy Markdown
Member

Changes

1. Added a --same-key flag to sig0lease-client (main/cmd/sig0lease-client/main.go) for both register and refresh. When passed, it builds the KEY RR straight from the already-loaded signing key (factored out into a shared keyRRFromClientKey helper, reused by the existing additional-section logic) and adds it to the Update section — so the same key no longer needs to be retyped as a full rr-spec string.

I'd propose reversing the behaviour so the default is --same-key, because this is what normally happens in register and enable an option for specifying another key. Thoughts?

Base automatically changed from udp_tcp to main August 28, 2026 09:52
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.

2 participants