Skip to content

derphttp: add GetHeaders callback for dynamic auth headers#117

Merged
deansheather merged 1 commit intocoder:mainfrom
ibdafna:nflx/derp-get-headers
May 6, 2026
Merged

derphttp: add GetHeaders callback for dynamic auth headers#117
deansheather merged 1 commit intocoder:mainfrom
ibdafna:nflx/derp-get-headers

Conversation

@ibdafna
Copy link
Copy Markdown

@ibdafna ibdafna commented May 4, 2026

Adds an optional GetHeaders callback to derphttp.Client that, when non-nil, is invoked on every (re)connect to obtain a fresh set of HTTP headers for the DERP upgrade request. When set, it takes precedence over the existing static Header field.

This is useful for callers that need to inject short-lived authentication tokens (e.g. for an authenticating reverse proxy in front of DERP) that must be refreshed on each reconnect rather than captured once at startup. The same pattern already exists on netcheck.Client.GetDERPHeaders.

magicsock plumbs the callback through Conn.derpGetHeaders / Conn.SetDERPGetHeaders, mirroring the existing SetDERPHeader pathway.

Backward compatible: GetHeaders == nil (the default) preserves the existing Header behavior; existing callers see no change.

This code was authored with Cursor under my supervision

@ibdafna ibdafna force-pushed the nflx/derp-get-headers branch from ee4bbb4 to c5b5cce Compare May 4, 2026 23:11
Adds an optional GetHeaders callback to derphttp.Client that, when
non-nil, is invoked on every (re)connect to obtain a fresh set of HTTP
headers for the DERP upgrade request. When set, it takes precedence
over the existing static Header field.

This is useful for callers that need to inject short-lived
authentication tokens (e.g. for an authenticating reverse proxy in
front of DERP) that must be refreshed on each reconnect rather than
captured once at startup. The same pattern already exists on
netcheck.Client.GetDERPHeaders.

magicsock plumbs the callback through Conn.derpGetHeaders /
Conn.SetDERPGetHeaders, mirroring the existing SetDERPHeader pathway.

Backward compatible: GetHeaders == nil (the default) preserves the
existing Header behavior; existing callers see no change.
@ibdafna ibdafna force-pushed the nflx/derp-get-headers branch from c5b5cce to c22782f Compare May 4, 2026 23:59
@ibdafna ibdafna marked this pull request as ready for review May 5, 2026 00:06
@ibdafna ibdafna requested a review from a team as a code owner May 5, 2026 00:06
@deansheather
Copy link
Copy Markdown
Member

Thank you for the contribution!

@deansheather deansheather merged commit e59cf28 into coder:main May 6, 2026
15 of 26 checks passed
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